diff --git a/src/main/java/com/gdsc/petwalk/auth/itself/controller/AuthController.java b/src/main/java/com/gdsc/petwalk/auth/itself/controller/AuthController.java index b19a3c4..f5f4620 100644 --- a/src/main/java/com/gdsc/petwalk/auth/itself/controller/AuthController.java +++ b/src/main/java/com/gdsc/petwalk/auth/itself/controller/AuthController.java @@ -15,6 +15,7 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -51,8 +52,8 @@ public ResponseEntity> checkDuplicate( ); } - @PostMapping("/sign-up") - @Operation(summary = "회원가입 로직", description = "signUpRequestDto는 application/json 형식, uploadPhoto는 multipart/form-data 형식으로, 두 개를 한꺼번에 form-data 형식으로 보내주면 됨") + @PostMapping(value = "/sign-up", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Operation(summary = "회원가입 로직", description = "signUpRequestDto는 application/json 형식, uploadPhoto는 multipart/form-data 형식으로, 두 개를 한꺼번에 form-data 형식으로 보내주면 됨.
try it out을 누르면 dto 정보를 확인 할 수 있습니다. swagger에서 직접 테스트는 안되니 참고하세요!") @ApiResponse(responseCode = "200", description = "token 반환") public ResponseEntity> signUp( @RequestPart("signUpRequestDto") @Valid SignUpRequestDto request, diff --git a/src/main/java/com/gdsc/petwalk/domain/pet/controller/PetController.java b/src/main/java/com/gdsc/petwalk/domain/pet/controller/PetController.java index 8fad317..76a5149 100644 --- a/src/main/java/com/gdsc/petwalk/domain/pet/controller/PetController.java +++ b/src/main/java/com/gdsc/petwalk/domain/pet/controller/PetController.java @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -39,14 +40,14 @@ public class PetController { private final PetService petService; - @PostMapping + @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PreAuthorize("isAuthenticated()") - @Operation(summary = "회원가입 후 펫 생성 로직", description = "회원가입 후 펫 생성 로직") + @Operation(summary = "회원가입 후 펫 생성 로직", description = "회원가입 후 펫 생성 로직, petCreateRequestDto는 application/json 형식, uploadPhoto는 multipart/form-data 형식으로, 두 개를 한꺼번에 form-data 형식으로 보내주면 됨.
try it out을 누르면 dto 정보를 확인 할 수 있습니다. swagger에서 직접 테스트는 안되니 참고하세요!") @ApiResponse(responseCode = "200", description = "회원가입 후 펫 생성, 성공 시 등록 펫 id 값 반환") @Parameter(description = "ex) Bearer eyzaqwd...", name = "Authorization", in = ParameterIn.HEADER) public ResponseEntity> createPet( - @RequestPart("petCreateRequestDto") PetCreateRequestDto petCreateRequestDto, - @RequestPart("uploadPhoto") MultipartFile file, + @RequestPart(value = "petCreateRequestDto") PetCreateRequestDto petCreateRequestDto, + @RequestPart(value = "uploadPhoto") MultipartFile file, @AuthenticationPrincipal PrincipalDetails principalDetails) { Long savedId = petService.addPetToMember(petCreateRequestDto, file, principalDetails); diff --git a/src/main/java/com/gdsc/petwalk/domain/pet/service/PetService.java b/src/main/java/com/gdsc/petwalk/domain/pet/service/PetService.java index 403a8ec..2e923d2 100644 --- a/src/main/java/com/gdsc/petwalk/domain/pet/service/PetService.java +++ b/src/main/java/com/gdsc/petwalk/domain/pet/service/PetService.java @@ -38,9 +38,9 @@ public Long addPetToMember(PetCreateRequestDto request, MultipartFile file, Prin .likesCount(0) .build(); - photoService.savePhotoToPet(file, pet); - member.getPets().add(pet); + + photoService.savePhotoToPet(file, pet); Pet savePet = petRepository.save(pet); return savePet.getId(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8b23305..2154ae5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -66,9 +66,10 @@ cloud: bucket: petwalk-bucket springdoc: + packages-to-scan: com.gdsc.petwalk override-with-generic-response: true - default-consumes-media-type: application/json # 소비 미디어 타입 - default-produces-media-type: application/json # 생산 미디어 타입 + default-consumes-media-type: application/json;charset=UTF-8 # 소비 미디어 타입 + default-produces-media-type: application/json;charset=UTF-8 # 생산 미디어 타입 swagger-ui: operations-sorter: method # operations 정렬 방식은 HTTP Method 순 tags-sorter: alpha # tag 정렬 방식은 알파벳 순 \ No newline at end of file