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 2c4c7f3..3a39e77 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 @@ -4,6 +4,7 @@ import com.cmc.zenefitserver.domain.policy.dao.PolicyRepository; import com.cmc.zenefitserver.domain.policy.domain.Policy; import com.cmc.zenefitserver.domain.policy.domain.enums.DenialReasonType; +import com.cmc.zenefitserver.domain.policy.domain.enums.PolicyMethodType; import com.cmc.zenefitserver.domain.policy.domain.enums.SearchDateType; import com.cmc.zenefitserver.domain.policy.domain.enums.SupportPolicyType; import com.cmc.zenefitserver.domain.policy.dto.*; @@ -41,6 +42,7 @@ public Page getPolicyList(User user, PolicyListRequestDto dto.updatePolicyDateTypeDescription(dto.getPolicyDateType()); dto.updateAreaCode(dto.getAreaCode()); dto.updateCityCode(dto.getCityCode()); + dto.updatePolicyMethodType(dto.getPolicyMethodTypeDescription()); return dto; }); } @@ -54,6 +56,7 @@ public Page getSearchPolicyList(User user, SearchPolicyLi dto.updatePolicyDateTypeDescription(dto.getPolicyDateType()); dto.updateAreaCode(dto.getAreaCode()); dto.updateCityCode(dto.getCityCode()); + dto.updatePolicyMethodType(dto.getPolicyMethodTypeDescription()); return dto; }); } @@ -64,6 +67,7 @@ public PolicyInfoResponseDto getPolicy(User user, Long policyId) { // 신청 불가 사유 로직 String denialReason = "null"; + PolicyMethodType findPolicyMethodType = PolicyMethodType.findPolicyMethodTypeByKeywords(policy.getApplicationProcedureContent()); PolicyInfoResponseDto dto = PolicyInfoResponseDto.builder() .policyId(policy.getId()) @@ -78,6 +82,8 @@ public PolicyInfoResponseDto getPolicy(User user, Long policyId) { .applicationSite(policy.getApplicationSiteAddress()) .referenceSite(policy.getReferenceSiteUrlAddress()) .benefit(policy.getBenefit()) + .policyMethodType(findPolicyMethodType) + .policyMethodTypeDescription(findPolicyMethodType.getDescription()) .build(); return dto; @@ -153,6 +159,8 @@ public RecommendPolicyInfoResponseDto recommend(User user) { .stream() .map(supportPolicyType -> { Policy policy = supportPolicyTypePolicyMap.get(supportPolicyType); + PolicyMethodType findPolicyMethodType = PolicyMethodType.findPolicyMethodTypeByKeywords(policy.getApplicationProcedureContent()); + RecommendPolicyInfoResponseDto.recommendPolicyInfo dto = RecommendPolicyInfoResponseDto.recommendPolicyInfo.builder() .policyId(policy.getId()) .policyName(policy.getPolicyName()) @@ -163,6 +171,8 @@ public RecommendPolicyInfoResponseDto recommend(User user) { .supportTypePolicyCnt(policyRepository.getPolicyCntBySupportPolicyType(supportPolicyType)) .benefit(10000000) .policyDateType(policy.getPolicyDateType().getDescription()) + .policyMethodType(findPolicyMethodType) + .policyMethodTypeDescription(findPolicyMethodType.getDescription()) .build(); return dto; }).collect(Collectors.toList()); @@ -201,6 +211,10 @@ public RecommendPolicyInfoResponseDto getRecommendPolicyDummy() { Policy moneyPolicy = policyRepository.findAllBySupportPolicyTypesContains(SupportPolicyType.MONEY).get(0); Policy socialServicePolicy = policyRepository.findAllBySupportPolicyTypesContains(SupportPolicyType.SOCIAL_SERVICE).get(0); + PolicyMethodType loansPolicyMethodType = PolicyMethodType.findPolicyMethodTypeByKeywords(loansPolicy.getApplicationProcedureContent()); + PolicyMethodType moneyPolicyMethodType = PolicyMethodType.findPolicyMethodTypeByKeywords(moneyPolicy.getApplicationProcedureContent()); + PolicyMethodType socialServicePolicyMethodType = PolicyMethodType.findPolicyMethodTypeByKeywords(socialServicePolicy.getApplicationProcedureContent()); + List result = new ArrayList<>(); result.add( RecommendPolicyInfoResponseDto.recommendPolicyInfo.builder() @@ -215,6 +229,8 @@ public RecommendPolicyInfoResponseDto getRecommendPolicyDummy() { .supportTypePolicyCnt(policyRepository.getPolicyCntBySupportPolicyType(SupportPolicyType.LOANS)) .benefit(10000000) .policyDateType("기간 신청") + .policyMethodType(loansPolicyMethodType) + .policyMethodTypeDescription(loansPolicyMethodType.getDescription()) .build() ); result.add( @@ -230,6 +246,8 @@ public RecommendPolicyInfoResponseDto getRecommendPolicyDummy() { .supportTypePolicyCnt(policyRepository.getPolicyCntBySupportPolicyType(SupportPolicyType.MONEY)) .benefit(10000000) .policyDateType("상시") + .policyMethodType(moneyPolicyMethodType) + .policyMethodTypeDescription(moneyPolicyMethodType.getDescription()) .build() ); result.add( @@ -245,6 +263,8 @@ public RecommendPolicyInfoResponseDto getRecommendPolicyDummy() { .supportTypePolicyCnt(policyRepository.getPolicyCntBySupportPolicyType(SupportPolicyType.SOCIAL_SERVICE)) .benefit(10000000) .policyDateType("미정") + .policyMethodType(socialServicePolicyMethodType) + .policyMethodTypeDescription(socialServicePolicyMethodType.getDescription()) .build() ); return RecommendPolicyInfoResponseDto.builder().policyInfos(result).build(); diff --git a/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyQueryRepository.java b/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyQueryRepository.java index 180fd2d..836baea 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyQueryRepository.java +++ b/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyQueryRepository.java @@ -40,7 +40,8 @@ public Page searchByPaging(User user, SupportPolicyType s policy.policyDateType, policy.benefit, ExpressionUtils.as(Expressions.constant(false), "applyFlag"), - ExpressionUtils.as(Expressions.constant(false), "interestFlag") + ExpressionUtils.as(Expressions.constant(false), "interestFlag"), + policy.applicationProcedureContent.as("policyMethodTypeDescription") ) ) .from(policy) diff --git a/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyRepository.java b/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyRepository.java index 79dfb39..bc37cde 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyRepository.java +++ b/src/main/java/com/cmc/zenefitserver/domain/policy/dao/PolicyRepository.java @@ -49,7 +49,7 @@ public interface PolicyRepository extends JpaRepository { "AND :age between p.minAge and p.maxAge") List findByAreaCodeAndCityCodeAndAge(@Param("areaCode") AreaCode areaCode, @Param("central") AreaCode central, @Param("cityCode") CityCode cityCode, @Param("age") int age); - @Query("SELECT COUNT(p) FROM Policy p WHERE p.supportPolicyTypes in (:supportPolicyType)") + @Query("SELECT COUNT(p) FROM Policy p WHERE (:supportPolicyType) MEMBER OF p.supportPolicyTypes") int getPolicyCntBySupportPolicyType(@Param("supportPolicyType") SupportPolicyType supportPolicyType); @Query("SELECT P FROM Policy P LEFT JOIN P.userPolicies UP " + 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 4db0dfd..bf4dbc9 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 @@ -1,6 +1,7 @@ package com.cmc.zenefitserver.domain.policy.dto; import com.cmc.zenefitserver.domain.policy.domain.enums.PolicyDateType; +import com.cmc.zenefitserver.domain.policy.domain.enums.PolicyMethodType; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Builder; @@ -50,8 +51,14 @@ public class PolicyInfoResponseDto { @ApiModelProperty(notes = "정책 수혜금액",example = "존재하면 숫자값, 없으면 null값") private int benefit; + @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) { + 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) { this.policyId = policyId; this.policyName = policyName; this.policyApplyDenialReason = policyApplyDenialReason; @@ -64,5 +71,7 @@ public PolicyInfoResponseDto(Long policyId, String policyName, String policyAppl this.applicationSite = applicationSite; this.referenceSite = referenceSite; this.benefit = benefit; + this.policyMethodType = policyMethodType; + this.policyMethodTypeDescription = policyMethodTypeDescription; } } diff --git a/src/main/java/com/cmc/zenefitserver/domain/policy/dto/PolicyListResponseDto.java b/src/main/java/com/cmc/zenefitserver/domain/policy/dto/PolicyListResponseDto.java index 6e158bb..e7ee258 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/policy/dto/PolicyListResponseDto.java +++ b/src/main/java/com/cmc/zenefitserver/domain/policy/dto/PolicyListResponseDto.java @@ -1,9 +1,6 @@ package com.cmc.zenefitserver.domain.policy.dto; -import com.cmc.zenefitserver.domain.policy.domain.enums.AreaCode; -import com.cmc.zenefitserver.domain.policy.domain.enums.CityCode; -import com.cmc.zenefitserver.domain.policy.domain.enums.PolicyDateType; -import com.cmc.zenefitserver.domain.policy.domain.enums.PolicySplzType; +import com.cmc.zenefitserver.domain.policy.domain.enums.*; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.*; @@ -56,6 +53,12 @@ public class PolicyListResponseDto { @ApiModelProperty(notes = "관심 정책 여부") private boolean interestFlag; + @ApiModelProperty(notes = "정책 신청 방법", example = "LETTER, ONLINE, VISIT 등") + private PolicyMethodType policyMethodType; + + @ApiModelProperty(notes = "정책 신청 방법 설명", example = "우편신청, 방문신청, 온라인신청 등") + private String policyMethodTypeDescription; + public void updateAreaCode(String areaCode) { this.areaCode = AreaCode.findName(areaCode); } @@ -64,8 +67,8 @@ public void updateCityCode(String cityCode) { this.cityCode = CityCode.findName(cityCode); } - public void updatePolicyDateTypeDescription(PolicyDateType policyDateType){ - if(policyDateType != null){ + public void updatePolicyDateTypeDescription(PolicyDateType policyDateType) { + if (policyDateType != null) { this.policyDateTypeDescription = policyDateType.getDescription(); } } @@ -80,7 +83,7 @@ public void updatePolicyApplyDenialReason(String policyApplyDenialReason) { } @Builder - public PolicyListResponseDto(Long policyId, String policyName, String policyLogo, String policyIntroduction, String areaCode, String cityCode, PolicyDateType policyDateType, String policyDateTypeDescription, String policyApplyDenialReason, boolean applyStatus, int benefit, boolean applyFlag, boolean interestFlag) { + public PolicyListResponseDto(Long policyId, String policyName, String policyLogo, String policyIntroduction, String areaCode, String cityCode, PolicyDateType policyDateType, String policyDateTypeDescription, String policyApplyDenialReason, boolean applyStatus, int benefit, boolean applyFlag, boolean interestFlag, PolicyMethodType policyMethodType, String policyMethodTypeDescription) { this.policyId = policyId; this.policyName = policyName; this.policyLogo = policyLogo; @@ -94,9 +97,11 @@ public PolicyListResponseDto(Long policyId, String policyName, String policyLogo this.benefit = benefit; this.applyFlag = applyFlag; this.interestFlag = interestFlag; + this.policyMethodType = policyMethodType; + this.policyMethodTypeDescription = policyMethodTypeDescription; } - public PolicyListResponseDto(Long policyId, String policyName, String policyLogo, String policyIntroduction, String areaCode, String cityCode, PolicyDateType policyDateType, int benefit, boolean applyFlag, boolean interestFlag) { + public PolicyListResponseDto(Long policyId, String policyName, String policyLogo, String policyIntroduction, String areaCode, String cityCode, PolicyDateType policyDateType, int benefit, boolean applyFlag, boolean interestFlag, String policyMethodTypeDescription) { this.policyId = policyId; this.policyName = policyName; this.policyLogo = policyLogo; @@ -107,8 +112,28 @@ public PolicyListResponseDto(Long policyId, String policyName, String policyLogo this.benefit = benefit; this.applyFlag = applyFlag; this.interestFlag = interestFlag; + this.policyMethodTypeDescription = policyMethodTypeDescription; + } + + public void updatePolicyMethodType(String applicationProcedureContent) { + PolicyMethodType findPolicyMethodType = PolicyMethodType.findPolicyMethodTypeByKeywords(applicationProcedureContent); + this.policyMethodType = findPolicyMethodType; + this.policyMethodTypeDescription = findPolicyMethodType.getDescription(); } +// public PolicyListResponseDto(Long policyId, String policyName, String policyLogo, String policyIntroduction, String areaCode, String cityCode, PolicyDateType policyDateType, int benefit, boolean applyFlag, boolean interestFlag) { +// this.policyId = policyId; +// this.policyName = policyName; +// this.policyLogo = policyLogo; +// this.policyIntroduction = policyIntroduction; +// this.areaCode = areaCode; +// this.cityCode = cityCode; +// this.policyDateType = policyDateType; +// this.benefit = benefit; +// this.applyFlag = applyFlag; +// this.interestFlag = interestFlag; +// } + @Builder @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/com/cmc/zenefitserver/domain/policy/dto/RecommendPolicyInfoResponseDto.java b/src/main/java/com/cmc/zenefitserver/domain/policy/dto/RecommendPolicyInfoResponseDto.java index 6e8902c..5465ee3 100644 --- a/src/main/java/com/cmc/zenefitserver/domain/policy/dto/RecommendPolicyInfoResponseDto.java +++ b/src/main/java/com/cmc/zenefitserver/domain/policy/dto/RecommendPolicyInfoResponseDto.java @@ -1,6 +1,6 @@ package com.cmc.zenefitserver.domain.policy.dto; -import com.cmc.zenefitserver.domain.policy.domain.enums.PolicyDateType; +import com.cmc.zenefitserver.domain.policy.domain.enums.PolicyMethodType; import com.cmc.zenefitserver.domain.policy.domain.enums.SupportPolicyType; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -62,8 +62,14 @@ public static class recommendPolicyInfo { @ApiModelProperty(notes = "정책 기간 타입", example = "1560000") private String policyDateType; + @ApiModelProperty(notes = "정책 신청 방법", example = "LETTER, ONLINE, VISIT 등") + private PolicyMethodType policyMethodType; + + @ApiModelProperty(notes = "정책 신청 방법 설명", example = "우편신청, 방문신청, 온라인신청 등") + private String policyMethodTypeDescription; + @Builder - public recommendPolicyInfo(SupportPolicyType supportType, String supportTypeDescription, Long policyId, String policyName, String policyLogo, String policyAreaCode, String policyCityCode, String policyIntroduction, int supportTypePolicyCnt, int benefit, String policyDateType) { + public recommendPolicyInfo(SupportPolicyType supportType, String supportTypeDescription, Long policyId, String policyName, String policyLogo, String policyAreaCode, String policyCityCode, String policyIntroduction, int supportTypePolicyCnt, int benefit, String policyDateType, PolicyMethodType policyMethodType, String policyMethodTypeDescription) { this.supportType = supportType; this.supportTypeDescription = supportTypeDescription; this.policyId = policyId; @@ -75,6 +81,8 @@ public recommendPolicyInfo(SupportPolicyType supportType, String supportTypeDesc this.supportTypePolicyCnt = supportTypePolicyCnt; this.benefit = benefit; this.policyDateType = policyDateType; + this.policyMethodType = policyMethodType; + this.policyMethodTypeDescription = policyMethodTypeDescription; } public void upgradeCityCode(String name) {