This commit is contained in:
ondal
2025-02-13 18:42:46 +09:00
parent ba3405bff3
commit d7ca5994b4
48 changed files with 1071 additions and 7 deletions
+18
View File
@@ -0,0 +1,18 @@
서비스명|구독추천
마이크로서비스 이름|SubRecommend
유저스토리 ID|RSS-005
유저스토리 제목|추천 구독 카테고리
Controller 이름|RecommendController
API 목적|사용자의 지출 패턴을 분석하여 추천 구독 카테고리 제공
API Method|GET
API 그룹 Path|/api/recommend
API Path|/categories
Path <변수유형> <변수명>|
Query Key|userId
Query <변수유형> <변수명>|String userId
Request DTO 이름|
Request DTO 배열 여부|
Request DTO 구조|
Response DTO 이름|RecommendCategoryDTO
Response DTO 배열 여부|No
Response DTO 구조|String categoryName; LocalDate baseDate; String spendingCategory; Long totalSpending
+37
View File
@@ -0,0 +1,37 @@
!theme mono
title Recommendation Service - 데이터 모델
' Style configurations
skinparam linetype ortho
hide circle
entity "Spending_History" as spending {
* id: bigint <<PK>>
--
userId: varchar(50)
category: varchar(50)
amount: decimal(15,2)
spendingDate: date
createdAt: timestamp
}
entity "Recommended_Categories" as recommend {
* id: bigint <<PK>>
--
spendingCategory: varchar(50)
recommendCategory: varchar(50)
createdAt: timestamp
}
note right of spending
사용자별 지출 이력 관리
- 금액
- 카테고리
- 지출일자
end note
note right of recommend
지출-구독 카테고리 매핑
- 지출 카테고리
- 추천 구독 카테고리
end note
+54
View File
@@ -0,0 +1,54 @@
!theme mono
title 구독추천 서비스 - 내부 시퀀스 다이어그램
actor Client
participant "추천 컨트롤러\n(RecommendController)" as Controller
participant "추천 서비스\n(RecommendService)" as Service
participant "지출분석 서비스\n(SpendingAnalyzer)" as Analyzer
database "구독추천 DB" as RecommendDB
' 지출 기반 추천 카테고리 조회
Client -> Controller: GET /api/recommend/categories\n[지출 기반 추천 카테고리 조회]
activate Controller
Controller -> Service: getRecommendedCategory(userId)
activate Service
' 사용자 지출 패턴 분석
Service -> Analyzer: analyzeSpending(spendings)
activate Analyzer
Analyzer -> RecommendDB: findSpendingsByUserIdAndDateAfter(userId, startDate)
RecommendDB --> Analyzer: List<SpendingEntity>
Analyzer -> Analyzer: calculateTotalByCategory()
Analyzer -> Analyzer: findTopCategory()
Analyzer --> Service: SpendingCategory
deactivate Analyzer
' 추천 카테고리 매핑
Service -> RecommendDB: findBySpendingCategory(topSpendingCategory)
RecommendDB --> Service: RecommendedCategory
' 추천 결과 반환
Service --> Controller: RecommendCategoryDTO
Controller --> Client: HTTP Response\n(recommendCategory, spendingCategory, baseDate)
deactivate Service
deactivate Controller
note right of Controller
1. 요청 파라미터 검증
2. 서비스 계층 호출
3. 응답 변환
end note
note right of Service
1. 지출 패턴 분석 요청
2. 추천 카테고리 매핑
3. 추천 결과 생성
end note
note right of Analyzer
1. 최근 1개월 지출 데이터 조회
2. 카테고리별 지출 합산
3. 최고 지출 카테고리 도출
end note
+81
View File
@@ -0,0 +1,81 @@
!theme mono
title Recommendation Service - Class Diagram
package "com.unicorn.lifesub.recommend" {
package "domain" {
class SpendingCategory {
-category: String
-totalAmount: Long
}
class RecommendedCategory {
-spendingCategory: String
-recommendCategory: String
-baseDate: LocalDate
}
}
package "service" {
interface RecommendService {
+getRecommendedCategory(userId: String): RecommendCategoryDTO
}
class RecommendServiceImpl {
-recommendRepository: RecommendRepository
-spendingRepository: SpendingRepository
-spendingAnalyzer: SpendingAnalyzer
+getRecommendedCategory(userId: String): RecommendCategoryDTO
}
class SpendingAnalyzer {
+analyzeSpending(spendings: List<SpendingEntity>): SpendingCategory
-calculateTotalByCategory(spendings: List<SpendingEntity>): Map<String, Long>
-findTopCategory(totals: Map<String, Long>): SpendingCategory
}
}
package "controller" {
class RecommendController {
-recommendService: RecommendService
+getRecommendedCategory(userId: String): ResponseEntity<ApiResponse<RecommendCategoryDTO>>
}
}
package "dto" {
class RecommendCategoryDTO {
-categoryName: String
-baseDate: LocalDate
-spendingCategory: String
-totalSpending: Long
}
}
package "repository" {
package "jpa" {
interface SpendingRepository {
+findSpendingsByUserIdAndDateAfter(userId: String, startDate: LocalDate): List<SpendingEntity>
}
interface RecommendRepository {
+findBySpendingCategory(category: String): Optional<RecommendedCategoryEntity>
}
}
package "entity" {
class SpendingEntity {
-id: Long
-userId: String
-category: String
-amount: Long
-spendingDate: LocalDate
}
class RecommendedCategoryEntity {
-id: Long
-spendingCategory: String
-recommendCategory: String
+toDomain(): RecommendedCategory
}
}
}
}