๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Web Develop/Spring

[Rest API] Spring JPA๋ฅผ ํ†ตํ•œ CRUD ๊ตฌํ˜„ํ•˜๊ธฐ_SpringBoot

by tripleup 2023. 10. 25.
728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’ก PURPOSE

๊ฐœ์ธ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ ค๊ณ  ํ–ˆ์œผ๋‚˜ ์Šค์Šค๋กœ ์ƒ๊ฐํ•˜๊ธฐ์— ์•„์ง api ์ž‘์„ฑ์— ๋Œ€ํ•ด ๋งŽ์ด ๋ถ€์กฑํ•œ ๊ฒƒ ๊ฐ™์•„ ์–ด๋””์„œ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ด์•ผํ•  ์ง€ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ์ผ๋‹จ jpa์— ๋Œ€ํ•œ ๊ธฐ์ดˆ์ ์ธ ์ง€์‹์„ ์Œ“๊ธฐ ์œ„ํ•ด ๊ณต๋ถ€ํ•œ ๊ฒƒ์„ ๋ณต์Šตํ•  ๊ฒธ ํฌ์ŠคํŒ…ํ•ด๋ณด๊ฒ ๋‹ค.


๐Ÿ’ก STUDY LIST

# Subject 2 : Spring JPA๋ฅผ ํ†ตํ•œ CRUD ๊ตฌํ˜„ํ•˜๊ธฐ

1. ์‚ฌ์šฉ์ž ์ธ์ฆ (31~35)
2. ์‚ฌ์šฉ์ž ์ธ์ฆ (2) (36~42)
3. ์‚ฌ์šฉ์ž ์ธ์ฆ ํ† ํฐ ๋ฐœํ–‰ (43~47)
4. ์‚ฌ์šฉ์ž ๊ด€๋ฆฌ (48~55)
5.์‚ฌ์šฉ์ž ๊ด€๋ฆฌ (2) ํ†ต๊ณ„ (56~60)


๐Ÿ’ก CONTENTS

(31) ์‚ฌ์šฉ์ž ๋“ฑ๋ก์‹œ ์ž…๋ ฅ๊ฐ’์ด ์œ ํšจํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ์˜ˆ์™ธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋Š” ๊ธฐ๋Šฅ

  • ์ž…๋ ฅ๊ฐ’  ์ด๋ฉ”์ผ(ID), ์ด๋ฆ„, ๋น„๋ฐ€๋ฒˆํ˜ธ, ์—ฐ๋ฝ์ฒ˜
  • ์‚ฌ์šฉ์ž ์ •์˜ ์—๋Ÿฌ ๋ชจ๋ธ์„ ์ด์šฉํ•˜์—ฌ ์—๋Ÿฌ๋ฅผ ๋ฆฌํ„ด
/*
user/dto/UserDto.java ์ƒ์„ฑ
*/
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class UserDto {

  @Email(message = "์ด๋ฉ”์ผ ํ˜•์‹์— ๋งž๊ฒŒ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.")
  @NotBlank(message = "์ด๋ฉ”์ผ์€ ํ•„์ˆ˜ ํ•ญ๋ชฉ ์ž…๋‹ˆ๋‹ค.")
  private String email;

  @NotBlank(message = "์ด๋ฆ„์€ ํ•„์ˆ˜ ํ•ญ๋ชฉ ์ž…๋‹ˆ๋‹ค.")
  private String userName;

  @Size(min = 4, message = "๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” 4์ž ์ด์ƒ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.")
  @NotBlank(message = "๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ํ•„์ˆ˜ ํ•ญ๋ชฉ ์ž…๋‹ˆ๋‹ค.")
  private String password;

  @Size(max = 20, message = "์—ฐ๋ฝ์ฒ˜๋Š” ์ตœ๋Œ€ 20์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.")
  @NotBlank(message = "์—ฐ๋ฝ์ฒ˜๋Š” ํ•„์ˆ˜ ํ•ญ๋ชฉ ์ž…๋‹ˆ๋‹ค.")
  private String phone;

}

 

/*
user/controller/UserController.java ์ƒ์„ฑ
*/
@RestController
public class UserController {

