//查 public StatisticsSchoolPracticeView findByUser(String userId,int statOrgType,int inDateType){ Query query = new Query(Criteria.where("userId").is(userId).and("statOrgType") .is(statOrgType).and("inDateType").is(inDateType)); return template.findOne(query,StatisticsSchoolPracticeView.class); } //改,不存在则新增 public int upsert(StatisticsSchoolPracticeView view){ Query query = new Query(Criteria.where("userId").is(view.getUserId()).and("statOrgType") .is(view.getStatOrgType()).and("inDateType").is(view.getInDateType())); String json = JSON.toJSONString(view); Document document = Document.parse(json); Update update = Update.fromDocument(document); return (int)template.upsert(query,update,StatisticsSchoolPracticeView.class).getMatchedCount(); }
String toDay = DateUtils.format(new Date()); List<String> moguNoSet = moguActiveUserDao.findDistinctMoguNos(toDay); public List<String> findDistinctMoguNos(String toDay) { Query query = new Query(); query.addCriteria(Criteria.where("date").lte(toDay)); return template.findDistinct(query,"moguNo",MoguActiveUserDto.class,String.class); }