Skip to content

Commit

Permalink
Merge pull request #254 from TEAM-MODDY/develop
Browse files Browse the repository at this point in the history
1.0.1
  • Loading branch information
KWY0218 authored Feb 24, 2024
2 parents 277c19e + c64c871 commit ad54370
Show file tree
Hide file tree
Showing 44 changed files with 726 additions and 649 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public enum SuccessCode {
REFRESH_SUCCESS(HttpStatus.OK, "토큰 갱신 성공입니다."),
CREATE_MODEL_APPLICATION_SUCCESS(HttpStatus.OK, "모델 지원서 생성 성공입니다."),
USER_WITHDRAW_SUCCESS(HttpStatus.OK, "회원 탈퇴 성공입니다."),
GET_PRE_SIGNED_URL_SUCCESS(HttpStatus.OK, "제안서 다운로드 url 생성 성공");
GET_PRE_SIGNED_URL_SUCCESS(HttpStatus.OK, "제안서 다운로드 url 생성 성공"),
GET_APPLICATION_IMG_URL_SUCCESS(HttpStatus.OK, "지원서 이미지 url 가져오기 성공");

private final HttpStatus httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moddy.server.config.resolver.kakao;

import com.moddy.server.common.exception.model.BadRequestException;
import com.moddy.server.common.exception.model.UnAuthorizedException;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -28,7 +29,7 @@ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer m
final HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest();
final String token = request.getHeader(AUTHORIZATION);
if (token == null || token.isBlank() || !token.startsWith("Bearer ")) {
throw new UnAuthorizedException(EMPTY_KAKAO_CODE_EXCEPTION);
throw new BadRequestException(EMPTY_KAKAO_CODE_EXCEPTION);
}
return token.substring("Bearer ".length());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,27 @@
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequiredArgsConstructor
public class ApplicationController {
@Tag(name = "Application Controller")
@RequestMapping("/application")
public class ApplicationRegisterController {

private final HairModelApplicationRegisterService hairModelApplicationRegisterService;

@Tag(name = "ModelController")
@Operation(summary = "[JWT] 모델 지원서 작성", description = "모델 지원서 작성 API입니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모델 지원서 작성 성공"),
@ApiResponse(responseCode = "400", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
})
@SecurityRequirement(name = "JWT Auth")
@PostMapping(value = "/model/application", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE})
@PostMapping(consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE})
public SuccessNonDataResponse submitModelApplication(
@Parameter(hidden = true) @UserId Long modelId,
@RequestPart(value = "modelImgUrl", required = false) MultipartFile modelImgUrl,
Expand All @@ -46,4 +48,3 @@ public SuccessNonDataResponse submitModelApplication(
return SuccessNonDataResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS);
}
}

Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package com.moddy.server.controller.designer;
package com.moddy.server.controller.application;

import com.moddy.server.common.dto.ErrorResponse;
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.config.resolver.user.UserId;
import com.moddy.server.controller.designer.dto.request.OfferCreateRequest;
import com.moddy.server.controller.designer.dto.request.OfferImageUrlRequestDto;
import com.moddy.server.controller.designer.dto.response.ApplicationDetailInfoResponse;
import com.moddy.server.controller.designer.dto.response.ApplicationInfoResponse;
import com.moddy.server.controller.designer.dto.response.DesignerMainResponse;
import com.moddy.server.controller.designer.dto.response.DownloadUrlResponseDto;
import com.moddy.server.controller.designer.dto.response.ModelInfoResponse;
import com.moddy.server.controller.model.dto.ApplicationDto;
import com.moddy.server.controller.model.dto.ApplicationModelInfoDto;
import com.moddy.server.controller.model.dto.response.ApplicationImgUrlResponse;
import com.moddy.server.service.application.HairModelApplicationRetrieveService;
import com.moddy.server.service.designer.DesignerService;
import com.moddy.server.service.model.ModelRetrieveService;
import com.moddy.server.service.offer.HairServiceOfferRetrieveService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -20,28 +23,39 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

import static com.moddy.server.common.exception.enums.SuccessCode.GET_PRE_SIGNED_URL_SUCCESS;

