Skip to content

Commit 522d3c8

Browse files
committed
work
1 parent 6651e2c commit 522d3c8

File tree

4 files changed

+182
-0
lines changed

4 files changed

+182
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.ai.lawyer.domain.precedent.entity;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import jakarta.persistence.*;
5+
import lombok.Data;
6+
7+
import java.time.LocalDate;
8+
9+
@Entity
10+
@Data
11+
@Table(name = "precedent")
12+
public class Precedent {
13+
14+
@Id
15+
@GeneratedValue(strategy = GenerationType.IDENTITY)
16+
@JsonIgnore
17+
private Long id;
18+
19+
private String precedentNumber; // 판례일련번호
20+
21+
@Lob
22+
@Column(columnDefinition = "TEXT")
23+
private String caseName; // 사건명
24+
25+
@Lob
26+
@Column(columnDefinition = "TEXT")
27+
private String caseNumber; // 사건번호
28+
29+
private LocalDate sentencingDate; // 선고일자
30+
31+
private String sentence; // 선고
32+
33+
private String courtName; // 법원명
34+
35+
private String courtTypeCode; // 법원종류코드
36+
37+
private String caseTypeName; // 사건종류명
38+
39+
private String caseTypeCode; // 사건종류코드
40+
41+
private String typeOfJudgment; // 판결유형
42+
43+
@Lob
44+
@Column(columnDefinition = "LONGTEXT")
45+
private String notice; // 판시사항
46+
47+
@Lob
48+
@Column(columnDefinition = "LONGTEXT")
49+
private String summaryOfTheJudgment; // 판결요지
50+
51+
@Lob
52+
@Column(columnDefinition = "LONGTEXT")
53+
private String referenceArticle; // 참조조문
54+
55+
@Lob
56+
@Column(columnDefinition = "LONGTEXT")
57+
private String referencePrecedent; // 참조판례
58+
59+
@Lob
60+
@Column(columnDefinition = "LONGTEXT")
61+
private String precedentContent; // 판례내용
62+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.ai.lawyer.domain.precedent.repository;
2+
3+
import com.ai.lawyer.domain.precedent.dto.PrecedentSearchRequestDto;
4+
import com.ai.lawyer.domain.precedent.dto.PrecedentSummaryListDto;
5+
import com.ai.lawyer.domain.precedent.entity.QPrecedent;
6+
import com.querydsl.core.BooleanBuilder;
7+
import com.querydsl.core.types.Projections;
8+
import com.querydsl.jpa.impl.JPAQueryFactory;
9+
import lombok.RequiredArgsConstructor;
10+
import org.springframework.data.domain.*;
11+
import org.springframework.stereotype.Repository;
12+
import org.springframework.util.StringUtils;
13+
14+
import java.util.Collections;
15+
import java.util.List;
16+
17+
@Repository
18+
@RequiredArgsConstructor
19+
public class PrecedentRepositoryImpl implements PrecedentRepositoryCustom{
20+
21+
private final JPAQueryFactory queryFactory;
22+
23+
private final QPrecedent precedent = QPrecedent.precedent;
24+
25+
@Override
26+
public Page<PrecedentSummaryListDto> searchPrecedentsByKeyword(PrecedentSearchRequestDto requestDto) {
27+
28+
BooleanBuilder builder = new BooleanBuilder();
29+
30+
if (StringUtils.hasText(requestDto.getKeyword())) {
31+
String pattern = "%" + requestDto.getKeyword().trim() + "%";
32+
builder.or(precedent.getNotice().like(pattern))
33+
.or(precedent.getSummaryOfTheJudgment().like(pattern))
34+
.or(precedent.getPrecedentContent().like(pattern))
35+
.or(precedent.getCaseName().like(pattern))
36+
.or(precedent.getCaseNumber().like(pattern));
37+
}
38+
39+
// 페이징 및 정렬 설정
40+
Pageable pageable = PageRequest.of(
41+
requestDto.getPageNumber(),
42+
requestDto.getPageSize(),
43+
Sort.by(Sort.Direction.DESC, "sentencingDate")
44+
);
45+
46+
// 1) 전체 건수 조회
47+
long total = queryFactory
48+
.selectFrom(precedent)
49+
.where(builder)
50+
.fetchCount();
51+
52+
if (total == 0) {
53+
return new PageImpl<>(Collections.emptyList(), pageable, 0);
54+
}
55+
56+
// 2) 데이터 조회
57+
List<PrecedentSummaryListDto> content = queryFactory
58+
.select(Projections.constructor(PrecedentSummaryListDto.class,
59+
precedent.getId(),
60+
precedent.getCaseName(),
61+
precedent.getCaseNumber(),
62+
precedent.getSentencingDate()))
63+
.from(precedent)
64+
.where(builder)
65+
.offset(pageable.getOffset())
66+
.limit(pageable.getPageSize())
67+
.orderBy(precedent.getSentencingDate().desc())
68+
.fetch();
69+
70+
return new PageImpl<>(content, pageable, total);
71+
}
72+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
spring:
2+
datasource:
3+
url: ${DEV_DATASOURCE_URL}
4+
username: ${DEV_DATASOURCE_USERNAME}
5+
password: ${DEV_DATASOURCE_PASSWORD}
6+
driver-class-name: ${DEV_DATASOURCE_DRIVER}
7+
jpa:
8+
hibernate:
9+
ddl-auto: ${DEV_JPA_HIBERNATE_DDL_AUTO}
10+
properties:
11+
hibernate:
12+
dialect: org.hibernate.dialect.MySQLDialect
13+
data:
14+
redis:
15+
host: ${DEV_REDIS_HOST}
16+
port: ${DEV_REDIS_PORT}
17+
password: ${DEV_REDIS_PASSWORD}
18+
embedded: false
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
spring:
2+
autoconfigure:
3+
exclude:
4+
datasource:
5+
url: ${PROD_DATASOURCE_URL}
6+
driver-class-name: ${PROD_DATASOURCE_DRIVER}
7+
username: ${PROD_DATASOURCE_USERNAME}
8+
password: ${PROD_DATASOURCE_PASSWORD}
9+
hikari:
10+
maximum-pool-size: 20 # 트래픽에 맞춰 조정
11+
minimum-idle: 5
12+
idle-timeout: 30000
13+
connection-timeout: 30000
14+
max-lifetime: 1800000 # MySQL wait_timeout(기본 28800)보다 짧게
15+
jpa:
16+
open-in-view: false # 프로덕션 권장
17+
hibernate:
18+
ddl-auto: ${PROD_JPA_HIBERNATE_DDL_AUTO} # 운영 DB는 보통 validate (또는 none)
19+
properties:
20+
hibernate:
21+
dialect: org.hibernate.dialect.MySQL8Dialect # 부트가 자동 감지하지만 명시해도 OK
22+
format_sql: false
23+
sql:
24+
init:
25+
mode: never
26+
data:
27+
redis:
28+
host: ${PROD_REDIS_HOST}
29+
port: ${PROD_REDIS_PORT}
30+
password: ${PROD_REDIS_PASSWORD}

0 commit comments

Comments
 (0)