@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void updateUser(User user) throws UserAlreadyExistsException { if (userDao.findDuplicateUserByUserName(user.getUsername(), user.getUserId()).size() > 0) throw new UserAlreadyExistsException(user.getUsername()); else { userDao.updateUser(user); } }
@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public Integer addUser(User user) throws UserAlreadyExistsException { if (userDao.findUserByUserName(user.getUsername()) != null) throw new UserAlreadyExistsException(user.getUsername()); else { PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); String hashedPassword = passwordEncoder.encode(user.getPassword()); user.setPassword(hashedPassword); return userDao.addUser(user); } }
@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void updateUserPassword(User user) { PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); String hashedPassword = passwordEncoder.encode(user.getPassword()); user.setPassword(hashedPassword); userDao.updateUser(user); }
@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void deleteUser(User user) { userDao.deleteUser(user); Map<String, Object> paramMap = new HashMap(); paramMap.put("userId", user.getUserId()); List<PermissionUserGroup> permissionUserGroupList = permissionDao.findPermissionUserGroups(paramMap, "PermissionUserGroup"); for (PermissionUserGroup permissionUserGroup : permissionUserGroupList) { permissionDao.deletePermissionUserGroup(permissionUserGroup); } List<GroupUser> groupUserList = groupUserDao.findAllGroupsByUserId(user.getUserId()); for (GroupUser groupUser : groupUserList) { groupUserDao.deleteGroupUser(groupUser); } }
@Override public void updateLastVisitDate(User user) { user.setLastVisitDate(new Date()); userDao.updateUser(user); }
public User findUserByUserName(String userName) { User result = userDao.findUserByUserName(userName); return result; }
@Override public User findUserById(Integer userId) { return userDao.findUserById(userId); }
@Override public List<User> findAllUsers(Integer clientId) { List<User> users = userDao.findAllUsers(clientId); return users; }
@Override public List<User> findAllUsersByClientId(long clientId) { return userDao.findAllUsersByClientId(clientId); }
@Override public List<User> findUsersByCriteria(String column, String value, Integer clientId) { return userDao.findUsersByCriteria(column, value, clientId); }