@Tag(name = "Application Controller", description = "지원서 관련 API 입니다.")
@RestController
@RequestMapping("/designer")
@Tag(name = "DesignerController")
@RequiredArgsConstructor
public class DesignerController {

private final DesignerService designerService;
@RequestMapping("/application")
public class ApplicationRetrieveController {
private final HairModelApplicationRetrieveService hairModelApplicationRetrieveService;
private final ModelRetrieveService modelRetrieveService;
private final HairServiceOfferRetrieveService hairServiceOfferRetrieveService;

@Operation(summary = "[JWT] 제안서 다운로드 링크", description = "디자이너 제안서 다운로드 링크 불러오는 API")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "지원서 다운로드 URL 조회 성공"),
@ApiResponse(responseCode = "401", description = "토큰이 만료되었습니다. 다시 로그인 해주세요."),
@ApiResponse(responseCode = "404", description = "해당 지원서는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
})
@GetMapping("/{applicationId}/download-url")
@SecurityRequirement(name = "JWT Auth")
public SuccessResponse<DownloadUrlResponseDto> getOfferImageDownloadUrl(
@Parameter(hidden = true) @UserId final Long modelId,
@PathVariable final Long applicationId
) {
return SuccessResponse.success(GET_PRE_SIGNED_URL_SUCCESS, hairModelApplicationRetrieveService.getApplicationCaptureDownloadUrl(applicationId));
}

