Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #57 from FinFellows/develop
Browse files Browse the repository at this point in the history
[FEAT]: 50 policy api (#56)
  • Loading branch information
sejineer authored Jan 7, 2024
2 parents 8ddb75f + e48f57c commit ea9d754
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public PolicyInfoBookmarkRes(String contentName, String content) {
public static List<PolicyInfoBookmarkRes> toDto(List<PolicyInfoBookmark> bookmarks) {
return bookmarks.stream()
.map(bookmark -> PolicyInfoBookmarkRes.builder()
.contentName(bookmark.getPolicyInfo().getContentName())
.content(bookmark.getPolicyInfo().getContent())
.contentName(bookmark.getPolicyInfo().getPolyBizSjNm())
.content(bookmark.getPolicyInfo().getPolyItcnCn())
.build())
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.finfellows.domain.policyinfo.application;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@RequiredArgsConstructor
@Service
@Transactional(readOnly = true)
public class PolicyInfoService {


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,61 @@ public class PolicyInfo extends BaseEntity {
@Column(name = "id", updatable = false)
private Long id;

@Column(name = "content_name", nullable = false, unique = true)
private String contentName;
private String polyBizSjNm;

@Column(name="content", nullable = false, unique = true)
private String content;
private String polyItcnCn;

private String sporCn;

private String bizPrdCn;

private String rqutPrdCn;

private String sporScvl;

private String ageInfo;

private String prcpCn;

private String accrRqisCn;

private String majrRqisCn;

private String empmSttsCn;

private String splzRlmRqisCn;

private String aditRscn;

private String prcpLmttTrgtCn;

private String rqutProcCn;

private String jdgnPresCn;

private String rqutUrla;

private String pstnPaprCn;

@Builder
public PolicyInfo(String contentName, String content) {
this.contentName = contentName;
this.content = content;
public PolicyInfo(String polyBizSjNm, String polyItcnCn, String sporCn, String bizPrdCn, String rqutPrdCn, String sporScvl, String ageInfo, String prcpCn, String accrRqisCn, String majrRqisCn, String empmSttsCn, String splzRlmRqisCn, String aditRscn, String prcpLmttTrgtCn, String rqutProcCn, String jdgnPresCn, String rqutUrla, String pstnPaprCn) {
this.polyBizSjNm = polyBizSjNm;
this.polyItcnCn = polyItcnCn;
this.sporCn = sporCn;
this.bizPrdCn = bizPrdCn;
this.rqutPrdCn = rqutPrdCn;
this.sporScvl = sporScvl;
this.ageInfo = ageInfo;
this.prcpCn = prcpCn;
this.accrRqisCn = accrRqisCn;
this.majrRqisCn = majrRqisCn;
this.empmSttsCn = empmSttsCn;
this.splzRlmRqisCn = splzRlmRqisCn;
this.aditRscn = aditRscn;
this.prcpLmttTrgtCn = prcpLmttTrgtCn;
this.rqutProcCn = rqutProcCn;
this.jdgnPresCn = jdgnPresCn;
this.rqutUrla = rqutUrla;
this.pstnPaprCn = pstnPaprCn;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.finfellows.domain.policyinfo.domain.repository;

import com.finfellows.domain.policyinfo.dto.SearchPolicyInfoRes;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

public interface PolicyInfoQueryDslRepository {

Page<SearchPolicyInfoRes> findPolicyInfos(String searchKeyword, Pageable pageable, Long userId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.finfellows.domain.policyinfo.domain.repository;

import com.finfellows.domain.bookmark.domain.QPolicyInfoBookmark;
import com.finfellows.domain.policyinfo.domain.QPolicyInfo;
import com.finfellows.domain.policyinfo.dto.QSearchPolicyInfoRes;
import com.finfellows.domain.policyinfo.dto.SearchPolicyInfoRes;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.support.PageableExecutionUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

import static com.finfellows.domain.policyinfo.domain.QPolicyInfo.*;

@RequiredArgsConstructor
@Repository
public class PolicyInfoQueryDslRepositoryImpl implements PolicyInfoQueryDslRepository {

private final JPAQueryFactory queryFactory;

@Override
public Page<SearchPolicyInfoRes> findPolicyInfos(String searchKeyword, Pageable pageable, Long userId) {
QPolicyInfoBookmark policyInfoBookmark = QPolicyInfoBookmark.policyInfoBookmark;

List<SearchPolicyInfoRes> results = queryFactory
.select(new QSearchPolicyInfoRes(
policyInfo.id,
policyInfo.polyBizSjNm,
policyInfo.polyItcnCn,
policyInfoBookmark.id.isNotNull()
))
.from(policyInfo)
.leftJoin(policyInfoBookmark)
.on(policyInfoBookmark.policyInfo.eq(policyInfo).and(policyInfoBookmark.user.id.eq(userId)))
.where(
searchEq(searchKeyword)
)
.orderBy(policyInfo.polyBizSjNm.asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();

JPAQuery<Long> countQuery = queryFactory
.select(policyInfo.count())
.from(policyInfo)
.where(
searchEq(searchKeyword)
);

return PageableExecutionUtils.getPage(results, pageable, countQuery::fetchCount);
}

private BooleanExpression searchEq(String searchKeyword) {
return searchKeyword != null ? policyInfo.polyBizSjNm.contains(searchKeyword).or(policyInfo.polyItcnCn.contains(searchKeyword)) : null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import com.finfellows.domain.policyinfo.domain.PolicyInfo;
import org.springframework.data.jpa.repository.JpaRepository;

public interface PolicyInfoRepository extends JpaRepository<PolicyInfo, Long> {
public interface PolicyInfoRepository extends JpaRepository<PolicyInfo, Long> , PolicyInfoQueryDslRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.finfellows.domain.policyinfo.dto;

import com.querydsl.core.annotations.QueryProjection;
import lombok.Data;

@Data
public class SearchPolicyInfoRes {

private Long policyInfoId;
private String policyName;
private String policyContent;
private Boolean isLiked;

@QueryProjection
public SearchPolicyInfoRes(Long policyInfoId, String policyName, String policyContent, Boolean isLiked) {
this.policyInfoId = policyInfoId;
this.policyName = policyName;
this.policyContent = policyContent;
this.isLiked = isLiked;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.finfellows.domain.policyinfo.presentation;

import com.finfellows.global.payload.ErrorResponse;
import com.finfellows.global.payload.ResponseCustom;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "Policy Information", description = "Policy Information API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/policy-info")
public class PolicyInfoController {

// @Operation(summary = "정책 리스트 조회", description = "정책 리스트를 조건에 따라 조회합니다.")
// @ApiResponses(value = {
// @ApiResponse(responseCode = "200", description = "정책 리스트 조회 성공", content = {@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = String.class)))}),
// @ApiResponse(responseCode = "400", description = "정책 리스트 조회 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}),
// })
// @GetMapping("/bank")
// public ResponseCustom<List<String>> findBanks(
// @Parameter(description = "조회 할 페이지와 페이지 크기를 입력해주세요") Pageable pageable
// ) {
// return ResponseCustom.OK(financialProductServiceImpl.findBanks(bankGroupNo));
// }

}

0 comments on commit ea9d754

Please sign in to comment.