Compare commits

..

60 Commits

Author SHA1 Message Date
ByungCheol 3535c2e220 Merge branch 'dev'
Deploy / deploy (push) Failing after 12m21s
2026-06-30 21:37:07 +09:00
ByungCheol 204c5ce430 Merge branch 'dev'
Deploy / deploy (push) Failing after 13m50s
2026-06-28 18:25:50 +09:00
ByungCheol 706deb057e Merge branch 'dev'
Deploy / deploy (push) Successful in 53s
2026-06-28 18:16:58 +09:00
ByungCheol e5d1b5d40c Merge branch 'dev'
Deploy / deploy (push) Failing after 14m27s
2026-06-28 18:05:13 +09:00
ByungCheol d028d957b6 Merge branch 'dev'
Deploy / deploy (push) Failing after 15m25s
2026-06-28 17:29:17 +09:00
ByungCheol f28ecd853e Merge branch 'dev'
Deploy / deploy (push) Failing after 13m16s
2026-06-28 16:56:25 +09:00
ByungCheol 5fec464f90 Merge branch 'dev'
Deploy / deploy (push) Failing after 15m19s
2026-06-28 16:04:22 +09:00
ByungCheol 483aaa6473 Merge branch 'dev'
Deploy / deploy (push) Failing after 15m15s
2026-06-28 15:44:26 +09:00
ByungCheol 5bd2616de9 Merge branch 'dev'
Deploy / deploy (push) Failing after 15m28s
2026-06-28 15:24:13 +09:00
ByungCheol ad40af18b2 Merge branch 'dev'
Deploy / deploy (push) Failing after 11m55s
2026-06-28 15:12:47 +09:00
ByungCheol 95d84c8138 Merge branch 'dev'
Deploy / deploy (push) Failing after 15m14s
2026-06-28 14:44:25 +09:00
ByungCheol 08338d516f Merge branch 'dev'
Deploy / deploy (push) Failing after 14m43s
2026-06-28 14:05:01 +09:00
ByungCheol dc4e99a6db Merge branch 'dev'
Deploy / deploy (push) Failing after 15m22s
2026-06-28 13:34:21 +09:00
ByungCheol f408715e17 Merge branch 'dev'
Deploy / deploy (push) Failing after 13m19s
2026-06-28 13:21:21 +09:00
ByungCheol 74a2cae9ef Merge branch 'dev'
Deploy / deploy (push) Failing after 15m11s
2026-06-28 12:29:27 +09:00
ByungCheol 6e269888c2 Merge branch 'dev'
Deploy / deploy (push) Failing after 11m49s
2026-06-28 11:07:51 +09:00
ByungCheol 39a11d299c Merge branch 'dev'
Deploy / deploy (push) Failing after 11m53s
2026-06-28 09:22:46 +09:00
ByungCheol f19f653715 Merge branch 'dev'
Deploy / deploy (push) Failing after 13m31s
CI / build (push) Failing after 15m20s
2026-06-28 09:04:22 +09:00
ByungCheol 16ddf88de3 Merge branch 'dev'
Deploy / deploy (push) Failing after 14m0s
CI / build (push) Failing after 15m50s
2026-06-28 08:38:52 +09:00
ByungCheol d794549f66 Merge branch 'dev'
Deploy / deploy (push) Failing after 12m43s
CI / build (push) Failing after 14m31s
2026-06-27 23:00:14 +09:00
ByungCheol 0e26237577 Merge branch 'dev'
CI / build (push) Failing after 12m28s
Deploy / deploy (push) Failing after 15m38s
2026-06-27 22:27:13 +09:00
ByungCheol 1646ec0a7f Merge branch 'dev'
Deploy / deploy (push) Failing after 11m22s
CI / build (push) Failing after 13m9s
2026-06-27 19:02:12 +09:00
ByungCheol fe0837cfd6 Merge branch 'dev'
Deploy / deploy (push) Successful in 50s
CI / build (push) Failing after 12m12s
2026-06-27 18:03:44 +09:00
ByungCheol 68f6c985bc Merge branch 'dev'
Deploy / deploy (push) Failing after 12m4s
CI / build (push) Failing after 14m3s
2026-06-27 14:47:00 +09:00
ByungCheol 47a01356a5 Merge branch 'dev'
CI / build (push) Failing after 12m36s
Deploy / deploy (push) Failing after 15m41s
2026-06-24 23:03:38 +09:00
ByungCheol 236332637a Merge branch 'dev'
Deploy / deploy (push) Failing after 13m31s
CI / build (push) Failing after 15m21s
2026-06-22 23:16:03 +09:00
ByungCheol 0e71e7b8cc Merge branch 'dev'
Deploy / deploy (push) Failing after 11m25s
CI / build (push) Failing after 13m19s
2026-06-22 22:38:06 +09:00
ByungCheol 9d4a415f2e Merge branch 'dev'
Deploy / deploy (push) Successful in 51s
CI / build (push) Failing after 12m48s
2026-06-20 17:13:14 +09:00
ByungCheol 5230ba1587 Merge branch 'dev'
Deploy / deploy (push) Failing after 11m6s
CI / build (push) Failing after 13m0s
2026-06-14 15:43:30 +09:00
ByungCheol 1f8b968588 Merge branch 'dev'
Deploy / deploy (push) Failing after 11m55s
CI / build (push) Failing after 13m43s
2026-06-12 22:52:23 +09:00
ByungCheol b90f9ea3b8 Merge branch 'dev'
Deploy / deploy (push) Failing after 11m21s
CI / build (push) Failing after 13m9s
2026-06-12 22:22:59 +09:00
ByungCheol a61700bdf6 Merge branch 'dev'
Deploy / deploy (push) Failing after 13m5s
CI / build (push) Failing after 14m58s
2026-06-12 22:16:09 +09:00
ByungCheol 484732c5ed Merge branch 'dev'
Deploy / deploy (push) Failing after 11m54s
CI / build (push) Failing after 13m49s
2026-06-09 22:47:32 +09:00
ByungCheol e3a24848bc Merge branch 'dev'
Deploy / deploy (push) Failing after 12m3s
CI / build (push) Failing after 13m52s
2026-06-07 20:32:38 +09:00
ByungCheol fd25968d0e Merge branch 'dev'
Deploy / deploy (push) Failing after 12m12s
CI / build (push) Failing after 14m4s
2026-06-07 19:17:25 +09:00
ByungCheol c61cec6dad Merge branch 'dev'
Deploy / deploy (push) Failing after 11m5s
CI / build (push) Failing after 12m55s
2026-06-06 17:33:33 +09:00
ByungCheol 2eef5c3b3e Merge branch 'dev'
Deploy / deploy (push) Failing after 11m56s
CI / build (push) Failing after 13m46s
2026-06-06 16:42:34 +09:00
ByungCheol 4f8ade5ff3 Merge branch 'dev'
CI / build (push) Failing after 12m27s
Deploy / deploy (push) Failing after 15m41s
2026-06-06 15:03:53 +09:00
ByungCheol 8bfe596f4e Merge branch 'dev'
CI / build (push) Failing after 11m31s
Deploy / deploy (push) Failing after 14m44s
2026-06-06 14:49:48 +09:00
ByungCheol 76bbf195df Merge branch 'dev'
Deploy / deploy (push) Failing after 12m0s
CI / build (push) Failing after 13m45s
2026-06-06 14:27:33 +09:00
ByungCheol b62b51b789 Merge branch 'dev'
Deploy / deploy (push) Failing after 12m22s
CI / build (push) Failing after 14m11s
2026-06-06 14:14:15 +09:00
ByungCheol 91cc5558e4 Merge branch 'dev'
Deploy / deploy (push) Failing after 11m20s
CI / build (push) Failing after 13m8s
2026-06-06 14:08:13 +09:00
ByungCheol 27b8829def Merge branch 'dev'
Deploy / deploy (push) Failing after 11m29s
CI / build (push) Failing after 13m15s
2026-06-06 08:13:03 +09:00
ByungCheol ad2ee4e75d Merge branch 'dev'
Deploy / deploy (push) Failing after 13m1s
CI / build (push) Failing after 14m52s
2026-06-06 00:16:30 +09:00
ByungCheol eb24a315d3 Merge branch 'dev'
CI / build (push) Failing after 11m1s
Deploy / deploy (push) Failing after 14m15s
2026-06-04 05:00:27 +09:00
ByungCheol 396e986792 Merge branch 'dev'
Deploy / deploy (push) Failing after 11m21s
CI / build (push) Failing after 13m3s
2026-06-03 18:51:32 +09:00
ByungCheol 191f1cfbe4 Merge branch 'dev'
CI / build (push) Failing after 12m15s
Deploy / deploy (push) Failing after 15m32s
2026-06-03 17:37:20 +09:00
ByungCheol 1d4dbc2183 Merge branch 'dev'
CI / build (push) Failing after 12m10s
Deploy / deploy (push) Failing after 15m27s
2026-06-03 16:42:22 +09:00
ByungCheol 478a75b6d8 Merge branch 'dev' into main
Deploy / deploy (push) Failing after 13m38s
CI / build (push) Failing after 15m20s
2026-06-01 22:54:25 +09:00
ByungCheol 41a5780e14 Merge branch 'dev' into main
CI / build (push) Successful in 50s
Deploy / deploy (push) Failing after 15m16s
2026-06-01 22:37:43 +09:00
ByungCheol 86c56f6c6f Merge branch 'dev' into main
Deploy / deploy (push) Failing after 11m36s
CI / build (push) Failing after 13m18s
2026-05-31 21:46:30 +09:00
ByungCheol bd1164866c Merge branch 'dev' into main
Deploy / deploy (push) Failing after 13m16s
CI / build (push) Failing after 14m57s
2026-05-31 20:49:52 +09:00
ByungCheol f884cb7b06 Merge branch 'dev' into main
CI / build (push) Failing after 11m54s
Deploy / deploy (push) Failing after 15m13s
2026-05-31 19:12:56 +09:00
ByungCheol e5fd31843a Merge branch 'dev' into main
Deploy / deploy (push) Failing after 11m27s
CI / build (push) Failing after 13m7s
2026-05-31 19:01:43 +09:00
ByungCheol a821cd8f89 Merge branch 'dev' into main
Deploy / deploy (push) Failing after 11m24s
CI / build (push) Failing after 13m6s
2026-05-31 18:46:44 +09:00
ByungCheol cf275fabf6 Merge branch 'dev' into main
CI / build (push) Failing after 11m53s
Deploy / deploy (push) Failing after 15m12s
2026-05-31 18:22:53 +09:00
ByungCheol d373e3e9e4 Merge branch 'dev' into main
Deploy / deploy (push) Has been cancelled
CI / build (push) Has been cancelled
fix(ci): SSH 개인키 CR 제거
2026-05-31 17:40:10 +09:00
ByungCheol f79c2412fd Merge branch 'dev' into main
Deploy / deploy (push) Has been cancelled
CI / build (push) Has been cancelled
ci: 자동 배포 워크플로 + 서버 설정 파일
2026-05-31 15:55:35 +09:00
ByungCheol f3230dcc5b Merge branch 'dev' into main
CI / build (push) Failing after 12m12s
ci: Gitea Actions CI/CD 워크플로 추가
2026-05-31 15:49:08 +09:00
ByungCheol ef7d0f7f83 Merge branch 'dev' into main
가계부·게시판 백엔드 API 구현 (account/auth/board/user/admin)
2026-05-31 15:45:25 +09:00
12 changed files with 23 additions and 158 deletions
@@ -50,22 +50,8 @@ public class BudgetController {
@GetMapping
public List<BudgetResponse> list(
@RequestParam int year,
@RequestParam int month,
@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
return budgetService.list(current.getId(), year, month);
}
/** 다른 월의 예산을 이 달로 복사(전월 복사 등). 같은 분류는 덮어씀 */
@PostMapping("/copy")
public List<BudgetResponse> copy(
@RequestParam int fromYear,
@RequestParam int fromMonth,
@RequestParam int toYear,
@RequestParam int toMonth,
@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
budgetService.copy(current.getId(), fromYear, fromMonth, toYear, toMonth);
return budgetService.list(current.getId(), toYear, toMonth);
return budgetService.list(current.getId());
}
@GetMapping("/status")
@@ -88,11 +74,9 @@ public class BudgetController {
@PostMapping
public ResponseEntity<BudgetResponse> create(
@RequestParam int year,
@RequestParam int month,
@Valid @RequestBody BudgetRequest req,
@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
return ResponseEntity.status(HttpStatus.CREATED).body(budgetService.create(req, current.getId(), year, month));
return ResponseEntity.status(HttpStatus.CREATED).body(budgetService.create(req, current.getId()));
}
@PutMapping("/{id}")
@@ -28,8 +28,6 @@ public class Budget implements Serializable {
private Long weekly;
private Long monthly;
private Long yearly;
private Integer year; // 예산 연도(월별 예산)
private Integer month; // 예산 월(1~12)
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}
@@ -6,7 +6,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -30,11 +29,6 @@ public class Wallet implements Serializable {
private Long openingBalance; // 초기 잔액(부호있음: 자산+, 부채-)
private LocalDate openingDate;
private Long currentValue; // 현재 평가금액 (INVEST 전용, 수동 갱신)
private Long loanAmount; // 대출 실행 금액(원금, 처음 빌린 금액) (LOAN 전용)
private BigDecimal loanRate; // 연이자율(%) e.g. 5.25 (LOAN 전용)
private String loanMethod; // 상환방식: EQUAL_PAYMENT / EQUAL_PRINCIPAL / BULLET (LOAN 전용)
private Integer loanMonths; // 대출기간(개월) (LOAN 전용)
private LocalDate loanStart; // 대출시작일 (LOAN 전용)
private Integer sortOrder; // 표시 순서 (타입 내 정렬)
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
@@ -1,13 +1,10 @@
package com.sb.web.account.dto;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
@@ -40,17 +37,4 @@ public class WalletRequest {
/** 현재 평가금액 (INVEST 전용, 수동 갱신) */
private Long currentValue;
// ===== 대출(LOAN) 전용 =====
private Long loanAmount; // 대출 실행 금액(원금)
@DecimalMin(value = "0.0", inclusive = true)
@DecimalMax(value = "100.0", message = "이자율은 100% 이하여야 합니다.")
private BigDecimal loanRate; // 연이자율(%)
@Pattern(regexp = "EQUAL_PAYMENT|EQUAL_PRINCIPAL|BULLET|", message = "상환방식이 올바르지 않습니다.")
private String loanMethod; // 상환방식
private Integer loanMonths; // 대출기간(개월)
private LocalDate loanStart; // 대출시작일
}
@@ -4,7 +4,6 @@ import com.sb.web.account.domain.Wallet;
import lombok.Builder;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
@@ -32,13 +31,6 @@ public class WalletResponse {
private Long currentValue; // 평가액 직접입력값(퇴직연금·연금 등 수동 갱신). 있으면 총평가로 사용
private Boolean manualValuation; // true면 평가액 직접입력형(종목 자동계산 대신)
// 대출(LOAN) 전용
private Long loanAmount; // 대출 실행 금액(원금)
private BigDecimal loanRate; // 연이자율(%) e.g. 5.25
private String loanMethod; // EQUAL_PAYMENT / EQUAL_PRINCIPAL / BULLET
private Integer loanMonths; // 대출기간(개월)
private LocalDate loanStart; // 대출시작일
public static WalletResponse from(Wallet w, long balance) {
return WalletResponse.builder()
.id(w.getId())
@@ -51,11 +43,6 @@ public class WalletResponse {
.openingDate(w.getOpeningDate())
.balance(balance)
.currentValue(w.getCurrentValue())
.loanAmount(w.getLoanAmount())
.loanRate(w.getLoanRate())
.loanMethod(w.getLoanMethod())
.loanMonths(w.getLoanMonths())
.loanStart(w.getLoanStart())
.build();
}
}
@@ -12,24 +12,13 @@ import java.util.List;
@Mapper
public interface BudgetMapper {
List<Budget> findByMember(@Param("memberId") Long memberId,
@Param("year") Integer year,
@Param("month") Integer month);
List<Budget> findByMember(@Param("memberId") Long memberId);
Budget findByIdAndMember(@Param("id") Long id, @Param("memberId") Long memberId);
int countByCategory(@Param("memberId") Long memberId,
@Param("category") String category,
@Param("excludeId") Long excludeId,
@Param("year") Integer year,
@Param("month") Integer month);
/** fromYear/fromMonth 예산을 toYear/toMonth 로 복사(같은 분류는 덮어씀). 복사된 건수 반환 */
int copyMonth(@Param("memberId") Long memberId,
@Param("fromYear") Integer fromYear,
@Param("fromMonth") Integer fromMonth,
@Param("toYear") Integer toYear,
@Param("toMonth") Integer toMonth);
@Param("excludeId") Long excludeId);
int insert(Budget budget);
@@ -535,12 +535,6 @@ public class AccountService {
wallet.setOpeningBalance(req.getOpeningBalance() != null ? req.getOpeningBalance() : 0L);
wallet.setOpeningDate(req.getOpeningDate());
wallet.setCurrentValue("INVEST".equals(req.getType()) ? req.getCurrentValue() : null);
boolean isLoan = "LOAN".equals(req.getType());
wallet.setLoanAmount(isLoan ? req.getLoanAmount() : null);
wallet.setLoanRate(isLoan ? req.getLoanRate() : null);
wallet.setLoanMethod(isLoan ? blankToNull(req.getLoanMethod()) : null);
wallet.setLoanMonths(isLoan ? req.getLoanMonths() : null);
wallet.setLoanStart(isLoan ? req.getLoanStart() : null);
walletMapper.update(wallet);
return WalletResponse.from(wallet, balanceMap(memberId).getOrDefault(id, wallet.getOpeningBalance()));
}
@@ -570,7 +564,6 @@ public class AccountService {
}
private Wallet toWallet(WalletRequest req) {
boolean isLoan = "LOAN".equals(req.getType());
return Wallet.builder()
.type(req.getType())
.name(req.getName().trim())
@@ -580,11 +573,6 @@ public class AccountService {
.openingBalance(req.getOpeningBalance() != null ? req.getOpeningBalance() : 0L)
.openingDate(req.getOpeningDate())
.currentValue("INVEST".equals(req.getType()) ? req.getCurrentValue() : null)
.loanAmount(isLoan ? req.getLoanAmount() : null)
.loanRate(isLoan ? req.getLoanRate() : null)
.loanMethod(isLoan ? blankToNull(req.getLoanMethod()) : null)
.loanMonths(isLoan ? req.getLoanMonths() : null)
.loanStart(isLoan ? req.getLoanStart() : null)
.build();
}
@@ -156,12 +156,11 @@ public class BackupService {
}
}
// 7) 예산 — 복구 시 현재 월 예산으로 등록(백업엔 월 정보 없음)
// 7) 예산
if (req.getBudgets() != null) {
java.time.LocalDate today = java.time.LocalDate.now();
for (BudgetRequest b : req.getBudgets()) {
if (b == null || b.getCategory() == null) continue;
budgetService.create(b, memberId, today.getYear(), today.getMonthValue());
budgetService.create(b, memberId);
}
}
@@ -31,46 +31,36 @@ public class BudgetService {
private final BudgetMapper budgetMapper;
private final AccountEntryMapper entryMapper;
public List<BudgetResponse> list(Long memberId, int year, int month) {
return budgetMapper.findByMember(memberId, year, month).stream().map(BudgetResponse::from).toList();
public List<BudgetResponse> list(Long memberId) {
return budgetMapper.findByMember(memberId).stream().map(BudgetResponse::from).toList();
}
@Transactional
public BudgetResponse create(BudgetRequest req, Long memberId, int year, int month) {
public BudgetResponse create(BudgetRequest req, Long memberId) {
String category = req.getCategory().trim();
if (budgetMapper.countByCategory(memberId, category, null, year, month) > 0) {
if (budgetMapper.countByCategory(memberId, category, null) > 0) {
throw new ApiException(HttpStatus.CONFLICT, "이미 예산이 설정된 카테고리입니다.");
}
Budget budget = toBudget(req, category);
budget.setMemberId(memberId);
budget.setYear(year);
budget.setMonth(month);
budgetMapper.insert(budget);
return BudgetResponse.from(budget);
}
@Transactional
public BudgetResponse update(Long id, BudgetRequest req, Long memberId) {
Budget existing = mustFind(id, memberId);
mustFind(id, memberId);
String category = req.getCategory().trim();
if (budgetMapper.countByCategory(memberId, category, id, existing.getYear(), existing.getMonth()) > 0) {
if (budgetMapper.countByCategory(memberId, category, id) > 0) {
throw new ApiException(HttpStatus.CONFLICT, "이미 예산이 설정된 카테고리입니다.");
}
Budget budget = toBudget(req, category);
budget.setId(id);
budget.setMemberId(memberId);
budget.setYear(existing.getYear());
budget.setMonth(existing.getMonth());
budgetMapper.update(budget);
return BudgetResponse.from(budget);
}
/** fromYear/fromMonth 예산을 toYear/toMonth 로 복사(같은 분류 덮어씀). 복사된 건수 반환 */
@Transactional
public int copy(Long memberId, int fromYear, int fromMonth, int toYear, int toMonth) {
return budgetMapper.copyMonth(memberId, fromYear, fromMonth, toYear, toMonth);
}
@Transactional
public void delete(Long id, Long memberId) {
mustFind(id, memberId);
@@ -89,7 +79,7 @@ public class BudgetService {
}
List<BudgetStatus> result = new ArrayList<>();
for (Budget b : budgetMapper.findByMember(memberId, year, month)) {
for (Budget b : budgetMapper.findByMember(memberId)) {
long monthlyBudget = monthlyBudget(b, daysInMonth);
long spent = spentByCategory.getOrDefault(b.getCategory(), 0L);
result.add(BudgetStatus.builder()
@@ -113,8 +103,7 @@ public class BudgetService {
int y = year != null ? year : Year.now().getValue();
int m = month != null ? month : 1;
// 기간 차트는 선택 월의 예산을 기준으로 각 버킷에 적용(월별 예산 도입 전 동작과 동일)
List<Budget> budgets = budgetMapper.findByMember(memberId, y, m);
List<Budget> budgets = budgetMapper.findByMember(memberId);
Map<String, Long> expense = new HashMap<>();
for (Map<String, Object> row : entryMapper.statsByPeriod(memberId, unit, year, month)) {
expense.put(String.valueOf(((Number) row.get("bucket")).longValue()),
-14
View File
@@ -28,11 +28,6 @@ ALTER TABLE wallet ADD COLUMN IF NOT EXISTS opening_balance BIGINT NOT NULL DEFA
ALTER TABLE wallet ADD COLUMN IF NOT EXISTS opening_date DATE NULL;
ALTER TABLE wallet ADD COLUMN IF NOT EXISTS current_value BIGINT NULL;
ALTER TABLE wallet ADD COLUMN IF NOT EXISTS sort_order INT NOT NULL DEFAULT 0;
ALTER TABLE wallet ADD COLUMN IF NOT EXISTS loan_rate DECIMAL(7,4) NULL COMMENT '연이자율(%) 예: 5.2500';
ALTER TABLE wallet ADD COLUMN IF NOT EXISTS loan_method VARCHAR(20) NULL COMMENT '상환방식: EQUAL_PAYMENT/EQUAL_PRINCIPAL/BULLET';
ALTER TABLE wallet ADD COLUMN IF NOT EXISTS loan_months INT NULL COMMENT '대출기간(개월)';
ALTER TABLE wallet ADD COLUMN IF NOT EXISTS loan_start DATE NULL COMMENT '대출시작일';
ALTER TABLE wallet ADD COLUMN IF NOT EXISTS loan_amount BIGINT NULL COMMENT '대출 실행 금액(원금, 처음 빌린 금액)';
-- 계좌번호 암호화 저장(AES-GCM)으로 평문보다 길어 VARCHAR(255) 필요 — 운영 적용 완료(CREATE TABLE 정의에 반영).
-- 매 기동 MODIFY 는 라이브 테이블 락 위험이 있어 제거. 기존 환경 확장이 필요하면 1회 수동 적용:
-- ALTER TABLE wallet MODIFY account_number VARCHAR(255) NULL;
@@ -170,15 +165,6 @@ CREATE TABLE IF NOT EXISTS budget (
UNIQUE KEY uk_budget_member_category (member_id, category)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- 월별 예산: 예산을 연/월별로 분리(전월 복사로 다음 달에 동일 예산 저장 가능).
ALTER TABLE budget ADD COLUMN IF NOT EXISTS `year` INT NULL COMMENT '예산 연도';
ALTER TABLE budget ADD COLUMN IF NOT EXISTS `month` INT NULL COMMENT '예산 월(1~12)';
-- 기존 상시 예산을 현재 연/월로 1회 이관
UPDATE budget SET `year` = YEAR(NOW()), `month` = MONTH(NOW()) WHERE `year` IS NULL OR `month` IS NULL;
-- 분류 유니크를 (member,category) → (member,category,year,month) 로 교체
ALTER TABLE budget DROP INDEX IF EXISTS uk_budget_member_category;
ALTER TABLE budget ADD UNIQUE KEY IF NOT EXISTS uk_budget_member_cat_ym (member_id, category, `year`, `month`);
-- 가계부 항목 - 태그 (다대다, tag_id 는 account_tag.id 참조)
CREATE TABLE IF NOT EXISTS account_entry_tag (
entry_id BIGINT NOT NULL,
+5 -24
View File
@@ -14,19 +14,15 @@
<result property="weekly" column="weekly"/>
<result property="monthly" column="monthly"/>
<result property="yearly" column="yearly"/>
<result property="year" column="year"/>
<result property="month" column="month"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
</resultMap>
<sql id="cols">id, member_id, category, fixed, base_unit, base_amount,
daily, weekly, monthly, yearly, `year`, `month`, created_at, updated_at</sql>
daily, weekly, monthly, yearly, created_at, updated_at</sql>
<select id="findByMember" resultMap="budgetResultMap">
SELECT <include refid="cols"/> FROM budget
WHERE member_id = #{memberId} AND `year` = #{year} AND `month` = #{month}
ORDER BY category
<select id="findByMember" parameterType="long" resultMap="budgetResultMap">
SELECT <include refid="cols"/> FROM budget WHERE member_id = #{memberId} ORDER BY category
</select>
<select id="findByIdAndMember" resultMap="budgetResultMap">
@@ -36,30 +32,15 @@
<select id="countByCategory" resultType="int">
SELECT COUNT(*) FROM budget
WHERE member_id = #{memberId} AND category = #{category}
AND `year` = #{year} AND `month` = #{month}
<if test="excludeId != null">AND id != #{excludeId}</if>
</select>
<insert id="insert" parameterType="com.sb.web.account.domain.Budget"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO budget (member_id, category, fixed, base_unit, base_amount,
daily, weekly, monthly, yearly, `year`, `month`, created_at, updated_at)
daily, weekly, monthly, yearly, created_at, updated_at)
VALUES (#{memberId}, #{category}, #{fixed}, #{baseUnit}, #{baseAmount},
#{daily}, #{weekly}, #{monthly}, #{yearly}, #{year}, #{month}, NOW(), NOW())
</insert>
<!-- 전월(또는 임의 월) 예산을 다른 월로 복사. 같은 분류는 덮어씀(ON DUPLICATE) -->
<insert id="copyMonth">
INSERT INTO budget (member_id, category, fixed, base_unit, base_amount,
daily, weekly, monthly, yearly, `year`, `month`, created_at, updated_at)
SELECT member_id, category, fixed, base_unit, base_amount,
daily, weekly, monthly, yearly, #{toYear}, #{toMonth}, NOW(), NOW()
FROM budget
WHERE member_id = #{memberId} AND `year` = #{fromYear} AND `month` = #{fromMonth}
ON DUPLICATE KEY UPDATE
fixed = VALUES(fixed), base_unit = VALUES(base_unit), base_amount = VALUES(base_amount),
daily = VALUES(daily), weekly = VALUES(weekly), monthly = VALUES(monthly),
yearly = VALUES(yearly), updated_at = NOW()
#{daily}, #{weekly}, #{monthly}, #{yearly}, NOW(), NOW())
</insert>
<update id="update" parameterType="com.sb.web.account.domain.Budget">
+4 -18
View File
@@ -15,20 +15,13 @@
<result property="openingBalance" column="opening_balance"/>
<result property="openingDate" column="opening_date"/>
<result property="currentValue" column="current_value"/>
<result property="loanAmount" column="loan_amount"/>
<result property="loanRate" column="loan_rate"/>
<result property="loanMethod" column="loan_method"/>
<result property="loanMonths" column="loan_months"/>
<result property="loanStart" column="loan_start"/>
<result property="sortOrder" column="sort_order"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
</resultMap>
<sql id="cols">id, member_id, type, name, issuer, account_number, card_type,
opening_balance, opening_date, current_value,
loan_amount, loan_rate, loan_method, loan_months, loan_start,
sort_order, created_at, updated_at</sql>
opening_balance, opening_date, current_value, sort_order, created_at, updated_at</sql>
<select id="findByMember" parameterType="long" resultMap="walletResultMap">
SELECT <include refid="cols"/> FROM wallet
@@ -44,14 +37,10 @@
<insert id="insert" parameterType="com.sb.web.account.domain.Wallet"
useGeneratedKeys="true" keyProperty="id">
INSERT INTO wallet (member_id, type, name, issuer, account_number, card_type,
opening_balance, opening_date, current_value,
loan_amount, loan_rate, loan_method, loan_months, loan_start,
sort_order, created_at, updated_at)
opening_balance, opening_date, current_value, sort_order, created_at, updated_at)
VALUES (#{memberId}, #{type}, #{name}, #{issuer},
#{accountNumber, typeHandler=com.sb.web.common.crypto.EncryptedStringTypeHandler}, #{cardType},
#{openingBalance}, #{openingDate}, #{currentValue},
#{loanAmount}, #{loanRate}, #{loanMethod}, #{loanMonths}, #{loanStart},
#{sortOrder}, NOW(), NOW())
#{openingBalance}, #{openingDate}, #{currentValue}, #{sortOrder}, NOW(), NOW())
</insert>
<update id="update" parameterType="com.sb.web.account.domain.Wallet">
@@ -60,10 +49,7 @@
account_number = #{accountNumber, typeHandler=com.sb.web.common.crypto.EncryptedStringTypeHandler},
card_type = #{cardType},
opening_balance = #{openingBalance}, opening_date = #{openingDate},
current_value = #{currentValue},
loan_amount = #{loanAmount},
loan_rate = #{loanRate}, loan_method = #{loanMethod},
loan_months = #{loanMonths}, loan_start = #{loanStart}
current_value = #{currentValue}
WHERE id = #{id} AND member_id = #{memberId}
</update>