  @PostMapping("/api/user")
  public ResponseEntity<?> addUser(@RequestBody @Valid UserDto userDto, Errors errors) {

    List<ResponseError> responseErrorList = new ArrayList<>();
    if (errors.hasErrors()) {
      errors.getAllErrors().forEach((e) -> {
        responseErrorList.add(ResponseError.of((FieldError) e));
      });
      return new ResponseEntity<>(responseErrorList, HttpStatus.BAD_REQUEST);
    }
    return ResponseEntity.ok().build();
  }

}

 


(32) ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ์ž…๋ ฅ๋ฐ›์•„์„œ ์ €์žฅํ•˜๋Š” API

  • ์ž…๋ ฅ๊ฐ’ : ์ด๋ฉ”์ผ(์œ ์ผํ•œ ๊ฐ’ ํ™•์ธ), ์ด๋ฆ„, ๋น„๋ฐ€๋ฒˆํ˜ธ, ์—ฐ๋ฝ์ฒ˜, ๊ฐ€์ž…์ผ (ํ˜„์žฌ์ผ์‹œ)
/*
user/entity/User.java ์ƒ์„ฑ
*/
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
@Entity
public class User {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private long id;

  @Column
  private String email;

  @Column
  private String userName;

  @Column
  private String password;

  @Column
  private String phone;

  @Column
  private LocalDateTime regDate;

}

 

/*
user/repository/UserRepository.java ์ƒ์„ฑ
*/
@Repository
public interface UserRepository extends JpaRepository<User, Long> {

}

 

@RequiredArgsConstructor
@RestController
public class UserController {

  private final UserRepository userRepository;

  @PostMapping("/api/user")
  public ResponseEntity<?> addUser(@RequestBody @Valid UserDto userDto, Errors errors) {

    List<ResponseError> responseErrorList = new ArrayList<>();
    if (errors.hasErrors()) {
      errors.getAllErrors().forEach((e) -> {
        responseErrorList.add(ResponseError.of((FieldError) e));
      });
      return new ResponseEntity<>(responseErrorList, HttpStatus.BAD_REQUEST);
    }
    
    User user = User.builder()
        .email(userDto.getEmail())
        .userName(userDto.getUserName())
        .password(userDto.getPassword())
        .phone(userDto.getPhone())
        .regDate(LocalDateTime.now())
        .build();
    userRepository.save(user);
    
    return ResponseEntity.ok().build();
  }
}


(33) ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ์ˆ˜์ •ํ•˜๋Š” API

  • ์‚ฌ์šฉ์ž ์ •๋ณด๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ UserNOtFoundException ๋ฐœ์ƒ
  • ์ˆ˜์ •์ •๋ณด๋Š” ์—ฐ๋ฝ์ฒ˜๋งŒ ์ˆ˜์ •๊ฐ€๋Šฅ, ์ˆ˜์ •์ผ์ž๋Š” ํ˜„์žฌ ๋‚ ์งœ
  • ์—๋Ÿฌ๋ฉ”์‹œ์ง€๋Š” "์‚ฌ์šฉ์ž ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."
/*
user/dto/UserUpdateDto.java ์ƒ์„ฑ
*/
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class UserDto {

  @Size(max = 20, message = "์—ฐ๋ฝ์ฒ˜๋Š” ์ตœ๋Œ€ 20์ž ์ดํ•˜๋กœ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.")
  @NotBlank(message = "์—ฐ๋ฝ์ฒ˜๋Š” ํ•„์ˆ˜ ํ•ญ๋ชฉ ์ž…๋‹ˆ๋‹ค.")
  private String phone;

}

 

/*
user/entity/User.java์— ์นผ๋Ÿผ ์ถ”๊ฐ€
*/
@Column
private LocalDateTime regDate;

 

@RequiredArgsConstructor
@RestController
public class UserController {

  private final UserRepository userRepository;

  @ExceptionHandler(UserNotFoundException.class)
  public ResponseEntity<String> handlerUserNotFoundException(UserNotFoundException exception) {

    return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
  }

  @PutMapping("/api/user/{id}")
  public ResponseEntity<?> updateUser(@PathVariable Long id,
      @RequestBody @Valid UserUpdateDto userUpdateDto, Errors errors) {

    List<ResponseError> responseErrorList = new ArrayList<>();
    if (errors.hasErrors()) {
      errors.getAllErrors().forEach((e) -> {
        responseErrorList.add(ResponseError.of((FieldError) e));
      });
      return new ResponseEntity<>(responseErrorList, HttpStatus.BAD_REQUEST);
    }

    User user = userRepository.findById(id)
        .orElseThrow(() -> new UserNotFoundException("์‚ฌ์šฉ์ž ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."));

    user.setPhone(userUpdateDto.getPhone());
    user.setUpdateDate(LocalDateTime.now());
    userRepository.save(user);

    return ResponseEntity.ok().build();
  }
}

 


