Skip to content

Commit

Permalink
feat : 정책 상세 조회 API 에 수혜 정책 여부와 관심 정책 여부 컬럼 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
LHS-11 committed Dec 26, 2023
1 parent ba2148f commit f77cf67
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,57 @@
@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;

@ApiModelProperty(notes = "정책 신청 방법 설명", example = "우편신청, 방문신청, 온라인신청 등")
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;
Expand All @@ -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;
}
Expand Down

0 comments on commit f77cf67

Please sign in to comment.