Skip to content

Commit 4bef513

Browse files
committed
feat: 요청 유효성 검증추가
- 관심기관 등록 요청 Dto에 유효성 검증 어노테이션 추가 - 활성화를 위해 컨트롤러에 @Valid 어노테이션 추가
1 parent 82bf3f2 commit 4bef513

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/java/com/somemore/interestcenter/controller/InterestCenterCommandApiController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.somemore.interestcenter.usecase.RegisterInterestCenterUseCase;
88
import io.swagger.v3.oas.annotations.Operation;
99
import io.swagger.v3.oas.annotations.tags.Tag;
10+
import jakarta.validation.Valid;
1011
import lombok.RequiredArgsConstructor;
1112
import org.springframework.web.bind.annotation.*;
1213

@@ -21,7 +22,7 @@ public class InterestCenterCommandApiController {
2122

2223
@Operation(summary = "관심기관 등록 API")
2324
@PostMapping()
24-
public ApiResponse<RegisterInterestCenterResponseDto> registerInterestCenter(@RequestBody RegisterInterestCenterRequestDto requestDto) {
25+
public ApiResponse<RegisterInterestCenterResponseDto> registerInterestCenter(@Valid @RequestBody RegisterInterestCenterRequestDto requestDto) {
2526

2627
RegisterInterestCenterResponseDto responseDto = registerInterestCenterUseCase.registerInterestCenter(requestDto);
2728

src/main/java/com/somemore/interestcenter/dto/request/RegisterInterestCenterRequestDto.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
import com.fasterxml.jackson.databind.annotation.JsonNaming;
55
import com.somemore.interestcenter.domain.InterestCenter;
66
import io.swagger.v3.oas.annotations.media.Schema;
7+
import jakarta.validation.constraints.NotNull;
78

89
import java.util.UUID;
910

1011
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
1112
public record RegisterInterestCenterRequestDto(
13+
1214
@Schema(description = "봉사자 ID", example = "123e4567-e89b-12d3-a456-426614174000")
15+
@NotNull(message = "봉사자 ID는 필수값입니다.")
1316
UUID volunteerId,
1417

1518
@Schema(description = "봉사자 ID", example = "123e4567-e89b-12d3-a456-426614174000")
19+
@NotNull(message = "기관 ID는 필수값입니다.")
1620
UUID centerId
1721
) {
1822
public InterestCenter toEntity(){

0 commit comments

Comments
 (0)