admin
2022-04-07 e1cc0d03fadc2d251d36c0dc3650f75e830d5363
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
package com.yeshi.makemoney.app.service.impl.msg;
 
import java.lang.Exception;
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import java.util.Date;
 
import org.yeshi.utils.StringUtil;
import org.yeshi.utils.bean.BeanUtil;
 
import java.util.List;
 
import com.yeshi.makemoney.app.dao.msg.AppPageNotifyMsgDao;
import com.yeshi.makemoney.app.entity.msg.AppPageNotifyMsg;
import com.yeshi.makemoney.app.service.inter.msg.AppPageNotifyMsgService;
import com.yeshi.makemoney.app.service.query.msg.AppPageNotifyMsgQuery;
import com.yeshi.makemoney.app.dao.msg.AppPageNotifyMsgDao.DaoQuery;
 
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
 
@Service
public class AppPageNotifyMsgServiceImpl implements AppPageNotifyMsgService {
 
    @Resource
    private AppPageNotifyMsgDao appPageNotifyMsgDao;
 
    @Override
    public List<AppPageNotifyMsg> list(AppPageNotifyMsgQuery appPageNotifyMsgQuery, int page, int pageSize) {
        DaoQuery daoQuery = new DaoQuery();
        daoQuery.type = appPageNotifyMsgQuery.getType();
        daoQuery.content = appPageNotifyMsgQuery.getKw();
        daoQuery.start = (page - 1) * pageSize;
        daoQuery.count = pageSize;
        return appPageNotifyMsgDao.list(daoQuery);
    }
 
    @Override
    public long count(AppPageNotifyMsgQuery appPageNotifyMsgQuery) {
        DaoQuery daoQuery = new DaoQuery();
        daoQuery.type = appPageNotifyMsgQuery.getType();
        daoQuery.content = appPageNotifyMsgQuery.getKw();
        return appPageNotifyMsgDao.count(daoQuery);
    }
 
    @Override
    public AppPageNotifyMsg get(String id) {
        Query query = new Query();
        query.addCriteria(Criteria.where("_id").is(id));
        return appPageNotifyMsgDao.findOne(query);
    }
 
    @Override
    public void add(AppPageNotifyMsg appPageNotifyMsg) throws Exception {
 
        if (appPageNotifyMsg.getId() == null) {
            appPageNotifyMsg.setId(appPageNotifyMsg.toId());
        }
 
        //查询主键ID是否存在
        if (appPageNotifyMsgDao.get(appPageNotifyMsg.getId()) != null) {
            throw new Exception("已存在");
        }
 
 
        appPageNotifyMsg.setMd5(appPageNotifyMsg.toMD5());
 
 
        if (appPageNotifyMsg.getCreateTime() == null) {
            appPageNotifyMsg.setCreateTime(new Date());
        }
        //保存
        appPageNotifyMsgDao.save(appPageNotifyMsg);
    }
 
    @Override
    public void update(AppPageNotifyMsg appPageNotifyMsg) {
        if (appPageNotifyMsg.getUpdateTime() == null) {
            appPageNotifyMsg.setUpdateTime(new Date());
        }
        //更新
        appPageNotifyMsgDao.updateSelective(appPageNotifyMsg);
    }
 
    @Override
    public void delete(List<String> idList) {
        for (String id : idList) {
            appPageNotifyMsgDao.delete(id);
        }
    }
 
 
}