From f77cf67253d5aa7344811689ea61584a514e0cac Mon Sep 17 00:00:00 2001 From: LHS-11 Date: Tue, 26 Dec 2023 22:18:57 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EC=A0=95=EC=B1=85=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20API=20=EC=97=90=20=EC=88=98?= =?UTF-8?q?=ED=98=9C=20=EC=A0=95=EC=B1=85=20=EC=97=AC=EB=B6=80=EC=99=80=20?= =?UTF-8?q?=EA=B4=80=EC=8B=AC=20=EC=A0=95=EC=B1=85=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../policy/application/PolicyService.java | 10 ++++-- .../policy/dto/PolicyInfoResponseDto.java | 35 ++++++++++++------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/cmc/zenefitserver/domain/policy/application/PolicyService.java b/src/main/java/com/cmc/zenefitserver/domain/policy/application/PolicyService.java index f83a107..813e1b3 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/policy/application/PolicyService.java +++ b/src/main/java/com/cmc/zenefitserver/domain/policy/application/PolicyService.java @@ -11,6 +11,7 @@ import com.cmc.zenefitserver.domain.user.domain.User; import com.cmc.zenefitserver.domain.user.dto.HomeInfoResponseDto; import com.cmc.zenefitserver.domain.userpolicy.dao.UserPolicyRepository; +import com.cmc.zenefitserver.domain.userpolicy.domain.UserPolicy; import com.cmc.zenefitserver.global.error.ErrorCode; import com.cmc.zenefitserver.global.error.exception.BusinessException; import lombok.RequiredArgsConstructor; @@ -66,15 +67,18 @@ public PolicyInfoResponseDto getPolicy(User user, Long policyId) { Policy policy = policyRepository.findById(policyId) .orElseThrow(() -> new BusinessException(ErrorCode.NOT_FOUND_POLICY)); + UserPolicy userPolicy = userPolicyRepository.findByUser_userIdAndPolicy_Id(user.getUserId(), policyId) + .orElseGet(null); + // 신청 불가 사유 로직 - String denialReason = "null"; PolicyMethodType findPolicyMethodType = PolicyMethodType.findPolicyMethodTypeByKeywords(policy.getApplicationProcedureContent()); + DenialReasonType denialReasonType = PolicyDenialReasonClassifier.getDenialReasonType(user, policy); PolicyInfoResponseDto dto = PolicyInfoResponseDto.builder() .policyId(policy.getId()) .policyName(policy.getPolicyName()) .policyIntroduction(policy.getPolicyIntroduction()) - .policyApplyDenialReason(PolicyDenialReasonClassifier.getDenialReasonType(user, policy).getText()) + .policyApplyDenialReason(denialReasonType != null ? denialReasonType.getText() : null) .policyApplyDocument(policy.getSubmissionDocumentContent()) .policyApplyMethod(policy.getApplicationProcedureContent()) .policyApplyDate(policy.getApplicationPeriodContent()) @@ -83,6 +87,8 @@ public PolicyInfoResponseDto getPolicy(User user, Long policyId) { .applicationSite(policy.getApplicationSiteAddress()) .referenceSite(policy.getReferenceSiteUrlAddress()) .benefit(policy.getBenefit()) + .applyFlag(userPolicy.isApplyFlag()) + .interestFlag(userPolicy.isInterestFlag()) .policyMethodType(findPolicyMethodType) .policyMethodTypeDescription(findPolicyMethodType.getDescription()) .build(); diff --git a/src/main/java/com/cmc/zenefitserver/domain/policy/dto/PolicyInfoResponseDto.java b/src/main/java/com/cmc/zenefitserver/domain/policy/dto/PolicyInfoResponseDto.java index bf4dbc9..a275b2b 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/policy/dto/PolicyInfoResponseDto.java +++ b/src/main/java/com/cmc/zenefitserver/domain/policy/dto/PolicyInfoResponseDto.java @@ -15,42 +15,49 @@ @ApiModel(description = "정책 상세 정보 조회 API response") public class PolicyInfoResponseDto { - @ApiModelProperty(notes = "정책 ID",example = "12") + @ApiModelProperty(notes = "정책 ID", example = "12") private Long policyId; - @ApiModelProperty(notes = "정책 이름",example = "청년도약계좌") + @ApiModelProperty(notes = "정책 이름", example = "청년도약계좌") private String policyName; - @ApiModelProperty(notes = "정책 불가 사유",example = "신청 기간이 아니에요, ~조건이 맞지 않습니다.") + @ApiModelProperty(notes = "정책 불가 사유", example = "신청 기간이 아니에요, ~조건이 맞지 않습니다.") private String policyApplyDenialReason; - @ApiModelProperty(notes = "정책 소개",example = "월 70만원을 5년 납입하면 약 5,000만원을 적립할 수 있는 청년도약계좌") + @ApiModelProperty(notes = "정책 소개", example = "월 70만원을 5년 납입하면 약 5,000만원을 적립할 수 있는 청년도약계좌") private String policyIntroduction; - @ApiModelProperty(notes = "신청 서류",example = "주민등록등본, 신분증, 소득증빙서류 등") + @ApiModelProperty(notes = "신청 서류", example = "주민등록등본, 신분증, 소득증빙서류 등") private String policyApplyDocument; - @ApiModelProperty(notes = "신청 방법",example = "주소지 읍·면·동 행정복지센터 방문 또는 등기우편 신청") + @ApiModelProperty(notes = "신청 방법", example = "주소지 읍·면·동 행정복지센터 방문 또는 등기우편 신청") private String policyApplyMethod; - @ApiModelProperty(notes = "신청 기간",example = "2023년 6월 15일 ~ 2023년 12월 31일") + @ApiModelProperty(notes = "신청 기간", example = "2023년 6월 15일 ~ 2023년 12월 31일") private String policyApplyDate; - @ApiModelProperty(notes = "신청 기간 타입",example = "PERIOD, CONSTANT, UNDECIDED, BLANK") + @ApiModelProperty(notes = "신청 기간 타입", example = "PERIOD, CONSTANT, UNDECIDED, BLANK") private PolicyDateType policyDateType; - @ApiModelProperty(notes = "신청 기간 타입 이름",example = "상시, 기간 신청, 미정, 빈값") + @ApiModelProperty(notes = "신청 기간 타입 이름", example = "상시, 기간 신청, 미정, 빈값") private String policyDateTypeDescription; - @ApiModelProperty(notes = "신청 url",example = "https://www.kinfa.or.kr/product/youthJump.do") + @ApiModelProperty(notes = "신청 url", example = "https://www.kinfa.or.kr/product/youthJump.do") private String applicationSite; - @ApiModelProperty(notes = "참고 url",example = "https://www.kinfa.or.kr/product/youthJump.do") + @ApiModelProperty(notes = "참고 url", example = "https://www.kinfa.or.kr/product/youthJump.do") private String referenceSite; - @ApiModelProperty(notes = "정책 수혜금액",example = "존재하면 숫자값, 없으면 null값") + @ApiModelProperty(notes = "정책 수혜금액", example = "존재하면 숫자값, 없으면 null값") private int benefit; + @ApiModelProperty(notes = "수혜(신청) 정책 여부") + private boolean applyFlag; + + @ApiModelProperty(notes = "관심 정책 여부") + private boolean interestFlag; + + @ApiModelProperty(notes = "정책 신청 방법", example = "LETTER, ONLINE, VISIT 등") private PolicyMethodType policyMethodType; @@ -58,7 +65,7 @@ public class PolicyInfoResponseDto { private String policyMethodTypeDescription; @Builder - public PolicyInfoResponseDto(Long policyId, String policyName, String policyApplyDenialReason, String policyIntroduction, String policyApplyDocument, String policyApplyMethod, String policyApplyDate, PolicyDateType policyDateType, String policyDateTypeDescription, String applicationSite, String referenceSite, int benefit, PolicyMethodType policyMethodType, String policyMethodTypeDescription) { + public PolicyInfoResponseDto(Long policyId, String policyName, String policyApplyDenialReason, String policyIntroduction, String policyApplyDocument, String policyApplyMethod, String policyApplyDate, PolicyDateType policyDateType, String policyDateTypeDescription, String applicationSite, String referenceSite, int benefit, boolean applyFlag, boolean interestFlag, PolicyMethodType policyMethodType, String policyMethodTypeDescription) { this.policyId = policyId; this.policyName = policyName; this.policyApplyDenialReason = policyApplyDenialReason; @@ -71,6 +78,8 @@ public PolicyInfoResponseDto(Long policyId, String policyName, String policyAppl this.applicationSite = applicationSite; this.referenceSite = referenceSite; this.benefit = benefit; + this.applyFlag = applyFlag; + this.interestFlag = interestFlag; this.policyMethodType = policyMethodType; this.policyMethodTypeDescription = policyMethodTypeDescription; }