| | |
| | | |
| | | |
| | | @Repository |
| | | public class GoldCornGetFrequencyConfigDao extends MongodbBaseDao<GoldCornGetFrequencyConfig>{ |
| | | public class GoldCornGetFrequencyConfigDao extends MongodbBaseDao<GoldCornGetFrequencyConfig> { |
| | | |
| | | public void updateSelective(GoldCornGetFrequencyConfig bean) { |
| | | public void updateSelective(GoldCornGetFrequencyConfig bean) { |
| | | Query query = new Query(); |
| | | Update update=new Update(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if(bean.getSystem() != null) { |
| | | if (bean.getSystem() != null) { |
| | | update.set("system", bean.getSystem()); |
| | | } |
| | | if(bean.getType() != null) { |
| | | if (bean.getType() != null) { |
| | | update.set("type", bean.getType()); |
| | | } |
| | | if(bean.getLimitCount() != null) { |
| | | if (bean.getLimitCount() != null) { |
| | | update.set("limitCount", bean.getLimitCount()); |
| | | } |
| | | if(bean.getTimeUnit() != null) { |
| | | if (bean.getTimeUnit() != null) { |
| | | update.set("timeUnit", bean.getTimeUnit()); |
| | | } |
| | | if(bean.getValidateTime() != null) { |
| | | if (bean.getValidateTime() != null) { |
| | | update.set("validateTime", bean.getValidateTime()); |
| | | } |
| | | if(bean.getRemarks() != null) { |
| | | |
| | | if (bean.getMinSpaceTime() != null) { |
| | | update.set("minSpaceTime", bean.getMinSpaceTime()); |
| | | } |
| | | |
| | | if (bean.getRemarks() != null) { |
| | | update.set("remarks", bean.getRemarks()); |
| | | } |
| | | if(bean.getCreateTime() != null) { |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | } |
| | | |
| | | |
| | | public List<GoldCornGetFrequencyConfig> list(DaoQuery daoQuery){ |
| | | public List<GoldCornGetFrequencyConfig> list(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | if (daoQuery.sortList!=null && daoQuery.sortList.size()>0){ |
| | | if (daoQuery.sortList != null && daoQuery.sortList.size() > 0) { |
| | | query.with(Sort.by(daoQuery.sortList)); |
| | | } |
| | | query.skip(daoQuery.start); |
| | | query.limit(daoQuery.count); |
| | | return findList(query); |
| | | } |
| | | } |
| | | |
| | | public long count(DaoQuery daoQuery){ |
| | | Query query=getQuery(daoQuery); |
| | | public long count(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | return count(query); |
| | | } |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery){ |
| | | List<Criteria> andList=new ArrayList<>(); |
| | | if(daoQuery.system!=null){ |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.system != null) { |
| | | andList.add(Criteria.where("system").is(daoQuery.system)); |
| | | } |
| | | if(daoQuery.type!=null){ |
| | | if (daoQuery.type != null) { |
| | | andList.add(Criteria.where("type").is(daoQuery.type)); |
| | | } |
| | | if(daoQuery.maxValidateTime!=null){ |
| | | if (daoQuery.maxValidateTime != null) { |
| | | andList.add(Criteria.where("validateTime").lt(daoQuery.maxValidateTime)); |
| | | } |
| | | if(daoQuery.minValidateTime!=null){ |
| | | if (daoQuery.minValidateTime != null) { |
| | | andList.add(Criteria.where("validateTime").gte(daoQuery.minValidateTime)); |
| | | } |
| | | Query query=new Query(); |
| | | Criteria[] ands=new Criteria[andList.size()]; |
| | | Query query = new Query(); |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | if(ands.length>0){ |
| | | if (ands.length > 0) { |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | } |
| | | return query; |
| | | } |
| | | } |
| | | |
| | | public static class DaoQuery{ |
| | | public static class DaoQuery { |
| | | public SystemEnum system; |
| | | public GoldCornGetType type; |
| | | public Date maxValidateTime; |
| | |
| | | public int start; |
| | | public int count; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | } |
| | | } |