Skip to content

Commit 88791bf

Browse files
authored
Merge pull request #171 from Money-Touch/fix/#159
🐛Fix: 소비루틴 반영 미리보기 시 반영하려는 카테고리가 기존 ROUTINE_CATEGORY에 포함되지 않는 경우 수정
2 parents 26e81f7 + 01940e8 commit 88791bf

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# 🌱 UMC 8th 돈터치 Backend 🌱
2-
## 🤑 Introduce
1+
# 🤑 UMC 8th 돈터치 Backend
32
<img width="1920" height="1080" alt="Image" src="https://github.com/user-attachments/assets/c9ee2c8b-74e9-4162-88a2-c3e651be45f8" />
43

54
**돈터치**는 소비 관리 플랫폼으로, 소비 기록과 분석을 중심으로 **예산 관리와 소비 습관 개선**을 지원합니다. SNS 형식의 소비 피드와 랭킹·배지 시스템을 통해 사용자 간 소통과 경쟁을 활성화하며, 가계부·소비 루틴·고정비 관리 등 체계적인 소비 관리 서비스를 제공합니다.
65

6+
&nbsp;
77
## 🔧 Tech Stack
88
<p>
99
<img src="https://img.shields.io/badge/springboot-6DB33F?style=for-the-badge&logo=springboot&logoColor=white">
@@ -22,10 +22,20 @@
2222
<img src="https://img.shields.io/badge/Swagger-85EA2D?style=for-the-badge&logo=swagger&logoColor=white">
2323
</p>
2424

25+
&nbsp;
26+
## ✨ Main Feature
27+
<img width="1920" height="1080" alt="서비스 컨셉" src="https://github.com/user-attachments/assets/c55a89d3-3b8f-49c5-be28-6360c7c0e4ff" />
28+
<img width="1920" height="2160" alt="image" src="https://github.com/user-attachments/assets/a1871e9c-6872-44a1-9aec-6b2d346df298" />
29+
<img width="1920" height="2751" alt="image" src="https://github.com/user-attachments/assets/c23cc439-14ce-4935-8ba7-8bbff2308293" />
30+
<img width="1920" height="4020" alt="image" src="https://github.com/user-attachments/assets/b96879b7-c5eb-440a-b9dd-0f6f04fa3890" />
31+
<img width="1920" height="2557" alt="image" src="https://github.com/user-attachments/assets/8cfaab8e-e420-4792-9a54-63a1f1f4a2e3" />
2532

33+
34+
&nbsp;
2635
## 🛠 Server Architecture
2736
<img width="1955" height="1540" alt="돈터치 아키텍처" src="https://github.com/user-attachments/assets/acc1630f-5eca-4a2f-aaa8-110ac448bee8" />
2837

38+
&nbsp;
2939
## 👤 Backend Developers
3040

3141
<table>
@@ -61,6 +71,7 @@
6171
</tr>
6272
</table>
6373

74+
&nbsp;
6475
## 🚀 Git Flow
6576
- `main`
6677
- 프로젝트 최종 merge
@@ -78,12 +89,14 @@
7889
7990
<!-- <img width="838" height="718" alt="Image" src="https://github.com/user-attachments/assets/530e9719-468e-457a-981a-e5fa46af82ff" /> -->
8091

92+
&nbsp;
8193
## 💡 PR Rules
8294
- Assignee에는 본인을 지정해 주세요.
8395
- Reviewers에는 본인을 제외한 백엔드 팀원 3명을 지정한 후, 카카오톡으로 공유해 주세요.
8496
- 이후, 팀원(1명 이상)이 PR을 확인하고 승인해서 머지해 주세요.
8597
(해당 브랜치는 머지 후 자동 삭제되며, 복구도 가능합니다.)
8698

99+
&nbsp;
87100
## 💻 Commit Message Convention
88101
| **Type** | **Description** |
89102
| --- | --- |

