Esempio n. 1
0
  @RequestMapping(method = RequestMethod.POST)
  ResponseEntity<UserDto> registerUser(
      @Validated @RequestBody UserDto userDto,
      HttpServletRequest request,
      HttpServletResponse response) {

    UserDto outDto = userService.registerUser(userDto);

    if (outDto.getErrorMessage() != null) {
      return new ResponseEntity<>(outDto, null, HttpStatus.NOT_ACCEPTABLE);
    } else {
      return new ResponseEntity<>(outDto, null, HttpStatus.CREATED);
    }
  }
Esempio n. 2
0
  @RequestMapping(value = "nickname", method = RequestMethod.PUT)
  ResponseEntity<UserDto> updateNickname(
      @AuthenticationPrincipal BeadsanUserDetails userDetail,
      @Validated @RequestBody UserDto userDto,
      HttpServletRequest request,
      HttpServletResponse response) {

    if (!userDetail.getUserInfo().getMailAddress().equals(userDto.getMailAddress())) {
      UserDto errorUserDto = new UserDto();
      errorUserDto.setMessage("ログイン時と異なるメールアドレスです");
      return new ResponseEntity<>(null, null, HttpStatus.NOT_ACCEPTABLE);
    }
    UserDto outDto = userService.updateNickname(userDto);
    return new ResponseEntity<>(outDto, null, HttpStatus.OK);
  }