示例#1
0
 public Page<User> findUser(Page<User> page, User user) {
   DetachedCriteria dc = userDao.createDetachedCriteria();
   User currentUser = UserUtils.getUser();
   if (!currentUser.isAdmin()) {
     if (user.getArea() == null || user.getArea().getId() == null) {
       user.setArea(currentUser.getArea());
     }
     if (user.getOffice() == null || user.getOffice().getId() == null) {
       user.setOffice(currentUser.getOffice());
     }
   }
   dc.createAlias("area", "area");
   if (user.getArea() != null && user.getArea().getId() != null) {
     dc.add(
         Restrictions.or(
             Restrictions.eq("area.id", user.getArea().getId()),
             Restrictions.eq("area.parent.id", user.getArea().getId()),
             Restrictions.like("area.parentIds", "%," + user.getArea().getId() + ",%")));
   }
   dc.createAlias("office", "office");
   if (user.getOffice() != null && user.getOffice().getId() != null) {
     dc.add(
         Restrictions.or(
             Restrictions.eq("office.id", user.getOffice().getId()),
             Restrictions.eq("office.parent.id", user.getOffice().getId()),
             Restrictions.like("office.parentIds", "%," + user.getOffice().getId() + ",%")));
   }
   if (StringUtils.isNotEmpty(user.getLoginName())) {
     dc.add(Restrictions.like("loginName", "%" + user.getLoginName() + "%"));
   }
   if (StringUtils.isNotEmpty(user.getName())) {
     dc.add(Restrictions.like("name", "%" + user.getName() + "%"));
   }
   dc.add(Restrictions.eq("delFlag", User.DEL_FLAG_NORMAL));
   if (!StringUtils.isNotEmpty(page.getOrderBy())) {
     dc.addOrder(Order.asc("area.code")).addOrder(Order.asc("office.code"));
   }
   return userDao.find(page, dc);
 }
示例#2
0
 public User getUser(Long id) {
   return userDao.findOne(id);
 }
示例#3
0
 @Transactional(readOnly = false)
 public void updateUserLoginInfo(Long id) {
   userDao.updateLoginInfo(SecurityUtils.getSubject().getSession().getHost(), new Date(), id);
 }
示例#4
0
 @Transactional(readOnly = false)
 public void updatePasswordById(Long id, String loginName, String newPassword) {
   userDao.updatePasswordById(entryptPassword(newPassword), id);
   systemRealm.clearCachedAuthorizationInfo(loginName);
 }
示例#5
0
 @Transactional(readOnly = false)
 public void deleteUser(Long id) {
   userDao.deleteById(id);
 }
示例#6
0
 @Transactional(readOnly = false)
 public void saveUser(User user) {
   userDao.clear();
   userDao.save(user);
   systemRealm.clearCachedAuthorizationInfo(user.getLoginName());
 }
示例#7
0
 public User getUserByLoginName(String loginName) {
   return userDao.findByLoginName(loginName);
 }