| | |
| | | |
| | | import com.ks.push.pojo.DO.BPushTask; |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import com.ks.push.pojo.Query.BPushTaskQuery; |
| | | 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.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class BPushTaskDao extends MongodbBaseDao<BPushTask>{ |
| | |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | private Query getQuery(BPushTaskQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.state != null) { |
| | | andList.add(Criteria.where("state").is(daoQuery.state)); |
| | | } |
| | | |
| | | if (daoQuery.appCode != null) { |
| | | andList.add(Criteria.where("appCode").is(daoQuery.appCode)); |
| | | } |
| | | |
| | | if (daoQuery.messageTitle != null) { |
| | | andList.add(Criteria.where("message.title").regex(daoQuery.messageTitle)); |
| | | } |
| | | |
| | | Query query = new Query(); |
| | | if (andList.size() > 0) { |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | } |
| | | return query; |
| | | } |
| | | |
| | | |
| | | public List<BPushTask> list(BPushTaskQuery daoQuery, int start, int count) { |
| | | Query query = getQuery(daoQuery); |
| | | query.skip(start); |
| | | query.limit(count); |
| | | return findList(query); |
| | | } |
| | | |
| | | public long count(BPushTaskQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | return count(query); |
| | | } |
| | | } |