Skip to content

Commit 9300d1b

Browse files
authored
Merge pull request #139 from prgrms-web-devcourse-final-project/develop
chore[qdrant]: 변수 수정
2 parents fd67693 + 87862c2 commit 9300d1b

File tree

8 files changed

+105
-5
lines changed

8 files changed

+105
-5
lines changed

.github/workflows/CI-CD_Pipeline.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ jobs:
239239
aws-region: ${{ secrets.AWS_REGION }}
240240
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
241241
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
242-
instance-ids: "i-04e6cdbebfead7150"
242+
instance-ids: "i-083c532175a61cd43"
243243
working-directory: /
244244
comment: Deploy
245245
command: |
@@ -270,8 +270,8 @@ jobs:
270270
PROD_REDIS_PORT=6379
271271
PROD_REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
272272
273-
SPRING_AI_VECTORSTORE_QDRANT_HOST=qdrant_1
274-
SPRING_AI_VECTORSTORE_QDRANT_PORT=6334
273+
PROD_QDRANT_HOST=qdrant_1
274+
PROD_QDRANT_PORT=6334
275275
276276
send_email_address=${{ secrets.SEND_EMAIL_ADDRESS }}
277277
email_address=${{ secrets.EMAIL_ADDRESS }}

backend/src/main/java/com/ai/lawyer/domain/law/controller/LawController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
import com.ai.lawyer.domain.law.service.LawService;
77
import com.ai.lawyer.global.dto.PageResponseDto;
88
import io.swagger.v3.oas.annotations.Operation;
9+
import io.swagger.v3.oas.annotations.tags.Tag;
910
import lombok.RequiredArgsConstructor;
1011
import org.springframework.data.domain.Page;
1112
import org.springframework.http.ResponseEntity;
1213
import org.springframework.web.bind.annotation.*;
1314