src/main/java/com/server/money_touch/domain/routine/service/RoutineCommandServiceImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ public void applyRoutineToBudget(Long userId, Long routineId, RoutineRequest.App
135135
Routine routine = routineRepository.findById(routineId)
136136
.orElseThrow(() -> new ErrorHandler(ErrorStatus.ROUTINE_NOT_FOUND));
137137

138-
// if (routine.getUser().getId().equals(userId)) {
139-
// throw new ErrorHandler(ErrorStatus.ROUTINE_PREVIEW_NOT_ALLOWED);
140-
// }
141-
142138
// 3. 이번 달 예산 조회
143139
String currentMonth = LocalDate.now().withDayOfMonth(1).toString().substring(0, 7); // "2025-08"
144140
Budget budget = budgetRepository.findByUserIdAndCreatedMonth(userId, currentMonth)

src/main/java/com/server/money_touch/domain/routine/service/RoutineQueryServiceImpl.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,6 @@ public RoutineResponse.ApplyRoutineInfoDTO getRoutineApplyInfo(Long userId, Long
165165
Routine routine = routineRepository.findById(routineId)
166166
.orElseThrow(() -> new ErrorHandler(ErrorStatus.ROUTINE_NOT_FOUND));
167167

168-
// 본인 루틴은 미리보기 제한 (단, userId=1은 예외 허용)
169-
// if (!userId.equals(1L) && routine.getUser().getId().equals(userId)) {
170-
// throw new ErrorHandler(ErrorStatus.ROUTINE_PREVIEW_NOT_ALLOWED);
171-
// }
172-
173168
// 3. 해당 루틴의 예산 생성 월 기준으로 내 예산 조회
174169
Budget myBudget = budgetRepository.findByUserAndCreatedMonth(user, routine.getBudget().getCreatedMonth())
175170
.orElseThrow(() -> new ErrorHandler(ErrorStatus.BUDGET_NOT_FOUND));
@@ -202,7 +197,7 @@ public RoutineResponse.ApplyRoutineInfoDTO getRoutineApplyInfo(Long userId, Long
202197
})
203198
.collect(Collectors.toList());
204199

205-
// 7. 루틴 기반 ROUTINE_CATEGORY 구성 (CUSTOM과 이름이 겹치는 항목 포함)
200+
// 7. 루틴 기반 ROUTINE_CATEGORY 구성 (CUSTOM과 이름이 겹치면 무조건 ROUTINE_CATEGORY)
206201
Set<String> routineCategoryNames = new HashSet<>();
207202
List<RoutineResponse.ApplyCategoryBudgetDTO> routineCategoryBudgets = routineAmounts.stream()
208203
.filter(ra -> !defaultNames.contains(ra.getCategoryName()))
@@ -219,7 +214,7 @@ public RoutineResponse.ApplyRoutineInfoDTO getRoutineApplyInfo(Long userId, Long
219214
.filter(mc -> {
220215
String name = mc.getConsumptionCategory().getBudgetCategoryName();
221216
return mc.getConsumptionCategory().getBudgetCategoryType() == CategoryType.CUSTOM &&
222-
!routineCategoryNames.contains(name);
217+
!routineCategoryNames.contains(name); // ✅ 겹치면 ROUTINE_CATEGORY 우선
223218
})
224219
.map(mc -> RoutineConverter.toCategoryDTO(
225220
mc.getConsumptionCategory().getBudgetCategoryName(),
@@ -228,8 +223,19 @@ public RoutineResponse.ApplyRoutineInfoDTO getRoutineApplyInfo(Long userId, Long
228223
)
229224
.collect(Collectors.toList());
230225

231-
// 9. 요청에 없는 기존 카테고리 → 금액 0으로 초기화
232-
// (루틴 반영 applyRoutineToBudget 로직과 동일한 컨셉 적용)
226+
// 9. 기존 루틴 카테고리인데 이번 루틴에 빠진 경우 → CUSTOM + 0원으로 변경
227+
myCategories.stream()
228+
.filter(mc -> mc.getConsumptionCategory().getBudgetCategoryType() == CategoryType.ROUTINE_CATEGORY)
229+
.filter(mc -> !routineCategoryNames.contains(mc.getConsumptionCategory().getBudgetCategoryName()))
230+
.forEach(mc -> customCategoryBudgets.add(
231+
RoutineConverter.toCategoryDTO(
232+
mc.getConsumptionCategory().getBudgetCategoryName(),
233+
0, // 빠졌으므로 0원
234+
CategoryType.CUSTOM // ROUTINE_CATEGORY → CUSTOM 변경
235+
)
236+
));
237+
238+
// 10. 요청에 없는 기존 카테고리 → 금액 0으로 초기화 (applyRoutineToBudget 로직과 동일)
233239
Set<String> requestCategoryNames = new HashSet<>();
234240
requestCategoryNames.addAll(defaultCategoryBudgets.stream()
235241
.map(RoutineResponse.ApplyCategoryBudgetDTO::getCategoryName)
@@ -254,5 +260,4 @@ public RoutineResponse.ApplyRoutineInfoDTO getRoutineApplyInfo(Long userId, Long
254260
routineCategoryBudgets
255261
);
256262
}
257-
258263
}

0 commit comments

Comments
 (0)