Skip to content

Commit ccf5e5a

Browse files
authored
Merge pull request #292 from prgrms-web-devcourse-final-project/feat/home
feat[home]: 판례 법령 등등 갯수
2 parents 0444007 + 16574f9 commit ccf5e5a

File tree

5 files changed

+106
-1
lines changed

5 files changed

+106
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.ai.lawyer.domain.home.controller;
2+
3+
import com.ai.lawyer.domain.home.dto.FullData;
4+
import com.ai.lawyer.domain.home.service.HomeService;
5+
import io.swagger.v3.oas.annotations.Operation;
6+
import io.swagger.v3.oas.annotations.tags.Tag;
7+
import lombok.RequiredArgsConstructor;
8+
import lombok.extern.slf4j.Slf4j;
9+
import org.springframework.http.ResponseEntity;
10+
import org.springframework.web.bind.annotation.PostMapping;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RestController;
13+
14+
@Slf4j
15+
@RestController
16+
@RequestMapping("/api/home")
17+
@RequiredArgsConstructor
18+
@Tag(name = "홈", description = "홈 화면 API")
19+
public class HomeController {
20+
21+
private final HomeService homeService;
22+
23+
@Operation(summary = "데이터 수", description = "판례 법령 채팅 투표 수 조회")
24+
@PostMapping("/data-count")
25+
public ResponseEntity<FullData> getDataCount() {
26+
return ResponseEntity.ok(homeService.getDataCount());
27+
}
28+
29+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.ai.lawyer.domain.home.dto;
2+
3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
import lombok.*;
5+
6+
@Getter
7+
@Setter
8+
@Builder
9+
@NoArgsConstructor
10+
@AllArgsConstructor
11+
@Schema(description = "판례수 법령수 채팅수 투표수 DTO")
12+
public class FullData {
13+
14+
@Schema(description = "판례 수", example = "1000")
15+
private Long precedentCount;
16+
17+
@Schema(description = "법령 수", example = "500")
18+
private Long lawCount;
19+
20+
@Schema(description = "채팅 수", example = "2000")
21+
private Long chatCount;
22+
23+
@Schema(description = "투표 수", example = "300")
24+
private Long voteCount;
25+
26+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.ai.lawyer.domain.home.service;
2+
3+
import com.ai.lawyer.domain.chatbot.repository.ChatRepository;
4+
import com.ai.lawyer.domain.home.dto.FullData;
5+
import com.ai.lawyer.domain.law.repository.LawRepository;
6+
import com.ai.lawyer.domain.poll.repository.PollRepository;
7+
import com.ai.lawyer.domain.precedent.repository.PrecedentRepository;
8+
import lombok.RequiredArgsConstructor;
9+
import lombok.extern.slf4j.Slf4j;
10+
import org.springframework.stereotype.Service;
11+
12+
@Slf4j
13+
@Service
14+
@RequiredArgsConstructor
15+
public class HomeService {
16+
17+
private final PrecedentRepository precedentRepository;
18+
private final LawRepository lawRepository;
19+
private final ChatRepository chatRepository;
20+
private final PollRepository pollRepository;
21+
22+
23+
public FullData getDataCount() {
24+
25+
Long precedentCount = precedentRepository.count();
26+
Long lawCount = lawRepository.count();
27+
Long chatCount = chatRepository.count();
28+
Long voteCount = pollRepository.count();
29+
30+
return FullData.builder()
31+
.precedentCount(precedentCount)
32+
.lawCount(lawCount)
33+
.chatCount(chatCount)
34+
.voteCount(voteCount)
35+
.build();
36+
37+
}
38+
39+
}

backend/src/main/java/com/ai/lawyer/global/security/SecurityConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class SecurityConfig {
5757
"/api/law/**", // 법령 (공개)
5858
"/api/law-word/**", // 법률 용어 (공개)
5959
"/api/chat/**", // 챗봇 (공개)
60+
"/api/home/**", // 홈 (공개)
6061
"/h2-console/**", // H2 콘솔 (개발용)
6162
"/actuator/health", "/actuator/health/**", "/actuator/info", // Spring Actuator
6263
"/api/actuator/health", "/api/actuator/health/**", "/api/actuator/info"

backend/src/main/java/com/ai/lawyer/global/springDoc/SpringDocConfig.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,24 @@ public GroupedOpenApi allApi() {
6868
.build();
6969
}
7070

71-
@Bean GroupedOpenApi chatApi() {
71+
@Bean
72+
GroupedOpenApi chatApi() {
7273
return GroupedOpenApi.builder()
7374
.group("챗봇과 관련된 API")
7475
.pathsToMatch("/api/chat/**")
7576
.packagesToScan("com.ai.lawyer.domain.chatbot.controller")
7677
.build();
7778
}
7879

80+
@Bean
81+
GroupedOpenApi homeApi() {
82+
return GroupedOpenApi.builder()
83+
.group("Home API")
84+
.pathsToMatch("/api/home/**")
85+
.packagesToScan("com.ai.lawyer.domain.home.controller")
86+
.build();
87+
}
88+
7989
@Bean
8090
public OpenAPI customOpenAPI() {
8191
return new OpenAPI()

0 commit comments

Comments
 (0)