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);
|
}
|
}
|
|
|
}
|