| | |
| | | import java.util.List; |
| | | import java.lang.Long; |
| | | import java.util.Date; |
| | | |
| | | import org.yeshi.utils.mongo.MongodbBaseDao; |
| | | import com.yeshi.location.app.entity.sos.SOSTargetInfo; |
| | | |
| | | import java.lang.String; |
| | | import java.lang.Integer; |
| | | import java.util.ArrayList; |
| | | |
| | | |
| | | @Repository |
| | | public class SOSTargetInfoDao extends MongodbBaseDao<SOSTargetInfo>{ |
| | | public class SOSTargetInfoDao extends MongodbBaseDao<SOSTargetInfo> { |
| | | |
| | | public void updateSelective(SOSTargetInfo bean) { |
| | | public void updateSelective(SOSTargetInfo bean) { |
| | | Query query = new Query(); |
| | | Update update=new Update(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if(bean.getSosId() != null) { |
| | | if (bean.getSosId() != null) { |
| | | update.set("sosId", bean.getSosId()); |
| | | } |
| | | if(bean.getUid() != null) { |
| | | if (bean.getUid() != null) { |
| | | update.set("uid", bean.getUid()); |
| | | } |
| | | if(bean.getTargetUid() != null) { |
| | | if (bean.getTargetUid() != null) { |
| | | update.set("targetUid", bean.getTargetUid()); |
| | | } |
| | | if(bean.getStatus() != null) { |
| | | if (bean.getStatus() != null) { |
| | | update.set("status", bean.getStatus()); |
| | | } |
| | | if(bean.getStatusDesc() != null) { |
| | | if (bean.getStatusDesc() != null) { |
| | | update.set("statusDesc", bean.getStatusDesc()); |
| | | } |
| | | if(bean.getCreateTime() != null) { |
| | | |
| | | if (bean.getReadTime() != null) { |
| | | update.set("readTime", bean.getReadTime()); |
| | | } |
| | | |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | } |
| | | |
| | | |
| | | public List<SOSTargetInfo> list(DaoQuery daoQuery){ |
| | | public List<SOSTargetInfo> 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.sosId!=null){ |
| | | public List<SOSTargetInfo> listBySOSIds(List<String> sosIds) { |
| | | List<Criteria> orList = new ArrayList<>(); |
| | | for (String sosId : sosIds) { |
| | | orList.add(Criteria.where("sosId").is(sosId)); |
| | | } |
| | | Criteria[] ors = new Criteria[orList.size()]; |
| | | orList.toArray(ors); |
| | | Query query = new Query(); |
| | | query.addCriteria(new Criteria().orOperator(ors)); |
| | | return findList(query); |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.sosId != null) { |
| | | andList.add(Criteria.where("sosId").is(daoQuery.sosId)); |
| | | } |
| | | if(daoQuery.uid!=null){ |
| | | if (daoQuery.uid != null) { |
| | | andList.add(Criteria.where("uid").is(daoQuery.uid)); |
| | | } |
| | | if(daoQuery.targetUid!=null){ |
| | | if (daoQuery.targetUid != null) { |
| | | andList.add(Criteria.where("targetUid").is(daoQuery.targetUid)); |
| | | } |
| | | if(daoQuery.status!=null){ |
| | | if (daoQuery.status != null) { |
| | | andList.add(Criteria.where("status").is(daoQuery.status)); |
| | | } |
| | | 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 String sosId; |
| | | public Long uid; |
| | | public Long targetUid; |
| | |
| | | public int start; |
| | | public int count; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | } |
| | | } |