Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore : 회원가입 후 펫 등록까지 flow #18

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,8 +52,8 @@ public ResponseEntity<AuthResultDto<Boolean>> 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 형식으로 보내주면 됨. <br> try it out을 누르면 dto 정보를 확인 할 수 있습니다. swagger에서 직접 테스트는 안되니 참고하세요!")
@ApiResponse(responseCode = "200", description = "token 반환")
public ResponseEntity<AuthResultDto<TokenResponseDto>> signUp(
@RequestPart("signUpRequestDto") @Valid SignUpRequestDto request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 형식으로 보내주면 됨. <br> try it out을 누르면 dto 정보를 확인 할 수 있습니다. swagger에서 직접 테스트는 안되니 참고하세요!")
@ApiResponse(responseCode = "200", description = "회원가입 후 펫 생성, 성공 시 등록 펫 id 값 반환")
@Parameter(description = "ex) Bearer eyzaqwd...", name = "Authorization", in = ParameterIn.HEADER)
public ResponseEntity<PetResultDto<Long>> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 정렬 방식은 알파벳 순
Loading