diff --git a/src/main/java/com/moddy/server/controller/auth/AuthController.java b/src/main/java/com/moddy/server/controller/auth/AuthController.java index 4c9d8a90..111cfb75 100644 --- a/src/main/java/com/moddy/server/controller/auth/AuthController.java +++ b/src/main/java/com/moddy/server/controller/auth/AuthController.java @@ -5,13 +5,11 @@ import com.moddy.server.common.dto.SuccessNonDataResponse; import com.moddy.server.common.dto.SuccessResponse; import com.moddy.server.common.exception.enums.SuccessCode; -import com.moddy.server.common.util.SmsUtil; import com.moddy.server.config.resolver.kakao.KakaoCode; import com.moddy.server.config.resolver.user.UserId; import com.moddy.server.controller.auth.dto.request.PhoneNumberRequestDto; import com.moddy.server.controller.auth.dto.request.VerifyCodeRequestDto; import com.moddy.server.controller.auth.dto.response.LoginResponseDto; -import com.moddy.server.controller.auth.dto.response.RegionResponse; import com.moddy.server.controller.designer.dto.request.DesignerCreateRequest; import com.moddy.server.controller.designer.dto.response.UserCreateResponse; import com.moddy.server.controller.model.dto.request.ModelCreateRequest; @@ -30,7 +28,6 @@ import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -39,7 +36,6 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -import java.util.List; import static com.moddy.server.common.exception.enums.SuccessCode.LOGOUT_SUCCESS; import static com.moddy.server.common.exception.enums.SuccessCode.SEND_VERIFICATION_CODE_SUCCESS; @@ -56,7 +52,6 @@ public class AuthController { private final AuthService authService; private final DesignerService designerService; private final ModelService modelService; - private final SmsUtil smsUtil; @Operation(summary = "[KAKAO CODE] 로그인 API") @ApiResponses(value = { @@ -73,16 +68,6 @@ public SuccessResponse login( return SuccessResponse.success(SOCIAL_LOGIN_SUCCESS, authService.login(request.getHeader(ORIGIN), kakaoCode)); } - @Operation(summary = "모델 회원가입 시 희망 지역 리스트 조회 API") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "희망 지역 리스트 조회 성공입니다."), - @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) - }) - @GetMapping("/regions") - public SuccessResponse> getRegionList() { - return SuccessResponse.success(SuccessCode.FIND_REGION_LIST_SUCCESS, authService.getRegionList()); - } - @Operation(summary = "[JWT] 디자이너 회원가입 API", description = "디자이너 회원가입 조회 API입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "디자이너 회원가입 성공", content = @Content(schema = @Schema(implementation = UserCreateResponse.class))), diff --git a/src/main/java/com/moddy/server/controller/model/ModelController.java b/src/main/java/com/moddy/server/controller/model/ModelController.java index 1ad7e5b7..a9b5ed92 100644 --- a/src/main/java/com/moddy/server/controller/model/ModelController.java +++ b/src/main/java/com/moddy/server/controller/model/ModelController.java @@ -5,11 +5,13 @@ import com.moddy.server.common.dto.SuccessResponse; import com.moddy.server.common.exception.enums.SuccessCode; import com.moddy.server.config.resolver.user.UserId; +import com.moddy.server.controller.auth.dto.response.RegionResponse; import com.moddy.server.controller.model.dto.request.ModelApplicationRequest; import com.moddy.server.controller.model.dto.response.ApplicationUserDetailResponse; import com.moddy.server.controller.model.dto.response.DetailOfferResponse; import com.moddy.server.controller.model.dto.response.ModelMainResponse; import com.moddy.server.controller.model.dto.response.OpenChatResponse; +import com.moddy.server.service.model.ModelRetrieveService; import com.moddy.server.service.model.ModelService; import com.moddy.server.service.offer.HairServiceOfferRetrieveService; import io.swagger.v3.oas.annotations.Operation; @@ -33,22 +35,35 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import java.util.List; + @RestController -@Tag(name = "ModelController") -@RequestMapping("/model") @RequiredArgsConstructor public class ModelController { private final ModelService modelService; private final HairServiceOfferRetrieveService hairServiceOfferRetrieveService; + private final ModelRetrieveService modelRetrieveService; + + @Tag(name = "Auth Controller") + @Operation(summary = "모델 회원가입 시 희망 지역 리스트 조회 API") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "희망 지역 리스트 조회 성공입니다."), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/auth/regions") + public SuccessResponse> getRegionList() { + return SuccessResponse.success(SuccessCode.FIND_REGION_LIST_SUCCESS, modelRetrieveService.getRegionList()); + } + @Tag(name = "ModelController") @Operation(summary = "[JWT] 모델 메인 뷰 조회", description = "모델 메인 뷰 조회 API입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "모델 메인뷰 조회 성공", content = @Content(schema = @Schema(implementation = ModelMainResponse.class))), @ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) - @GetMapping + @GetMapping("/model") @SecurityRequirement(name = "JWT Auth") public SuccessResponse getModelMainInfo( @Parameter(hidden = true) @UserId Long userId, @@ -57,6 +72,7 @@ public SuccessResponse getModelMainInfo( return SuccessResponse.success(SuccessCode.FIND_MODEL_MAIN_INFO_SUCCESS, modelService.getModelMainInfo(userId, page, size)); } + @Tag(name = "ModelController") @Operation(summary = "[JWT] 제안서 상세보기 뷰 조회", description = "제안서 상세보기 API입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "제안서 상세보기 조회 성공", content = @Content(schema = @Schema(implementation = DetailOfferResponse.class))), @@ -64,7 +80,7 @@ public SuccessResponse getModelMainInfo( @ApiResponse(responseCode = "404", description = "제안서 아이디가 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) - @GetMapping("/offer/{offerId}") + @GetMapping("/model/offer/{offerId}") @SecurityRequirement(name = "JWT Auth") public SuccessResponse getModelDetailOfferInfo( @Parameter(hidden = true) @UserId Long userId, @@ -72,13 +88,14 @@ public SuccessResponse getModelDetailOfferInfo( return SuccessResponse.success(SuccessCode.FIND_MODEL_DETAIL_OFFER_SUCCESS, modelService.getOfferDetail(userId, offerId)); } + @Tag(name = "ModelController") @Operation(summary = "[JWT] 카카오톡 오픈채팅", description = "지원서 캡처 이미지 및 디자이너 정보 조회입니다") @ApiResponses({ @ApiResponse(responseCode = "200", description = "모델 메인뷰 조회 성공", content = @Content(schema = @Schema(implementation = OpenChatResponse.class))), @ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) - @GetMapping("/{offerId}/agree") + @GetMapping("/model/{offerId}/agree") @SecurityRequirement(name = "JWT Auth") public SuccessResponse getOpenChat( @Parameter(hidden = true) @UserId Long userId, @@ -86,6 +103,7 @@ public SuccessResponse getOpenChat( return SuccessResponse.success(SuccessCode.OPEN_CHAT_GET_SUCCESS, hairServiceOfferRetrieveService.getOpenChatInfo(userId, offerId)); } + @Tag(name = "ModelController") @Operation(summary = "[JWT] 디자이너 제안서 승낙하기", description = "디자이너 제안서 승낙하기 API입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "디자이너 제안서 승낙하기"), @@ -93,7 +111,7 @@ public SuccessResponse getOpenChat( @ApiResponse(responseCode = "404", description = "제안서 아이디가 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) - @PutMapping("/offer/{offerId}") + @PutMapping("/model/offer/{offerId}") @SecurityRequirement(name = "JWT Auth") public SuccessNonDataResponse acceptOffer( @Parameter(hidden = true) @UserId Long userId, @@ -102,6 +120,7 @@ public SuccessNonDataResponse acceptOffer( return SuccessNonDataResponse.success(SuccessCode.OFFER_ACCEPT_SUCCESS); } + @Tag(name = "ModelController") @Operation(summary = "[JWT] 모델 지원서 작성", description = "모델 지원서 작성 API입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "모델 지원서 작성 성공"), @@ -109,7 +128,7 @@ public SuccessNonDataResponse acceptOffer( @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) @SecurityRequirement(name = "JWT Auth") - @PostMapping(value = "/application", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) + @PostMapping(value = "/model/application", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) public SuccessNonDataResponse submitModelApplication( @Parameter(hidden = true) @UserId Long userId, @RequestPart(value = "modelImgUrl", required = false) MultipartFile modelImgUrl, @@ -119,6 +138,7 @@ public SuccessNonDataResponse submitModelApplication( return SuccessNonDataResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS); } + @Tag(name = "ModelController") @Operation(summary = "[JWT] 모델 지원서 최종 확인 시 유저 정보 조회 API", description = "[모델 뷰] 모델 지원서 최종 확인 시 유저 정보 조회 API 입니다.") @ApiResponses({ @ApiResponse(responseCode = "200", description = "모델 지원서 작성 성공"), @@ -127,7 +147,7 @@ public SuccessNonDataResponse submitModelApplication( @ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), }) @SecurityRequirement(name = "JWT Auth") - @GetMapping(value = "/application/user") + @GetMapping(value = "/model/application/user") public SuccessResponse getUserDetailInApplication(@Parameter(hidden = true) @UserId Long userId) { return SuccessResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS, modelService.getUserDetailInApplication(userId)); } diff --git a/src/main/java/com/moddy/server/service/auth/AuthService.java b/src/main/java/com/moddy/server/service/auth/AuthService.java index 3b2b4fd0..cecfa552 100644 --- a/src/main/java/com/moddy/server/service/auth/AuthService.java +++ b/src/main/java/com/moddy/server/service/auth/AuthService.java @@ -8,9 +8,7 @@ import com.moddy.server.common.util.VerificationCodeGenerator; import com.moddy.server.config.jwt.JwtService; import com.moddy.server.controller.auth.dto.response.LoginResponseDto; -import com.moddy.server.controller.auth.dto.response.RegionResponse; import com.moddy.server.controller.designer.dto.response.UserCreateResponse; -import com.moddy.server.domain.region.repository.RegionJpaRepository; import com.moddy.server.domain.user.User; import com.moddy.server.domain.user.repository.UserRepository; import com.moddy.server.external.kakao.service.KakaoSocialService; @@ -19,9 +17,7 @@ import org.springframework.stereotype.Service; import java.io.IOException; -import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static com.moddy.server.common.exception.enums.ErrorCode.INVALID_PHONE_NUMBER_EXCEPTION; import static com.moddy.server.common.exception.enums.ErrorCode.NOT_FOUND_VERIFICATION_CODE_EXCEPTION; @@ -36,7 +32,6 @@ public class AuthService { private final JwtService jwtService; private final KakaoSocialService kakaoSocialService; private final UserRepository userRepository; - private final RegionJpaRepository regionJpaRepository; public LoginResponseDto login(final String baseUrl, final String kakaoCode) { String kakaoId = kakaoSocialService.getIdFromKakao(baseUrl, kakaoCode); @@ -57,19 +52,6 @@ public LoginResponseDto login(final String baseUrl, final String kakaoCode) { return new LoginResponseDto(tokenPair.accessToken(), tokenPair.refreshToken(), user.get().getRole().name()); } - public List getRegionList() { - - List regionResponseList = regionJpaRepository.findAll().stream().map(region -> { - RegionResponse regionResponse = new RegionResponse( - region.getId(), - region.getName() - ); - return regionResponse; - }).collect(Collectors.toList()); - - return regionResponseList; - } - public UserCreateResponse createUserToken(String useId) { TokenPair tokenPair = jwtService.generateTokenPair(useId); diff --git a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java index 69505d1b..71e03b6b 100644 --- a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java +++ b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java @@ -2,21 +2,36 @@ import com.moddy.server.common.exception.enums.ErrorCode; import com.moddy.server.common.exception.model.NotFoundException; +import com.moddy.server.controller.auth.dto.response.RegionResponse; import com.moddy.server.controller.model.dto.ApplicationModelInfoDto; import com.moddy.server.domain.model.Model; import com.moddy.server.domain.model.repository.ModelJpaRepository; +import com.moddy.server.domain.region.repository.RegionJpaRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; +import java.util.stream.Collectors; + @Service @RequiredArgsConstructor @Transactional(readOnly = true) public class ModelRetrieveService { private final ModelJpaRepository modelJpaRepository; + private final RegionJpaRepository regionJpaRepository; - public ApplicationModelInfoDto getApplicationModelInfo(final Long modelId){ + public ApplicationModelInfoDto getApplicationModelInfo(final Long modelId) { Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); - return new ApplicationModelInfoDto(model.getName(),model.getAge(), model.getGender().getValue()); + return new ApplicationModelInfoDto(model.getName(), model.getAge(), model.getGender().getValue()); + } + + public List getRegionList() { + List regionResponseList = regionJpaRepository.findAll().stream().map(region -> { + RegionResponse regionResponse = new RegionResponse(region.getId(), region.getName()); + return regionResponse; + }).collect(Collectors.toList()); + + return regionResponseList; } }