(34) ์‚ฌ์šฉ์ž ์ •๋ณด ์กฐํšŒ (๊ฐ€์ž…ํ•œ ์•„์ด๋””์— ๋Œ€ํ•œ)์˜ ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•˜๋Š” API

  • ๋‹ค๋งŒ ๋ณด์•ˆ์ƒ ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ๊ฐ€์ž…์ผ, ํšŒ์›์ •๋ณด ์ˆ˜์ •์ผ์€ ๋‚ด๋ฆฌ์ง€ ์•Š๋Š”๋‹ค.
/*
user/dto/UserResponseDto.java ์ƒ์„ฑ
*/
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class UserResponseDto {

  private long id;
  private String email;
  private String userName;
  private String phone;

  public static UserResponseDto of(User user) {
    return UserResponseDto.builder()
            .id(user.getId())
            .userName(user.getUserName())
            .phone(user.getPhone())
            .email(user.getEmail())
            .build();
  }
}

 

@RequiredArgsConstructor
@RestController
public class UserController {

  private final UserRepository userRepository;

  @ExceptionHandler(UserNotFoundException.class)
  public ResponseEntity<String> handlerUserNotFoundException(UserNotFoundException exception) {

    return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
  }

  @GetMapping("/api/user/{id}")
  public UserResponseDto getUser(@PathVariable Long id) {

    User user = userRepository.findById(id)
        .orElseThrow(() -> new UserNotFoundException("์‚ฌ์šฉ์ž ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."));

    UserResponseDto userResponseDto = UserResponseDto.of(user);

    return userResponseDto;
  }
}


(35) ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ๊ณต์ง€์‚ฌํ•ญ ๋ชฉ๋ก์— ๋Œ€ํ•œ API ์ž‘์„ฑ

  • ๋‹ค๋งŒ ๋ณด์•ˆ์ƒ ์‚ญ์ œ์ผ๊ณผ ์‚ญ์ œ์ž ์•„์ด๋””๋Š” ๋‚ด๋ฆฌ์ง€ ์•Š์Œ
  • ์ž‘์„ฑ์ž์ •๋ณด๋ฅผ ๋ชจ๋‘ ๋‚ด๋ฆฌ์ง€ ์•Š๊ณ , ์ž‘์„ฑ์ž์™€ ์•„์ด๋””์™€ ์ด๋ฆ„๋งŒ ๋‚ด๋ฆผ
/*
notice/entity/Notice.java์— ์นผ๋Ÿผ ์ถ”๊ฐ€
*/
@JoinColumn
@ManyToOne
private User user;

 

/*
notice/repository/NoticeRepository.java์— ์ถ”๊ฐ€
*/
List<Notice> findByUser(User user);

 

/*
notice/dto/NoticeResponseDto.java ์ƒ์„ฑ
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class NoticeResponseDto {

  private long id;

  private long regUserId;
  private String regUserName;

  private String title;
  private String contents;
  private LocalDateTime regDate;
  private LocalDateTime updateDate;
  private int hits;
  private int likes;

  public static NoticeResponseDto of(Notice notice) {
    return NoticeResponseDto.builder()
        .id(notice.getId())
        .title(notice.getTitle())
        .contents(notice.getContents())
        .regDate(notice.getRegDate())
        .regUserId(notice.getUser().getId())
        .regUserName(notice.getUser().getUserName())
        .updateDate(notice.getUpdateDate())
        .hits(notice.getHits())
        .likes(notice.getLikes())
        .build();
  }
}

 

@RequiredArgsConstructor
@RestController
public class UserController {

  private final UserRepository userRepository;
  private final NoticeRepository noticeRepository;

  @GetMapping("/api/user/{id}/notice")
  public List<NoticeResponseDto> userNotice(@PathVariable Long id) {

    User user = userRepository.findById(id)
        .orElseThrow(() -> new UserNotFoundException("์‚ฌ์šฉ์ž ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."));

    List<Notice> noticeList = noticeRepository.findByUser(user);

    List<NoticeResponseDto> noticeResponseDtoList = new ArrayList<>();

    noticeList.stream().forEach((e) -> {
      noticeResponseDtoList.add(NoticeResponseDto.of(e));
    });

    return noticeResponseDtoList;
  }

  @ExceptionHandler(UserNotFoundException.class)
  public ResponseEntity<String> handlerUserNotFoundException(UserNotFoundException exception) {

    return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
  }
]


(36) ์‚ฌ์šฉ์ž ๋“ฑ๋ก์‹œ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” ์ด๋ฉ”์ผ(์œ ์ผ)์ธ ๊ฒฝ์šฐ ์˜ˆ์™ธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋Š” API

  • ๋™์ผํ•œ ์ด๋ฉ”์ผ์— ๊ฐ€์ž…๋œ ํšŒ์›์ •๋ณด๊ฐ€ ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ ExistEmailException
/*
exception/ExistsEmailException.java ์ƒ์„ฑ
*/
public class UserNotFoundException extends RuntimeException{
  public UserNotFoundException(String message) {
    super(message);
  }
}

 

