Skip to content

Commit

Permalink
Merge pull request #540 from woowacourse-teams/feat/#527
Browse files Browse the repository at this point in the history
feat: 빈 쪽지 검증 추가
  • Loading branch information
dooboocookie authored Nov 8, 2023
2 parents ade11dd + 03443e8 commit 1056f33
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 103 deletions.
1 change: 1 addition & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'

implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public ResponseEntity<ExceptionResponse> handleBaseException(final BaseException
@ExceptionHandler({
HttpMessageNotReadableException.class,
MethodArgumentNotValidException.class,
HttpMediaTypeNotSupportedException.class})
HttpMediaTypeNotSupportedException.class,
MethodArgumentNotValidException.class})
public ResponseEntity<ExceptionResponse> handleTypeMismatchException(final Exception e) {
final CommonExceptionType commonExceptionType = CommonExceptionType.INVALID_REQUEST_BODY;
final ExceptionResponse exceptionResponse = new ExceptionResponse(commonExceptionType.errorCode(), commonExceptionType.errorMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.now.naaga.letter.domain.letterlog.LetterLogType;
import com.now.naaga.letter.presentation.dto.*;
import com.now.naaga.player.presentation.dto.PlayerRequest;
import jakarta.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -26,7 +27,7 @@ public LetterController(final LetterService letterService) {

@PostMapping("/letters")
public ResponseEntity<LetterResponse> createLetter(@Auth final PlayerRequest playerRequest,
@RequestBody final LetterRequest letterRequest) {
@Valid @RequestBody final LetterRequest letterRequest) {
final CreateLetterCommand createLetterCommand = CreateLetterCommand.of(playerRequest, letterRequest);
final Letter letter = letterService.writeLetter(createLetterCommand);
return ResponseEntity
Expand Down Expand Up @@ -73,4 +74,3 @@ public ResponseEntity<List<LetterResponse>> findLetterInGame(@Auth final PlayerR
.body(writeLetterResponses);
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.now.naaga.letter.presentation.dto;

public record LetterRequest(String message,
import jakarta.validation.constraints.NotBlank;

public record LetterRequest(@NotBlank String message,
Double latitude,
Double longitude) {
}
Loading

0 comments on commit 1056f33

Please sign in to comment.