admin
2021-09-24 f788607ff771a47bc60d6a86e00b3433c40f3d2c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.yeshi.buwan.dao.live;
 
import com.yeshi.buwan.domain.live.SuperTVLiveCategory;
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 SuperTVLiveCategoryDao extends MongodbBaseDao<SuperTVLiveCategory> {
 
    public void updateSelective(SuperTVLiveCategory bean) {
        Query query = new Query();
        Update update = new Update();
        query.addCriteria(Criteria.where("id").is(bean.getId()));
        if (bean.getCid() != null) {
            update.set("cid", bean.getCid());
        }
        if (bean.getDetailSystemId() != null) {
            update.set("detailSystemId", bean.getDetailSystemId());
        }
        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<SuperTVLiveCategory> listByDetailSystemId(String detailSystemId, 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("detailSystemId").is(detailSystemId));
        return findList(query);
    }
 
 
    public long countByDetailSystemId(String detailSystemId) {
        BaseQuery baseQuery = new BaseQuery();
        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("detailSystemId").is(detailSystemId));
        return count(query);
    }
 
    public List<SuperTVLiveCategory> listByCid(String cid) {
        Query query = new Query();
        query.addCriteria(Criteria.where("cid").is(cid));
        return findList(query);
    }
 
    public SuperTVLiveCategory selectByCidAndDetailsystemId(String cid, String detailSystemId) {
 
        Query query = new Query();
        query.addCriteria(Criteria.where("cid").is(cid).and("detailSystemId").is(detailSystemId));
        return findOne(query);
    }
}