- weeklyWalletFlow(월요일 기준 주별 순현금흐름) + netWorthTrendWeekly(기본 13주) - 컨트롤러에 unit=WEEK&weeks=N 지원(기존 월별은 그대로) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
97 lines
4.7 KiB
Java
97 lines
4.7 KiB
Java
package com.sb.web.account.mapper;
|
|
|
|
import com.sb.web.account.domain.AccountEntry;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 가계부 매퍼. 모든 조회/수정은 member_id(소유자)로 격리한다.
|
|
*/
|
|
@Mapper
|
|
public interface AccountEntryMapper {
|
|
|
|
List<AccountEntry> findByMember(@Param("memberId") Long memberId,
|
|
@Param("year") Integer year,
|
|
@Param("month") Integer month,
|
|
@Param("type") String type,
|
|
@Param("category") String category,
|
|
@Param("walletId") Long walletId,
|
|
@Param("keyword") String keyword,
|
|
@Param("tagId") Long tagId);
|
|
|
|
/** 특정 계좌(wallet)와 연관된 내역 (wallet_id 또는 to_wallet_id 가 해당 계좌) */
|
|
List<AccountEntry> findByWalletAndMember(@Param("memberId") Long memberId,
|
|
@Param("walletId") Long walletId);
|
|
|
|
AccountEntry findByIdAndMember(@Param("id") Long id, @Param("memberId") Long memberId);
|
|
|
|
/** 구분(type)별 합계 — {type, total} 행 반환 */
|
|
List<Map<String, Object>> sumByType(@Param("memberId") Long memberId,
|
|
@Param("year") Integer year,
|
|
@Param("month") Integer month);
|
|
|
|
/** 카테고리별 지출 합계 — {category, total} 행 반환 (예산 대비용) */
|
|
List<Map<String, Object>> sumExpenseByCategory(@Param("memberId") Long memberId,
|
|
@Param("year") Integer year,
|
|
@Param("month") Integer month);
|
|
|
|
/** 구분(type)별 분류 합계 — {category, total} 행 반환 (파이차트용) */
|
|
List<Map<String, Object>> sumByCategory(@Param("memberId") Long memberId,
|
|
@Param("type") String type,
|
|
@Param("year") Integer year,
|
|
@Param("month") Integer month);
|
|
|
|
/** 월별 순현금흐름(수입−지출, 계좌 지정분) — {ym, net} 행 반환 (순자산 추이용) */
|
|
List<Map<String, Object>> monthlyWalletFlow(@Param("memberId") Long memberId);
|
|
|
|
/** 주별 순현금흐름(수입−지출, 계좌 지정분) — {wk(=주 월요일 yyyy-MM-dd), net} (주간 순자산 추이용) */
|
|
List<Map<String, Object>> weeklyWalletFlow(@Param("memberId") Long memberId);
|
|
|
|
/** 기간 버킷(일/주/월/년)별 수입·지출 — {bucket, income, expense} (이체 제외) */
|
|
List<Map<String, Object>> statsByPeriod(@Param("memberId") Long memberId,
|
|
@Param("unit") String unit,
|
|
@Param("year") Integer year,
|
|
@Param("month") Integer month);
|
|
|
|
int insert(AccountEntry entry);
|
|
|
|
int update(AccountEntry entry);
|
|
|
|
int delete(@Param("id") Long id, @Param("memberId") Long memberId);
|
|
|
|
/* ----- 알림 자동인식(미확인) ----- */
|
|
/** 중복방지 키로 기존 알림 내역 조회 */
|
|
AccountEntry findByMemberAndNotifKey(@Param("memberId") Long memberId, @Param("notifKey") String notifKey);
|
|
|
|
/** 미확인(확인 필요) 내역 개수 */
|
|
int countPending(@Param("memberId") Long memberId);
|
|
|
|
/** 자동인식 분류 학습: 같은 메모 키워드로 과거에 가장 많이 쓴 분류 1건(없으면 null) */
|
|
String findLearnedCategory(@Param("memberId") Long memberId,
|
|
@Param("type") String type,
|
|
@Param("memo") String memo);
|
|
|
|
/** 미확인 내역 확정 (pending=0, 분류/계좌 보정) */
|
|
int confirm(@Param("id") Long id, @Param("memberId") Long memberId,
|
|
@Param("category") String category, @Param("walletId") Long walletId);
|
|
|
|
/** 기존 내역의 (type별) 사용된 분류명 distinct (분류 불러오기용) */
|
|
List<String> findDistinctCategories(@Param("memberId") Long memberId, @Param("type") String type);
|
|
|
|
/** 분류 이름 변경 시 기존 내역 일괄 갱신 */
|
|
int renameCategory(@Param("memberId") Long memberId,
|
|
@Param("type") String type,
|
|
@Param("oldName") String oldName,
|
|
@Param("newName") String newName);
|
|
|
|
/* ----- 항목-태그 ----- */
|
|
int insertEntryTag(@Param("entryId") Long entryId, @Param("tagId") Long tagId);
|
|
|
|
int deleteEntryTagsByEntryId(@Param("entryId") Long entryId);
|
|
|
|
List<String> findTagNamesByEntryId(@Param("entryId") Long entryId);
|
|
}
|