Skip to content

Commit

Permalink
[FIX] merge 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
hcg0127 committed Aug 1, 2024
2 parents 29d2076 + 801c6e1 commit 04b0e25
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
16 changes: 10 additions & 6 deletions src/main/java/umc/haruchi/service/BudgetRedistributionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,10 @@ public PushPlusClosing closingPlusOrZero(BudgetRedistributionRequestDTO.createCl
Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new MemberHandler(NO_MEMBER_EXIST)); //영속화

MonthBudget monthBudget = monthBudgetRepository.findByMemberIdAndYearAndMonth(member.getId(), request.getYear(), request.getMonth()).orElse(null);
DayBudget dayBudget = dayBudgetRepository.findByMonthBudgetAndDay(monthBudget, request.getDay()).orElse(null);
MonthBudget monthBudget = monthBudgetRepository.findByMemberIdAndYearAndMonth(member.getId(), request.getYear(), request.getMonth())
.orElseThrow(() -> new MonthBudgetHandler(MONTH_BUDGET_NOT_FOUND));
DayBudget dayBudget = dayBudgetRepository.findByMonthBudgetAndDay(monthBudget, request.getDay())
.orElseThrow(() -> new DayBudgetHandler(NOT_SOME_DAY_BUDGET));

//이미 마감된 날 에러처리
if(dayBudget.getDayBudgetStatus().equals(DayBudgetStatus.INACTIVE)) {
Expand Down Expand Up @@ -394,9 +396,10 @@ public PullMinusClosing closingMinus(BudgetRedistributionRequestDTO.createClosin
Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new MemberHandler(NO_MEMBER_EXIST)); //영속화

//orElse(null)을 붙여 수정함 -> null일 때 throw 처리 해야 할 수도?
MonthBudget monthBudget = monthBudgetRepository.findByMemberIdAndYearAndMonth(member.getId(), request.getYear(), request.getMonth()).orElse(null);
DayBudget dayBudget = dayBudgetRepository.findByMonthBudgetAndDay(monthBudget, request.getDay()).orElse(null);
MonthBudget monthBudget = monthBudgetRepository.findByMemberIdAndYearAndMonth(member.getId(), request.getYear(), request.getMonth())
.orElseThrow(() -> new MonthBudgetHandler(MONTH_BUDGET_NOT_FOUND));
DayBudget dayBudget = dayBudgetRepository.findByMonthBudgetAndDay(monthBudget, request.getDay())
.orElseThrow(() -> new DayBudgetHandler(NOT_SOME_DAY_BUDGET));

//이미 마감된 날 에러처리
if(dayBudget.getDayBudgetStatus().equals(DayBudgetStatus.INACTIVE)) {
Expand Down Expand Up @@ -480,7 +483,8 @@ public PullMinusClosing closingMinus(BudgetRedistributionRequestDTO.createClosin

public Long calculatingAmount(int year, int month, int day, Long amount, Long memberId) {

MonthBudget monthBudget = monthBudgetRepository.findByMemberIdAndYearAndMonth(memberId, year, month).orElse(null);
MonthBudget monthBudget = monthBudgetRepository.findByMemberIdAndYearAndMonth(memberId, year, month)
.orElseThrow(() -> new MonthBudgetHandler(MONTH_BUDGET_NOT_FOUND));

//이번 달 남은 일 수 알아내기(본인 제외)
long dayCount = monthBudget.getDayBudgetList().stream()
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/umc/haruchi/service/DayBudgetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import java.util.ArrayList;
import java.util.List;

import static umc.haruchi.apiPayload.code.status.ErrorStatus.NOT_DAY_BUDGET;
import static umc.haruchi.apiPayload.code.status.ErrorStatus.NOT_SOME_DAY_BUDGET;
import static umc.haruchi.apiPayload.code.status.ErrorStatus.*;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -128,7 +127,9 @@ public Income joinIncome(DayBudgetRequestDTO.createIncomeDTO request, Long membe
public Expenditure joinExpenditure(DayBudgetRequestDTO.createExpenditureDTO request, Long memberId) {
MonthBudget monthBudget = check(memberId);

DayBudget dayBudget = dayBudgetRepository.findByMonthBudgetAndDay(monthBudget, day).orElse(null);
DayBudget dayBudget = dayBudgetRepository.findByMonthBudgetAndDay(monthBudget, day)
.orElseThrow(() -> new DayBudgetHandler(NOT_SOME_DAY_BUDGET));

if(dayBudget == null){
throw new DayBudgetHandler(ErrorStatus.NOT_DAY_BUDGET);
}
Expand All @@ -154,7 +155,9 @@ public Expenditure joinExpenditure(DayBudgetRequestDTO.createExpenditureDTO requ
public void deleteExpenditure(Long memberId, Long expenditureId) {
MonthBudget monthBudget = check(memberId);

DayBudget dayBudget = dayBudgetRepository.findByMonthBudgetAndDay(monthBudget, day).orElse(null);
DayBudget dayBudget = dayBudgetRepository.findByMonthBudgetAndDay(monthBudget, day)
.orElseThrow(() -> new DayBudgetHandler(NOT_SOME_DAY_BUDGET));

if(dayBudget == null){
throw new DayBudgetHandler(ErrorStatus.NOT_DAY_BUDGET);
}
Expand Down

0 comments on commit 04b0e25

Please sign in to comment.