@Operation(summary = "[JWT] 디자이너 메인 뷰 조회", description = "디자이너 메인 뷰 조회 API입니다.")
@ApiResponses({
Expand All @@ -58,23 +72,6 @@ public SuccessResponse<DesignerMainResponse> getDesignerMainInfo(
return SuccessResponse.success(SuccessCode.FIND_DESIGNER_MAIN_INFO_SUCCESS, hairModelApplicationRetrieveService.getDesignerMainInfo(designerId, page, size));
}

@Operation(summary = "[JWT] 제안서 작성하기", description = "제안서 작성하기 API입니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "제안서 작성 성공", content = @Content(schema = @Schema(implementation = SuccessNonDataResponse.class))),
@ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "제안서가 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
})
@SecurityRequirement(name = "JWT Auth")
@PostMapping("{applicationId}/offer")
public SuccessNonDataResponse offerCreateRequest(
@Parameter(hidden = true) @UserId Long userId,
@PathVariable(value = "applicationId") Long applicationId,
@Valid @RequestBody OfferCreateRequest offerCreateRequest) throws IOException {
designerService.postOffer(userId, applicationId, offerCreateRequest);
return SuccessNonDataResponse.success(SuccessCode.POST_OFFER_SUCCESS);
}

@Operation(summary = "[JWT] 모델 지원서 상세 조회", description = "모델 지원서 상세 조회 API입니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모델 지원서 상세 조회 성공", content = @Content(schema = @Schema(implementation = ApplicationDetailInfoResponse.class))),
Expand All @@ -85,24 +82,46 @@ public SuccessNonDataResponse offerCreateRequest(
@GetMapping("/{applicationId}")
@SecurityRequirement(name = "JWT Auth")
public SuccessResponse<ApplicationDetailInfoResponse> getApplicationDetailInfo(
@Parameter(hidden = true) @UserId Long userId,
@Parameter(hidden = true) @UserId Long designerId,
@PathVariable(value = "applicationId") Long applicationId) {
return SuccessResponse.success(SuccessCode.MODEL_APPLICATION_DETAil_INFO_SUCCESS, designerService.getApplicationDetail(userId, applicationId));
ApplicationDto applicationDto = hairModelApplicationRetrieveService.getApplicationDetailInfo(applicationId);
ApplicationModelInfoDto modelInfoDto = modelRetrieveService.getApplicationModelInfo(applicationDto.modelId());
ApplicationInfoResponse applicationInfoResponse = new ApplicationInfoResponse(
applicationId,
applicationDto.modelImgUrl(),
applicationDto.hairLength(),
applicationDto.preferHairStyleList(),
applicationDto.recordResponseList(),
applicationDto.hairDetail(),
hairServiceOfferRetrieveService.getIsSendStatus(applicationId, designerId),
applicationDto.instgramId()
);

ModelInfoResponse modelInfoResponse = new ModelInfoResponse(
modelInfoDto.modelId(),
modelInfoDto.name(),
modelInfoDto.age(),
modelInfoDto.gender(),
modelInfoDto.regionList()

);

ApplicationDetailInfoResponse applicationDetailInfoResponse = new ApplicationDetailInfoResponse(applicationInfoResponse, modelInfoResponse);
return SuccessResponse.success(SuccessCode.MODEL_APPLICATION_DETAil_INFO_SUCCESS, applicationDetailInfoResponse);
}

@Operation(summary = "[JWT] 제안서 다운로드 링크", description = "디자이너 제안서 다운로드 링크 불러오는 API")
@Operation(summary = "[JWT] 지원서 이미지 가져오기", description = "오픈채팅 뷰에서 지원서 이미지 가져오기 API입니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "모델 지원서 상세 조회 성공", content = @Content(schema = @Schema(implementation = ApplicationDetailInfoResponse.class))),
@ApiResponse(responseCode = "404", description = "해당 디자이너는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "200", description = "모델 지원서 이미지 가져오기 성공", content = @Content(schema = @Schema(implementation = ApplicationDetailInfoResponse.class))),
@ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "지원서 아이디가 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
})
@PostMapping("/offer/download-url")
@GetMapping("/{applicationId}/img-url")
@SecurityRequirement(name = "JWT Auth")
public SuccessResponse<DownloadUrlResponseDto> getOfferImageDownloadUrl(
@Parameter(hidden = true) @UserId Long userId,
@RequestBody OfferImageUrlRequestDto offerImageUrlRequestDto
) {
return SuccessResponse.success(GET_PRE_SIGNED_URL_SUCCESS, designerService.getOfferImageDownloadUrl(userId, offerImageUrlRequestDto.offerImageUrl()));
public SuccessResponse<ApplicationImgUrlResponse> getApplicationImgUrlOpenChat(
@Parameter(hidden = true) @UserId Long modelId,
@PathVariable(value = "applicationId") Long applicationId) {
return SuccessResponse.success(SuccessCode.GET_APPLICATION_IMG_URL_SUCCESS, hairModelApplicationRetrieveService.getApplicationImgUrl(applicationId));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.moddy.server.controller.application.dto.response;

import java.util.List;

public record ApplicationInfoDetailResponse(
Long applicationId,
List<String> preferStyle,
String modelApplicationDetail
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
import com.moddy.server.common.dto.SuccessNonDataResponse;
import com.moddy.server.common.dto.SuccessResponse;
import com.moddy.server.common.dto.TokenPair;
import com.moddy.server.common.exception.enums.SuccessCode;
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.TokenRequestDto;
import com.moddy.server.controller.auth.dto.request.VerifyCodeRequestDto;
import com.moddy.server.controller.auth.dto.response.LoginResponseDto;
import com.moddy.server.controller.designer.dto.request.DesignerCreateRequest;
import com.moddy.server.controller.designer.dto.response.UserCreateResponse;
import com.moddy.server.service.auth.AuthService;
import com.moddy.server.service.designer.DesignerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -27,13 +23,10 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

Expand All @@ -47,11 +40,10 @@
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AuthController {
public class AuthRegisterController {

private static final String ORIGIN = "origin";
private final AuthService authService;
private final DesignerService designerService;


@Operation(summary = "[KAKAO CODE] 로그인 API")
Expand All @@ -69,20 +61,6 @@ public SuccessResponse<LoginResponseDto> login(
return SuccessResponse.success(SOCIAL_LOGIN_SUCCESS, authService.login(request.getHeader(ORIGIN), kakaoCode));
}

@Operation(summary = "[JWT] 디자이너 회원가입 API", description = "디자이너 회원가입 조회 API입니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "디자이너 회원가입 성공", content = @Content(schema = @Schema(implementation = UserCreateResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
})
@SecurityRequirement(name = "JWT Auth")
@PostMapping(value = "/signup/designer", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE})
SuccessResponse<UserCreateResponse> createDesigner(
@Parameter(hidden = true) @UserId Long userId,
@RequestPart(value = "profileImg", required = false) MultipartFile profileImg,
@Valid @RequestPart("designerInfo") DesignerCreateRequest designerInfo) {
return SuccessResponse.success(SuccessCode.DESIGNER_CREATE_SUCCESS, designerService.createDesigner(userId, designerInfo, profileImg));
}

@Operation(summary = "인증번호 요청 API", description = "인증번호 요청 API입니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "전화번호 인증 요청 성공입니다."),
Expand Down
Loading

0 comments on commit ad54370

Please sign in to comment.