| | |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | |
| | | import org.yeshi.utils.bean.BeanUtil; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.location.app.dao.location.LocationUsersDao; |
| | | import com.yeshi.location.app.entity.location.LocationUsers; |
| | | import com.yeshi.location.app.service.inter.location.LocationUsersService; |
| | |
| | | |
| | | @Override |
| | | public void add(LocationUsers locationUsers) throws Exception { |
| | | |
| | | if (locationUsers.getId() == null) { |
| | | locationUsers.setId(LocationUsers.createId(locationUsers.getUid(), locationUsers.getTargetUid())); |
| | | } |
| | | |
| | | //查询主键ID是否存在 |
| | | if(locationUsersDao.get(locationUsers.getId())!=null){ |
| | | throw new Exception("已存在"); |
| | | } |
| | | |
| | | if (locationUsers.getStatus() == null) { |
| | | locationUsers.setStatus(LocationUsers.LocationInviteStatus.sentInvite); |
| | | } |
| | | |
| | | if (locationUsers.getSentCount() == null) { |
| | | locationUsers.setSentCount(0); |
| | | } |
| | | if(locationUsers.getCreateTime()==null){ |
| | | locationUsers.setCreateTime(new Date()); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<LocationUsers> listMyLocationUser(Long uid, LocationUsers.LocationInviteStatus status, int page, int pageSize) { |
| | | DaoQuery daoQuery = new DaoQuery(); |
| | | daoQuery.start = (page - 1) * pageSize; |
| | | daoQuery.count = pageSize; |
| | | daoQuery.status = status; |
| | | daoQuery.uid = uid; |
| | | return locationUsersDao.list(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public long countMyLocationUser(Long uid, LocationUsers.LocationInviteStatus status) { |
| | | DaoQuery daoQuery = new DaoQuery(); |
| | | daoQuery.uid = uid; |
| | | daoQuery.status = status; |
| | | return locationUsersDao.count(daoQuery); |
| | | } |
| | | |
| | | @Override |
| | | public LocationUsers selectByUidAndTargetUid(Long uid, Long targetUid) { |
| | | DaoQuery daoQuery = new DaoQuery(); |
| | | daoQuery.uid = uid; |
| | | daoQuery.targetUid = targetUid; |
| | | daoQuery.count = 1; |
| | | List<LocationUsers> list = locationUsersDao.list(daoQuery); |
| | | return list != null && list.size() > 0 ? list.get(0) : null; |
| | | } |
| | | |
| | | |
| | | } |