1415
@RestController
1516
@RequiredArgsConstructor
17+
@Tag(name = "법령", description = "법령 API")
1618
@RequestMapping("/api/law")
1719
public class LawController {
1820

backend/src/main/java/com/ai/lawyer/domain/law/dto/LawsDto.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ public class LawsDto {
2323
private LocalDate promulgationDate; // 공포일자
2424

2525
private LocalDate enforcementDate; // 시행일자
26+
27+
private String firstJoContent; // 조
2628
}

backend/src/main/java/com/ai/lawyer/domain/law/repository/LawRepositoryCustomImpl.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
import com.ai.lawyer.domain.law.dto.LawSearchRequestDto;
44
import com.ai.lawyer.domain.law.dto.LawsDto;
5+
import com.ai.lawyer.domain.law.entity.QJang;
6+
import com.ai.lawyer.domain.law.entity.QJo;
57
import com.ai.lawyer.domain.law.entity.QLaw;
68
import com.querydsl.core.BooleanBuilder;
9+
import com.querydsl.core.Tuple;
710
import com.querydsl.core.types.Projections;
11+
import com.querydsl.core.types.dsl.Expressions;
12+
import com.querydsl.jpa.JPAExpressions;
813
import com.querydsl.jpa.impl.JPAQuery;
914
import com.querydsl.jpa.impl.JPAQueryFactory;
1015
import lombok.RequiredArgsConstructor;
@@ -14,8 +19,13 @@
1419
import org.springframework.data.domain.Pageable;
1520
import org.springframework.stereotype.Repository;
1621
import org.springframework.util.StringUtils;
22+
import com.querydsl.core.types.dsl.StringTemplate;
1723

24+
25+
import java.util.HashMap;
1826
import java.util.List;
27+
import java.util.Map;
28+
import java.util.stream.Collectors;
1929

2030
@Repository
2131
@RequiredArgsConstructor
@@ -24,6 +34,8 @@ public class LawRepositoryCustomImpl implements LawRepositoryCustom {
2434
private final JPAQueryFactory queryFactory;
2535

2636
private QLaw law = QLaw.law;
37+
private QJang jang = QJang.jang;
38+
private QJo jo = QJo.jo;
2739

2840
@Override
2941
public Page<LawsDto> searchLaws(LawSearchRequestDto searchRequest) {
@@ -70,6 +82,7 @@ public Page<LawsDto> searchLaws(LawSearchRequestDto searchRequest) {
7082

7183
Pageable pageable = PageRequest.of(searchRequest.getPageNumber(), searchRequest.getPageSize());
7284

85+
7386
// DTO 프로젝션 조회
7487
JPAQuery<LawsDto> query = queryFactory
7588
.select(Projections.constructor(
@@ -80,7 +93,8 @@ public Page<LawsDto> searchLaws(LawSearchRequestDto searchRequest) {
8093
law.getMinistry(),
8194
law.getPromulgationNumber(),
8295
law.getPromulgationDate(),
83-
law.getEnforcementDate()
96+
law.getEnforcementDate(),
97+
Expressions.nullExpression(String.class)
8498
))
8599
.from(law)
86100
.where(builder)
@@ -89,6 +103,35 @@ public Page<LawsDto> searchLaws(LawSearchRequestDto searchRequest) {
89103

90104
List<LawsDto> content = query.fetch();
91105

106+
if (content.isEmpty()) {
107+
return new PageImpl<>(content, pageable, 0);
108+
}
109+
110+
// 2. 조회한 법령 ID 목록 추출
111+
List<Long> lawIds = content.stream()
112+
.map(LawsDto::getId)
113+
.collect(Collectors.toList());
114+
115+
// 3. 법령별 첫 번째 조 내용 조회 - 반복문으로 각각 조회
116+
Map<Long, String> firstJoContentMap = new HashMap<>();
117+
for (Long lawId : lawIds) {
118+
String firstJoContent = queryFactory
119+
.select(jo.getContent())
120+
.from(jo)
121+
.join(jo.getJang(), jang)
122+
.where(jang.getLaw().getId().eq(lawId))
123+
.orderBy(jang.getId().asc(), jo.getId().asc())
124+
.limit(1)
125+
.fetchOne();
126+
firstJoContentMap.put(lawId, firstJoContent);
127+
}
128+
129+
// 4. 조회 결과에 firstJoContent 세팅
130+
content.forEach(dto -> {
131+
String contentVal = firstJoContentMap.get(dto.getId());
132+
dto.setFirstJoContent(contentVal != null ? contentVal : "");
133+
});
134+
92135
// 전체 개수 조회
93136
Long total = queryFactory
94137
.select(law.count())

backend/src/main/java/com/ai/lawyer/domain/lawWord/controller/LawWordController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.ai.lawyer.domain.lawWord.service.LawWordService;
44
import com.ai.lawyer.domain.precedent.entity.Precedent;
55
import io.swagger.v3.oas.annotations.Operation;
6+
import io.swagger.v3.oas.annotations.tags.Tag;
67
import lombok.RequiredArgsConstructor;
78
import org.springframework.http.ResponseEntity;
89
import org.springframework.web.bind.annotation.GetMapping;
@@ -13,6 +14,7 @@
1314
@RestController
1415
@RequiredArgsConstructor
1516
@RequestMapping("/api/law-word")
17+
@Tag(name = "법령 용어", description = "법령 용어 API")
1618
public class LawWordController {
1719

1820
private final LawWordService lawWordService;

backend/src/main/java/com/ai/lawyer/domain/precedent/controller/PrecedentController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.ai.lawyer.domain.precedent.service.PrecedentService;
77
import com.ai.lawyer.global.dto.PageResponseDto;
88
import io.swagger.v3.oas.annotations.Operation;
9+
import io.swagger.v3.oas.annotations.tags.Tag;
910
import lombok.RequiredArgsConstructor;
1011
import org.springframework.data.domain.Page;
1112
import org.springframework.http.ResponseEntity;
@@ -14,6 +15,7 @@
1415
@RestController
1516
@RequiredArgsConstructor
1617
@RequestMapping("/api/precedent")
18+
@Tag(name = "판례", description = "판례 API")
1719
public class PrecedentController {
1820

1921
private final PrecedentService precedentService;

backend/src/main/java/com/ai/lawyer/domain/precedent/dto/PrecedentSummaryListDto.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ public class PrecedentSummaryListDto {
1212
private String caseName; // 사건명
1313
private String caseNumber; // 사건번호
1414
private LocalDate sentencingDate; // 선고일자
15+
private String contents;
1516
}

backend/src/main/java/com/ai/lawyer/domain/precedent/repository/PrecedentRepositoryImpl.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.ai.lawyer.domain.precedent.entity.QPrecedent;
66
import com.querydsl.core.BooleanBuilder;
77
import com.querydsl.core.types.Projections;
8+
import com.querydsl.core.types.dsl.CaseBuilder;
9+
import com.querydsl.core.types.dsl.StringExpression;
810
import com.querydsl.jpa.impl.JPAQueryFactory;
911
import lombok.RequiredArgsConstructor;
1012
import org.springframework.data.domain.*;
@@ -53,20 +55,66 @@ public Page<PrecedentSummaryListDto> searchPrecedentsByKeyword(PrecedentSearchRe
5355
return new PageImpl<>(Collections.emptyList(), pageable, 0);
5456
}
5557

58+
// CLOB 필드 조건: null 또는 빈 문자열("") 체크
59+
StringExpression contents = new CaseBuilder()
60+
// summaryOfTheJudgment가 null도 아니고, 빈 문자열도 아닐 때
61+
.when(precedent.getSummaryOfTheJudgment().isNotNull()
62+
.and(precedent.getSummaryOfTheJudgment().ne("")))
63+
.then(precedent.getSummaryOfTheJudgment())
64+
// notice가 null도 아니고, 빈 문자열도 아닐 때
65+
.when(precedent.getNotice().isNotNull()
66+
.and(precedent.getNotice().ne("")))
67+
.then(precedent.getNotice())
68+
// 그 외에는 precedentContent 전체
69+
.otherwise(precedent.getPrecedentContent());
70+
71+
5672
// 2) 데이터 조회
5773
List<PrecedentSummaryListDto> content = queryFactory
5874
.select(Projections.constructor(PrecedentSummaryListDto.class,
5975
precedent.getId(),
6076
precedent.getCaseName(),
6177
precedent.getCaseNumber(),
62-
precedent.getSentencingDate()))
78+
precedent.getSentencingDate(),
79+
contents
80+
))
6381
.from(precedent)
6482
.where(builder)
6583
.offset(pageable.getOffset())
6684
.limit(pageable.getPageSize())
6785
.orderBy(precedent.getSentencingDate().desc())
6886
.fetch();
6987

88+
// Java에서 후처리: 빈 문자열 체크 및 【주문】부분 추출
89+
content.forEach(dto -> {
90+
String processedContents = processContents(dto.getContents());
91+
dto.setContents(processedContents);
92+
});
93+
7094
return new PageImpl<>(content, pageable, total);
7195
}
96+
97+
private String processContents(String contents) {
98+
if (contents == null || contents.trim().isEmpty()) {
99+
return "";
100+
}
101+
102+
// 이미 summaryOfTheJudgment나 notice가 있는 경우
103+
if (!contents.contains("【주 문】")) {
104+
return contents;
105+
}
106+
107+
// precedentContent에서 【주문】부터 【이유】까지 추출
108+
String startTag = "【주 문】";
109+
String endTag = "【이 유】";
110+
111+
int startIndex = contents.indexOf(startTag);
112+
int endIndex = contents.indexOf(endTag);
113+
114+
if (startIndex != -1 && endIndex != -1 && endIndex > startIndex) {
115+
return contents.substring(startIndex, endIndex).trim();
116+
}
117+
118+
return contents;
119+
}
72120
}

0 commit comments

Comments
 (0)