示例#1
0
  @Transactional(readOnly = false, rollbackFor = Exception.class)
  @Override
  public User delete(Long id) throws Exception {
    LOGGER.debug("User delete(Long id): " + id);

    User user = userRepository.findOne(id);

    if (user == null) {
      LOGGER.debug("No user found with id: " + id);
      throw new Exception();
    }

    userRepository.delete(user);
    return user;
  }
示例#2
0
  @Transactional(readOnly = false, rollbackFor = Exception.class)
  @Override
  public User update(User user) throws Exception {
    LOGGER.debug("update(User user): " + user);
    user.setUpdatedDate(new Date());
    LOGGER.debug("Updating user with information: " + user);

    User userDb = userRepository.findOne(user.getId());

    if (userDb == null) {
      LOGGER.debug("No user found with id: " + user.getId());
      throw new Exception();
    }

    userRepository.save(user);
    return user;
  }
示例#3
0
  @Transactional(readOnly = false, rollbackFor = Exception.class)
  @Override
  public User create(User user) {
    LOGGER.debug("User create(User user):" + user);
    Date now = new Date();
    user.setCreatedDate(now);
    user.setUpdatedDate(now);

    Role role = roleRepository.findOne(user.getRole().getId());
    user.setRole(role);

    LOGGER.debug("Creating a new user with information: " + user);
    return userRepository.save(user);
  }
示例#4
0
 @Transactional(readOnly = true)
 @Override
 public List<User> findAllOrdered() {
   LOGGER.debug("findAllOrdered()");
   return userRepository.findAllOrdered();
 }
示例#5
0
 @Transactional(readOnly = true)
 @Override
 public User findById(Long id) {
   LOGGER.debug("findById(Long id): " + id);
   return userRepository.findOne(id);
 }
示例#6
0
 @Override
 public List<User> findByUsernameAndPassword(String username, String password) {
   LOGGER.debug("findByUsernameAndPassword(String username, String password): " + username);
   return userRepository.findByUsernameAndPassword(username, password);
 }