feat: 예상 수입 월별 저장 + 계좌 순서변경 API
- 예상 수입: budget_income(연·월별) 로 변경, GET/PUT 에 year·month - 계좌: wallet.sort_order + reorder 엔드포인트, 생성 시 맨 뒤 배치 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
cac9919cc5
commit
f5e9b78a14
@@ -301,10 +301,25 @@ public class AccountService {
|
||||
public WalletResponse createWallet(WalletRequest req, Long memberId) {
|
||||
Wallet wallet = toWallet(req);
|
||||
wallet.setMemberId(memberId);
|
||||
Integer max = walletMapper.maxSortOrder(memberId, req.getType());
|
||||
wallet.setSortOrder(max == null ? 0 : max + 1); // 같은 타입의 맨 뒤
|
||||
walletMapper.insert(wallet);
|
||||
return WalletResponse.from(wallet, wallet.getOpeningBalance()); // 신규 → 잔액=초기잔액
|
||||
}
|
||||
|
||||
/** 드래그앤드랍 순서 변경: 전달된 id 순서대로 sort_order 재설정 (본인·동일 타입만) */
|
||||
@Transactional
|
||||
public List<WalletResponse> reorderWallets(Long memberId, String type, List<Long> ids) {
|
||||
int i = 0;
|
||||
for (Long id : ids) {
|
||||
Wallet w = walletMapper.findByIdAndMember(id, memberId);
|
||||
if (w != null && w.getType().equals(type)) {
|
||||
walletMapper.updateSortOrder(id, memberId, i++);
|
||||
}
|
||||
}
|
||||
return listWallets(memberId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public WalletResponse updateWallet(Long id, WalletRequest req, Long memberId) {
|
||||
Wallet wallet = mustFindWallet(id, memberId);
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 사용자별 가계부 설정 서비스 (월 예상 수입 등).
|
||||
* 월 예상 수입 설정 서비스 (월별).
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -14,12 +14,12 @@ public class AccountSettingService {
|
||||
|
||||
private final AccountSettingMapper settingMapper;
|
||||
|
||||
public Long getExpectedIncome(Long memberId) {
|
||||
return settingMapper.findExpectedIncome(memberId);
|
||||
public Long getExpectedIncome(Long memberId, int year, int month) {
|
||||
return settingMapper.findExpectedIncome(memberId, year, month);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setExpectedIncome(Long memberId, Long expectedIncome) {
|
||||
settingMapper.upsertExpectedIncome(memberId, expectedIncome);
|
||||
public void setExpectedIncome(Long memberId, int year, int month, Long expectedIncome) {
|
||||
settingMapper.upsertExpectedIncome(memberId, year, month, expectedIncome);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user