| | |
| | | package com.yeshi.makemoney.app.dao.user; |
| | | |
| | | import com.yeshi.makemoney.app.entity.user.UserExtraInfo; |
| | | import org.springframework.data.domain.Sort; |
| | | 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.data.domain.Sort; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | import com.yeshi.makemoney.app.entity.user.UserExtraInfo; |
| | | import java.util.Date; |
| | | import org.yeshi.utils.mongo.MongodbBaseDao; |
| | | import java.lang.String; |
| | | import java.lang.Integer; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | @Repository |
| | | public class UserExtraInfoDao extends MongodbBaseDao<UserExtraInfo>{ |
| | | public class UserExtraInfoDao extends MongodbBaseDao<UserExtraInfo> { |
| | | |
| | | public void updateSelective(UserExtraInfo bean) { |
| | | public void updateSelective(UserExtraInfo bean) { |
| | | Query query = new Query(); |
| | | Update update=new Update(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("id").is(bean.getId())); |
| | | if(bean.getInviteCode() != null) { |
| | | if (bean.getInviteCode() != null) { |
| | | update.set("inviteCode", bean.getInviteCode()); |
| | | } |
| | | if(bean.getUnReadMsgCount() != null) { |
| | | if (bean.getUnReadMsgCount() != null) { |
| | | update.set("unReadMsgCount", bean.getUnReadMsgCount()); |
| | | } |
| | | if(bean.getCreateTime() != null) { |
| | | |
| | | if (bean.getSignInNotify() != null) { |
| | | update.set("signInNotify", bean.getSignInNotify()); |
| | | } |
| | | |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | } |
| | | |
| | | |
| | | public List<UserExtraInfo> list(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | 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); |
| | | return count(query); |
| | | } |
| | | |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.inviteCode != null) { |
| | | andList.add(Criteria.where("inviteCode").is(daoQuery.inviteCode)); |
| | | } |
| | | Query query = new Query(); |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | if (ands.length > 0) { |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | } |
| | | return query; |
| | | } |
| | | |
| | | public static class DaoQuery { |
| | | public String inviteCode; |
| | | public int start; |
| | | public int count; |
| | | public List<Sort.Order> sortList; |
| | | } |
| | | |
| | | |
| | | } |