admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package com.yeshi.fanli.dao.user.vip;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
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 com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.bus.user.vip.GiveVIPApplyInfo;
 
@Repository
public class GiveVIPApplyInfoDao extends MongodbBaseDao<GiveVIPApplyInfo> {
 
    /**
     * 查询列表
     * @Title: list
     * @Description: 
     * @param sourceUid
     * @param state
     * @param start
     * @param count
     * @return 
     * List<GiveVIPApplyInfo> 返回类型
     * @throws
     */
    public List<GiveVIPApplyInfo> listByTargetUid(Long targetUid, Integer state, int start, int count) {
        Query query = new Query();
 
        List<Criteria> list = new ArrayList<Criteria>();
        if (targetUid != null)
            list.add(Criteria.where("targetUid").is(targetUid));
 
        if (state != null)
            list.add(Criteria.where("state").is(state));
 
        if (list.size() > 0) {
            Criteria[] cas = new Criteria[list.size()];
            for (int i = 0; i < list.size(); i++)
                cas[i] = list.get(i);
            query.addCriteria(new Criteria().andOperator(cas));
        }
        query.skip(start);
        query.limit(count);
        query.with(new Sort(Sort.Direction.DESC, "createTime"));
        return findList(query);
    }
 
    public long countByTargetUid(Long targetUid, Integer state) {
        Query query = new Query();
 
        List<Criteria> list = new ArrayList<Criteria>();
        if (targetUid != null)
            list.add(Criteria.where("targetUid").is(targetUid));
 
        if (state != null)
            list.add(Criteria.where("state").is(state));
 
        if (list.size() > 0) {
 
            Criteria[] cas = new Criteria[list.size()];
            for (int i = 0; i < list.size(); i++)
                cas[i] = list.get(i);
            query.addCriteria(new Criteria().andOperator(cas));
        }
        return count(query);
    }
    
    
    
    public List<GiveVIPApplyInfo> listBySourceUid(Long sourceUid, Integer state, int start, int count) {
        Query query = new Query();
 
        List<Criteria> list = new ArrayList<Criteria>();
        if (sourceUid != null)
            list.add(Criteria.where("sourceUid").is(sourceUid));
 
        if (state != null)
            list.add(Criteria.where("state").is(state));
 
        if (list.size() > 0) {
            Criteria[] cas = new Criteria[list.size()];
            for (int i = 0; i < list.size(); i++)
                cas[i] = list.get(i);
            query.addCriteria(new Criteria().andOperator(cas));
        }
        query.skip(start);
        query.limit(count);
        query.with(new Sort(Sort.Direction.DESC, "createTime"));
        return findList(query);
    }
 
    public long countBySourceUid(Long sourceUid, Integer state) {
        Query query = new Query();
 
        List<Criteria> list = new ArrayList<Criteria>();
        if (sourceUid != null)
            list.add(Criteria.where("sourceUid").is(sourceUid));
 
        if (state != null)
            list.add(Criteria.where("state").is(state));
 
        if (list.size() > 0) {
 
            Criteria[] cas = new Criteria[list.size()];
            for (int i = 0; i < list.size(); i++)
                cas[i] = list.get(i);
            query.addCriteria(new Criteria().andOperator(cas));
        }
        return count(query);
    }
 
    public void updateSelective(GiveVIPApplyInfo info) {
        Query query = new Query();
        query.addCriteria(Criteria.where("id").is(info.getId()));
        Update update = new Update();
        if (info.getHasDoOtherPlatform() != null)
            update.set("hasDoOtherPlatform", info.getHasDoOtherPlatform());
        if (info.getApplyReason() != null)
            update.set("getApplyReson", info.getApplyReason());
        if (info.getImgList() != null)
            update.set("imgList", info.getImgList());
        if (info.getLevel() != null)
            update.set("level", info.getLevel());
        if (info.getMark() != null)
            update.set("mark", info.getMark());
        if (info.getOtherDirectTeams() != null)
            update.set("otherDirectTeams", info.getOtherDirectTeams());
        if (info.getOtherInDirectTeams() != null)
            update.set("otherInDirectTeams", info.getOtherInDirectTeams());
        if (info.getOtherLevel() != null)
            update.set("otherLevel", info.getOtherLevel());
        if (info.getOtherMonthIncome() != null)
            update.set("otherMonthIncome", info.getOtherMonthIncome());
        if (info.getOtherPlatformName() != null)
            update.set("otherPlatformName", info.getOtherPlatformName());
        if (info.getPhone() != null)
            update.set("phone", info.getPhone());
        if (info.getRejectReson() != null)
            update.set("rejectReson", info.getRejectReson());
        if (info.getSourceUid() != null)
            update.set("sourceUid", info.getSourceUid());
        if (info.getState() != null)
            update.set("state", info.getState());
        if (info.getTargetUid() != null)
            update.set("targetUid", info.getTargetUid());
        if (info.getVerifyTime() != null)
            update.set("verifyTime", info.getVerifyTime());
        if (info.getWxID() != null)
            update.set("wxID", info.getWxID());
        update.set("updateTime", new Date());
        update(query, update);
    }
 
    public void saveImgs(String id, List<String> imgList) {
        GiveVIPApplyInfo info = new GiveVIPApplyInfo();
        info.setId(id);
        info.setImgList(imgList);
        updateSelective(info);
    }
 
}