From 2464548977f4720bc8fceeb5d999c1a3852c2d10 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 21 四月 2022 19:38:30 +0800 Subject: [PATCH] 签到与任务 --- app/src/main/java/com/yeshi/makemoney/app/dao/goldcorn/GoldCornGetRecordDao.java | 81 ++++++++++++++++++++++++---------------- 1 files changed, 48 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/com/yeshi/makemoney/app/dao/goldcorn/GoldCornGetRecordDao.java b/app/src/main/java/com/yeshi/makemoney/app/dao/goldcorn/GoldCornGetRecordDao.java index 634d385..8dd8731 100644 --- a/app/src/main/java/com/yeshi/makemoney/app/dao/goldcorn/GoldCornGetRecordDao.java +++ b/app/src/main/java/com/yeshi/makemoney/app/dao/goldcorn/GoldCornGetRecordDao.java @@ -9,100 +9,115 @@ import java.util.List; import java.lang.Long; import java.util.Date; + import org.yeshi.utils.mongo.MongodbBaseDao; + import java.lang.String; + import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetType; + import java.lang.Integer; import java.util.ArrayList; + import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetRecord; @Repository -public class GoldCornGetRecordDao extends MongodbBaseDao<GoldCornGetRecord>{ +public class GoldCornGetRecordDao extends MongodbBaseDao<GoldCornGetRecord> { - public void updateSelective(GoldCornGetRecord bean) { + public void updateSelective(GoldCornGetRecord bean) { Query query = new Query(); - Update update=new Update(); + Update update = new Update(); query.addCriteria(Criteria.where("id").is(bean.getId())); - if(bean.getUid() != null) { + if (bean.getUid() != null) { update.set("uid", bean.getUid()); } - if(bean.getDay() != null) { + if (bean.getDay() != null) { update.set("day", bean.getDay()); } - if(bean.getCornNum() != null) { + if (bean.getCornNum() != null) { update.set("cornNum", bean.getCornNum()); } - if(bean.getFromUid() != null) { + if (bean.getFromUid() != null) { update.set("fromUid", bean.getFromUid()); } - if(bean.getFromId() != null) { + if (bean.getFromId() != null) { update.set("fromId", bean.getFromId()); } - if(bean.getType() != null) { + if (bean.getType() != null) { update.set("type", bean.getType()); } - if(bean.getRemarks() != null) { + 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<GoldCornGetRecord> list(DaoQuery daoQuery){ + public List<GoldCornGetRecord> 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.uid!=null){ + private Query getQuery(DaoQuery daoQuery) { + List<Criteria> andList = new ArrayList<>(); + if (daoQuery.uid != null) { andList.add(Criteria.where("uid").is(daoQuery.uid)); } - if(daoQuery.day!=null){ + if (daoQuery.day != null) { andList.add(Criteria.where("day").is(daoQuery.day)); } - if(daoQuery.fromUid!=null){ + + if (daoQuery.dayList != null && daoQuery.dayList.size() > 0) { + Criteria[] ors = new Criteria[daoQuery.dayList.size()]; + for (int i = 0; i < ors.length; i++) { + ors[i] = Criteria.where("day").is(daoQuery.dayList.get(i)); + } + andList.add(new Criteria().orOperator(ors)); + } + + if (daoQuery.fromUid != null) { andList.add(Criteria.where("fromUid").is(daoQuery.fromUid)); } - if(daoQuery.fromId!=null){ + if (daoQuery.fromId != null) { andList.add(Criteria.where("fromId").is(daoQuery.fromId)); } - if(daoQuery.type!=null){ + if (daoQuery.type != null) { andList.add(Criteria.where("type").is(daoQuery.type)); } - if(daoQuery.maxCreateTime!=null){ + if (daoQuery.maxCreateTime != null) { andList.add(Criteria.where("createTime").lt(daoQuery.maxCreateTime)); } - if(daoQuery.minCreateTime!=null){ + if (daoQuery.minCreateTime != null) { andList.add(Criteria.where("createTime").gte(daoQuery.minCreateTime)); } - 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 Long uid; public String day; + public List<String> dayList; public Long fromUid; public String fromId; public GoldCornGetType type; @@ -111,5 +126,5 @@ public int start; public int count; public List<Sort.Order> sortList; - } + } } -- Gitblit v1.8.0