/*
user/repository/UserRepository.java์— ์ถ”๊ฐ€
*/
int countByEmail(String email);

 

@RequiredArgsConstructor
@RestController
public class UserController {

  private final UserRepository userRepository;
  private final NoticeRepository noticeRepository;

  @PostMapping("/api/user")
  public ResponseEntity<?> addUser(@RequestBody @Valid UserDto userDto, Errors errors) {

    List<ResponseError> responseErrorList = new ArrayList<>();
    if (errors.hasErrors()) {
      errors.getAllErrors().forEach((e) -> {
        responseErrorList.add(ResponseError.of(e));
      });
      return new ResponseEntity<>(responseErrorList, HttpStatus.BAD_REQUEST);
    }

    if (userRepository.countByEmail(userDto.getEmail()) > 0) {
      throw new ExistsEmailException("์ด๋ฏธ ์กด์žฌํ•˜๋Š” ์ด๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.");
    }

    User user = User.builder()
        .email(userDto.getEmail())
        .userName(userDto.getUserName())
        .phone(userDto.getPhone())
        .password(userDto.getPassword())
        .regDate(LocalDateTime.now())
        .build();
    userRepository.save(user);

    return ResponseEntity.ok().build();
  }

  @ExceptionHandler(ExistsEmailException.class)
  public ResponseEntity<String> handlerExistsEmailException(ExistsEmailException exception) {

    return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
  }
}

 


(37) ์‚ฌ์šฉ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ˆ˜์ •ํ•˜๋Š” API

  • ์ด์ „๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ์ผ์น˜ํ•˜๋Š” ๊ฒฝ์šฐ ์ˆ˜์ •
  • ์ผ์น˜ํ•˜์ง€ ์•Š๋Š”๊ฒฝ์šฐ PasswordNotMatchExeption ๋ฐœ์ƒ
  • ๋ฐœ์ƒ๋ฉ”์‹œ์ง€๋Š” "๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."
/*
user/dto/UserPasswordDto.java ์ƒ์„ฑ
*/
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class UserPasswordDto {

  @NotBlank(message = "ํ˜„์žฌ ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ํ•„์ˆ˜ ํ•ญ๋ชฉ ์ž…๋‹ˆ๋‹ค.")
  private String password;

  @Size(min = 4, max = 20, message = "์‹ ๊ทœ ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” 4-20์‚ฌ์ด์˜ ๊ธธ์ด๋กœ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”.")
  @NotBlank(message = "์‹ ๊ทœ ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ํ•„์ˆ˜ ํ•ญ๋ชฉ ์ž…๋‹ˆ๋‹ค.")
  private String newPassword;
}

 

/*
user/repository/UserRepository.java์— ์ถ”๊ฐ€
*/
Optional<User> findByIdAndPassword(Long id, String password);

 

/*
exception/UserNotFoundException.java ์ƒ์„ฑ
*/
public class UserNotFoundException extends RuntimeException{
  public UserNotFoundException(String message) {
    super(message);
  }
}

 

@RequiredArgsConstructor
@RestController
public class UserController {

  private final UserRepository userRepository;
  private final NoticeRepository noticeRepository;


