package com.yeshi.fanli.dao.brand;
|
|
import java.util.Date;
|
import java.util.List;
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.stereotype.Repository;
|
|
import com.yeshi.fanli.dao.MongodbBaseDao;
|
import com.yeshi.fanli.entity.brand.BrandShopCahe;
|
|
@Repository
|
public class BrandShopCaheDao extends MongodbBaseDao<BrandShopCahe> {
|
|
|
/**
|
* 新增
|
* @param record
|
*/
|
public void insert(BrandShopCahe record) {
|
if (record == null) {
|
return;
|
}
|
mongoTemplate.insert(record);
|
}
|
|
/**
|
* 查询品牌下店铺
|
* @param brandId
|
* @return
|
*/
|
public List<BrandShopCahe> getByBrandId(Long brandId){
|
if (brandId == null)
|
return null;
|
Query query = new Query();
|
query.addCriteria(Criteria.where("brandId").is(brandId));
|
return mongoTemplate.find(query, BrandShopCahe.class);
|
}
|
|
/**
|
* 查询品牌下店铺
|
* @param brandId
|
* @return
|
*/
|
public List<BrandShopCahe> getByBrandShop(Long brandId, int type){
|
if (brandId == null)
|
return null;
|
Query query = new Query();
|
query.addCriteria(
|
new Criteria().andOperator(
|
Criteria.where("brandId").is(brandId),
|
Criteria.where("shop.userType").is(type)
|
)
|
);
|
return mongoTemplate.find(query, BrandShopCahe.class);
|
}
|
|
|
/**
|
* 品牌id
|
* @param brandId
|
*/
|
public void removeByBrandId(Long brandId) {
|
Query query = new Query();
|
query.addCriteria(Criteria.where("brandId").is(brandId));
|
mongoTemplate.remove(query, BrandShopCahe.class);
|
}
|
|
|
/**
|
* 删除根据时间
|
*
|
* @param id
|
* @return
|
*/
|
public void removeByDate(Long brandId, int userType,Date createTime) {
|
Query query = new Query();
|
query.addCriteria(
|
new Criteria().andOperator(
|
Criteria.where("brandId").is(brandId),
|
Criteria.where("shop.userType").is(userType),
|
Criteria.where("createTime").lt(createTime)
|
)
|
);
|
mongoTemplate.remove(query, BrandShopCahe.class);
|
}
|
|
/**
|
* 删除根据时间
|
*
|
* @param id
|
* @return
|
*/
|
public void removeAgoByDate(Date createTime) {
|
Query query = new Query();
|
query.addCriteria(Criteria.where("createTime").lt(createTime));
|
mongoTemplate.remove(query, BrandShopCahe.class);
|
}
|
}
|