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

#268 [feat] 지원서 유무 확인 API에 ApplicationId 추가 #269

Merged
merged 4 commits into from
Mar 5, 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
4 changes: 0 additions & 4 deletions src/main/java/com/moddy/server/common/dto/TokenPair.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.moddy.server.common.dto;


import lombok.Getter;
import lombok.ToString;

public record TokenPair(
String accessToken, String refreshToken
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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.application.dto.response.ApplicationIdResponse;
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;
Expand Down Expand Up @@ -130,17 +130,16 @@ public SuccessResponse<ApplicationImgUrlResponse> getApplicationImgUrlOpenChat(

@Operation(summary = "[JWT] 나의 지원서 유무 확인하기", description = "마이페이지에서 유효한 지원서 유무를 확인하는 API입니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "유효한 지원서 존재여부 조회 성공", content = @Content(schema = @Schema(implementation = ApplicationDetailInfoResponse.class))),
@ApiResponse(responseCode = "200", description = "유효한 지원서 존재여부 조회 성공", content = @Content(schema = @Schema(implementation = ApplicationIdResponse.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))),
})
@GetMapping("/check")
@SecurityRequirement(name = "JWT Auth")
public SuccessNonDataResponse getValidApplicationStatus(
public SuccessResponse<ApplicationIdResponse> getValidApplicationStatus(
@Parameter(hidden = true) @UserId Long modelId) {
hairModelApplicationRetrieveService.checkValidApplicationStatus(modelId);
return SuccessNonDataResponse.success(SuccessCode.CHECK_VALID_APPLICATION_SUCCESS);
return SuccessResponse.success(SuccessCode.CHECK_VALID_APPLICATION_SUCCESS, hairModelApplicationRetrieveService.checkValidApplicationStatus(modelId));
}

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

public record ApplicationIdResponse(
Long applicationId
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.moddy.server.common.exception.enums.ErrorCode;
import com.moddy.server.common.exception.model.NotFoundException;
import com.moddy.server.controller.application.dto.response.ApplicationIdResponse;
import com.moddy.server.controller.application.dto.response.ApplicationInfoDetailResponse;
import com.moddy.server.controller.designer.dto.response.DesignerMainResponse;
import com.moddy.server.controller.designer.dto.response.DownloadUrlResponseDto;
Expand Down Expand Up @@ -103,10 +104,12 @@ public ApplicationDto getApplicationDetailInfo(final Long applicationId) {
hairModelApplication.getExpiredDate().format(DateTimeFormatter.ofPattern(DATE_FORMAT)));
}

public void checkValidApplicationStatus(final Long modelId){
public ApplicationIdResponse checkValidApplicationStatus(final Long modelId){
HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findFirstByModelIdOrderByCreatedAtDesc(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION));

if(hairModelApplication.isExpired()) throw new NotFoundException(ErrorCode.NOT_FOUND_VALID_APPLICATION_EXCEPTION);

return new ApplicationIdResponse(hairModelApplication.getId());
}

public boolean fetchModelApplyStatus(final Long modelId) {
Expand Down
Loading