  @PatchMapping("/api/user/{id}/password")
  public ResponseEntity<?> updateUserPassword(@PathVariable Long id, @RequestBody UserPasswordDto userPasswordDto, Errors errors) {

    List<ResponseError> responseErrorList = new ArrayList<>();
    if (errors.hasErrors()) {
      errors.getAllErrors().forEach((e) -> {
        responseErrorList.add(ResponseError.of(e));
      });
      return new ResponseEntity<>(responseErrorList, HttpStatus.BAD_REQUEST);
    }

    User user = userRepository.findByIdAndPassword(id, userPasswordDto.getPassword())
        .orElseThrow(() -> new PasswordNotMatchException("๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."));

    user.setPassword(userPasswordDto.getNewPassword());
    userRepository.save(user);

    return ResponseEntity.ok().build();
  }

  @ExceptionHandler(PasswordNotMatchException.class)
  public ResponseEntity<String> handlerPasswordNotMatchException(PasswordNotMatchException exception) {

    return new ResponseEntity<>(exception.getMessage(), HttpStatus.BAD_REQUEST);
  }
}


(38) ํšŒ์›๊ฐ€์ž…์‹œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์•”ํ˜ธํ™”ํ•˜์—ฌ ์ €์žฅํ•˜๋Š” API

@RequiredArgsConstructor
@RestController
public class UserController {

  private final UserRepository userRepository;
  private final NoticeRepository noticeRepository;

  private String getEncryptPassword(String password) {
    BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
    return bCryptPasswordEncoder.encode(password);
  }

  @PostMapping("/api/user")
  public ResponseEntity<?> addUser(@RequestBody @Valid UserDto userDto, Errors errors) {

    List<ResponseError> responseErrorList = new ArrayList<>();
    if (errors.hasErrors()) {
      errors.getAllErrors().forEach((e) -> {
        responseErrorList.add(ResponseError.of(e));
      });
      return new ResponseEntity<>(responseErrorList, HttpStatus.BAD_REQUEST);
    }

    if (userRepository.countByEmail(userDto.getEmail()) > 0) {
      throw new ExistsEmailException("์ด๋ฏธ ์กด์žฌํ•˜๋Š” ์ด๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.");
    }

    String encryptPassword = getEncryptPassword(userDto.getPassword());

    User user = User.builder()
        .email(userDto.getEmail())
        .userName(userDto.getUserName())
        .phone(userDto.getPhone())
        .password(encryptPassword)
        .regDate(LocalDateTime.now())
        .build();
    userRepository.save(user);

    return ResponseEntity.ok().build();
  }
}


(39) ์‚ฌ์šฉ์ž ํšŒ์› ํƒˆํ‡ด ๊ธฐ๋Šฅ์— ๋Œ€ํ•œ API

  • ํšŒ์›์ •๋ณด๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ์˜ˆ์™ธ์ฒ˜๋ฆฌ
  • ๋งŒ์•ฝ, ํšŒ์›์ด ๊ฒŒ์‹œํŒ์— ๊ธ€์„ ์“ด ๊ฒฝ์šฐ๋Š” ํšŒ์›์‚ญ์ œ๊ฐ€ ๋˜์ง€ ์•Š์Œ
@RequiredArgsConstructor
@RestController
public class UserController {

  private final UserRepository userRepository;
  private final NoticeRepository noticeRepository;

  @DeleteMapping("/api/user/{id}")
  public ResponseEntity<?> deleteUser(@PathVariable Long id) {

    User user = userRepository.findById(id)
        .orElseThrow(() -> new UserNotFoundException("์‚ฌ์šฉ์ž ์ •๋ณด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค."));

    try {
      userRepository.delete(user);
    } catch (DataIntegrityViolationException e) {
      String message = "์ œ์•ฝ์กฐ๊ฑด์— ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.";
      return new ResponseEntity<>(message, HttpStatus.BAD_REQUEST);
    } catch (Exception e) {
      String message = "ํšŒ์› ํƒˆํ‡ด ์ค‘ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.";
      return new ResponseEntity<>(message, HttpStatus.BAD_REQUEST);
    }

    return ResponseEntity.ok().build();
  }
}


(40) ์‚ฌ์šฉ์ž ์•„์ด๋””(์ด๋ฉ”์ผ)์„ ์ฐพ๋Š” API

  • ์ด๋ฆ„๊ณผ ์ „ํ™”๋ฒˆํ˜ธ์— ํ•ด๋‹นํ•˜๋Š” ์ด๋ฉ”์ผ์„ ์ฐพ๋Š”๋‹ค.
728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€