Skip to content

Commit

Permalink
feat : 정책 추천 API, 정책 리스트 조회, 키워드 조회 API, 정책 상세 정보 조회 API 에 정책 신청 방법 필드
Browse files Browse the repository at this point in the history
( PolicyMethodType ) 추가
  • Loading branch information
LHS-11 committed Dec 21, 2023
1 parent c57dfe7 commit b67e1e5
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -41,6 +42,7 @@ public Page<PolicyListResponseDto> getPolicyList(User user, PolicyListRequestDto
dto.updatePolicyDateTypeDescription(dto.getPolicyDateType());
dto.updateAreaCode(dto.getAreaCode());
dto.updateCityCode(dto.getCityCode());
dto.updatePolicyMethodType(dto.getPolicyMethodTypeDescription());
return dto;
});
}
Expand All @@ -54,6 +56,7 @@ public Page<PolicyListResponseDto> getSearchPolicyList(User user, SearchPolicyLi
dto.updatePolicyDateTypeDescription(dto.getPolicyDateType());
dto.updateAreaCode(dto.getAreaCode());
dto.updateCityCode(dto.getCityCode());
dto.updatePolicyMethodType(dto.getPolicyMethodTypeDescription());
return dto;
});
}
Expand All @@ -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())
Expand All @@ -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;
Expand Down Expand Up @@ -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())
Expand All @@ -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());
Expand Down Expand Up @@ -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<RecommendPolicyInfoResponseDto.recommendPolicyInfo> result = new ArrayList<>();
result.add(
RecommendPolicyInfoResponseDto.recommendPolicyInfo.builder()
Expand All @@ -215,6 +229,8 @@ public RecommendPolicyInfoResponseDto getRecommendPolicyDummy() {
.supportTypePolicyCnt(policyRepository.getPolicyCntBySupportPolicyType(SupportPolicyType.LOANS))
.benefit(10000000)
.policyDateType("기간 신청")
.policyMethodType(loansPolicyMethodType)
.policyMethodTypeDescription(loansPolicyMethodType.getDescription())
.build()
);
result.add(
Expand All @@ -230,6 +246,8 @@ public RecommendPolicyInfoResponseDto getRecommendPolicyDummy() {
.supportTypePolicyCnt(policyRepository.getPolicyCntBySupportPolicyType(SupportPolicyType.MONEY))
.benefit(10000000)
.policyDateType("상시")
.policyMethodType(moneyPolicyMethodType)
.policyMethodTypeDescription(moneyPolicyMethodType.getDescription())
.build()
);
result.add(
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public Page<PolicyListResponseDto> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface PolicyRepository extends JpaRepository<Policy, Long> {
"AND :age between p.minAge and p.maxAge")
List<Policy> 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 " +
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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();
}
}
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit b67e1e5

Please sign in to comment.