admin
2020-07-16 b7ab5bb0771b4c221c47a61f04aa2920509e4c4c
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
package com.yeshi.fanli.dao.user.vip;
 
import java.util.ArrayList;
import java.util.List;
 
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
 
import com.yeshi.common.MongodbBaseDao;
import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
import com.yeshi.fanli.entity.bus.user.vip.UserLevelUpgradedNotify;
 
@Repository
public class UserLevelUpgradedNotifyDao extends MongodbBaseDao<UserLevelUpgradedNotify> {
 
    public List<UserLevelUpgradedNotify> listToLevelsByUid(Long uid, List<UserLevelEnum> levelList) {
        Query query = new Query();
        Criteria levels = new Criteria();
        Criteria[] orlevels = new Criteria[levelList.size()];
        for (int i = 0; i < levelList.size(); i++) {
            orlevels[i] = Criteria.where("toLevel").is(levelList.get(i).name());
        }
        levels.orOperator(orlevels);
        query.addCriteria(Criteria.where("uid").is(uid).andOperator(levels));
        return findList(query);
    }
 
    /**
     * 
     * 获取没有通知的列表
     * @Title: listNotNotifiedByUid
     * @Description: 
     * @param uid
     * @return 
     * List<UserLevelUpgradedNotify> 返回类型
     * @throws
     */
    public List<UserLevelUpgradedNotify> listNotNotifiedByUid(Long uid) {
        Query query = new Query();
        query.addCriteria(Criteria.where("uid").is(uid).andOperator(Criteria.where("valid").is(true),
                Criteria.where("notified").is(false)));
 
        List<Order> orders = new ArrayList<>();
        orders.add(new Order(Direction.DESC, "createTime"));
        query.with(new Sort(orders));
 
        return findList(query);
    }
 
}