コード例 #1
0
  @RequestMapping(value = "/records")
  public @ResponseBody UserListDto getUsers() {

    UserListDto userListDto = new UserListDto();
    userListDto.setUsers(UserMapper.map(service.readAll()));
    return userListDto;
  }
コード例 #2
0
  @RequestMapping(value = "/update", method = RequestMethod.POST)
  public @ResponseBody UserDto update(
      @RequestParam String username,
      @RequestParam String firstName,
      @RequestParam String lastName,
      @RequestParam Integer role) {

    Role existingRole = new Role();
    existingRole.setRole(role);

    User existingUser = new User();
    existingUser.setUsername(username);
    existingUser.setFirstName(firstName);
    existingUser.setLastName(lastName);
    existingUser.setRole(existingRole);

    return UserMapper.map(service.update(existingUser));
  }
コード例 #3
0
  @RequestMapping(value = "/create", method = RequestMethod.POST)
  public @ResponseBody UserDto create(
      @RequestParam String username,
      @RequestParam String password,
      @RequestParam String firstName,
      @RequestParam String lastName,
      @RequestParam Integer role) {

    Role newRole = new Role();
    newRole.setRole(role);

    User newUser = new User();
    newUser.setUsername(username);
    newUser.setPassword(password);
    newUser.setFirstName(firstName);
    newUser.setLastName(lastName);
    newUser.setRole(newRole);

    return UserMapper.map(service.create(newUser));
  }