Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,35 @@ public ResponseEntity<?> getStatisticsCard(

@PostMapping("/search")
@Operation(summary = "볍령 목록 검색 기능", description = "조건에 맞는 법령 목록을 가져옵니다")
public ResponseEntity<PageResponseDto> searchLaws(@RequestBody LawSearchRequestDto searchRequest) {
Page<LawsDto> laws = lawService.searchLaws(searchRequest);
PageResponseDto response = PageResponseDto.builder()
.content(laws.getContent())
.totalElements(laws.getTotalElements())
.totalPages(laws.getTotalPages())
.pageNumber(laws.getNumber())
.pageSize(laws.getSize())
.build();
return ResponseEntity.ok(response);
public ResponseEntity<?> searchLaws(@RequestBody LawSearchRequestDto searchRequest) {
try {
Page<LawsDto> laws = lawService.searchLaws(searchRequest);
PageResponseDto response = PageResponseDto.builder()
.content(laws.getContent())
.totalElements(laws.getTotalElements())
.totalPages(laws.getTotalPages())
.pageNumber(laws.getNumber())
.pageSize(laws.getSize())
.build();
return ResponseEntity.ok(response);
}catch (Exception e){
return ResponseEntity.badRequest().body("법령 목록 검색 에러 : " + e.getMessage());
}

}

@GetMapping("/{id}")
@Operation(summary = "볍령 상세 조회 기능", description = "법령 상세 데이터를 조회합니다 \n" +
"예시: /api/law/1")
public ResponseEntity<Law> getFullLaw(@PathVariable Long id) {
Law law = lawService.getLawWithAllChildren(id);
public ResponseEntity<?> getFullLaw(@PathVariable Long id) {
try {
Law law = lawService.getLawWithAllChildren(id);
return ResponseEntity.ok(law);
}catch (Exception e){
return ResponseEntity.badRequest().body("법령 상세 조회 에러 : " + e.getMessage());
}



return ResponseEntity.ok(law);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ResponseEntity<?> getPrecedentV1(@PathVariable String word) {
try {
return ResponseEntity.ok(lawWordService.findDefinition(word));
}catch (Exception e){
return ResponseEntity.badRequest().body(e.getMessage());
return ResponseEntity.badRequest().body("법령 용어 검색 에러 : " + e.getMessage());
}
}

Expand All @@ -37,7 +37,7 @@ public ResponseEntity<?> getPrecedentV2(@PathVariable String word) {
try {
return ResponseEntity.ok(lawWordService.findDefinitionV2(word));
}catch (Exception e){
return ResponseEntity.badRequest().body(e.getMessage());
return ResponseEntity.badRequest().body("법령 용어 검색 에러 : " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ private String extractTop3DefinitionsFromJson(String json, String requestedWord)

// 2. 클라이언트가 요청한 단어와 정확히 일치하는 item만 필터링
List<JsonNode> matchingItems = new ArrayList<>();
String normalizedRequestedWord = normalize(requestedWord);

for (JsonNode item : itemsNode) {
String itemWord = item.path("word").asText();
if (requestedWord.equals(itemWord)) {
String normalizedItemWord = normalize(itemWord);
if (normalizedRequestedWord.equals(normalizedItemWord)) {
matchingItems.add(item);
}
}
Expand Down Expand Up @@ -211,4 +214,9 @@ private void saveDefinition(String word, String definition) {
.build();
lawWordRepository.save(entity);
}

// 유틸: 단어 정규화 함수
private String normalize(String input) {
return input.replaceAll("[\\s\\^]", "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,23 @@ public ResponseEntity<?> list(

@PostMapping("/search")
@Operation(summary = "판례 목록 검색 기능", description = "조건에 맞는 판례 목록을 가져옵니다")
public ResponseEntity<PageResponseDto> searchPrecedents(
public ResponseEntity<?> searchPrecedents(
@RequestBody PrecedentSearchRequestDto requestDto) {
try {
Page<PrecedentSummaryListDto> results = precedentService.searchByKeyword(requestDto);
PageResponseDto response = PageResponseDto.builder()
.content(results.getContent())
.totalElements(results.getTotalElements())
.totalPages(results.getTotalPages())
.pageNumber(results.getNumber())
.pageSize(results.getSize())
.build();
return ResponseEntity.ok(response);
}catch (Exception e){
return ResponseEntity.badRequest().body("판례 목록 검색 에러 : " + e.getMessage());
}


Page<PrecedentSummaryListDto> results = precedentService.searchByKeyword(requestDto);
PageResponseDto response = PageResponseDto.builder()
.content(results.getContent())
.totalElements(results.getTotalElements())
.totalPages(results.getTotalPages())
.pageNumber(results.getNumber())
.pageSize(results.getSize())
.build();
return ResponseEntity.ok(response);
}

/**
Expand All @@ -61,8 +66,12 @@ public ResponseEntity<PageResponseDto> searchPrecedents(
@GetMapping("/{id}")
@Operation(summary = "판례 상세 조회 기능", description = "판례 상세 데이터를 조회합니다 \n" +
"예시: /api/precedent/1")
public ResponseEntity<Precedent> getPrecedent(@PathVariable Long id) {
Precedent precedent = precedentService.getPrecedentById(id);
return ResponseEntity.ok(precedent);
public ResponseEntity<?> getPrecedent(@PathVariable Long id) {
try {
Precedent precedent = precedentService.getPrecedentById(id);
return ResponseEntity.ok(precedent);
}catch (Exception e){
return ResponseEntity.badRequest().body("판례 상세 조회 에러 : " + e.getMessage());
}
}
}