package com.yeshi.buwan.dao.live;
|
|
import com.yeshi.buwan.domain.live.TVLiveCategoryChannelMap;
|
import com.yeshi.buwan.dao.base.MongodbBaseDao;
|
import com.yeshi.buwan.query.BaseQuery;
|
import org.springframework.data.domain.Sort;
|
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Update;
|
import org.springframework.stereotype.Repository;
|
|
import java.util.Arrays;
|
import java.util.Date;
|
import java.util.List;
|
|
@Repository
|
public class TVLiveCategoryChannelMapDao extends MongodbBaseDao<TVLiveCategoryChannelMap> {
|
|
public void updateSelective(TVLiveCategoryChannelMap bean) {
|
Query query = new Query();
|
Update update = new Update();
|
query.addCriteria(Criteria.where("id").is(bean.getId()));
|
if (bean.getChannelId() != null) {
|
update.set("channelId", bean.getChannelId());
|
}
|
if (bean.getCategoryId() != null) {
|
update.set("categoryId", bean.getCategoryId());
|
}
|
if (bean.getWeight() != null) {
|
update.set("weight", bean.getWeight());
|
}
|
if (bean.getCreateTime() != null) {
|
update.set("createTime", bean.getCreateTime());
|
}
|
update.set("updateTime", new Date());
|
update(query, update);
|
}
|
|
|
public List<TVLiveCategoryChannelMap> listByCid(String cid, int start, int count) {
|
BaseQuery baseQuery = new BaseQuery();
|
baseQuery.start = start;
|
baseQuery.count = count;
|
Query query = BaseQuery.createBaseMongoQuery(baseQuery, Arrays.asList(new Sort.Order[]{new Sort.Order(Sort.Direction.DESC, "weight"), new Sort.Order(Sort.Direction.DESC, "createTime")}));
|
query.addCriteria(Criteria.where("categoryId").is(cid));
|
return findList(query);
|
}
|
|
|
public long countByCid(String cid) {
|
BaseQuery baseQuery = new BaseQuery();
|
Query query = BaseQuery.createBaseMongoQuery(baseQuery, null);
|
query.addCriteria(Criteria.where("categoryId").is(cid));
|
return count(query);
|
}
|
|
|
}
|