feat: 시세 자동조회·퇴직연금 평가액·게시판 카테고리·태그 정렬·계좌번호 암호화
- 투자: 종목코드로 현재가 시세 자동조회(StockQuoteService, 투자탭/포트폴리오 진입 시 갱신) - 투자: 퇴직연금 등 평가액 직접입력형 계좌(currentValue 활성화, manualValuation) - 게시판: community/saving/tips 카테고리 분리(post.category + 목록 필터) - 태그: 순서 변경(account_tag.sort_order, /tags/reorder) - 보안: 계좌번호 AES-256-GCM 암호화 저장/복호화(EncryptedStringTypeHandler, account_number VARCHAR(255)) 키는 서버 .env ACCOUNT_CRYPTO_KEY 로 주입(미설정 시 평문 통과) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -68,6 +68,13 @@ google:
|
||||
vision:
|
||||
api-key: ${GOOGLE_VISION_API_KEY:}
|
||||
|
||||
# ===== 민감 필드 암호화 (계좌번호 등) =====
|
||||
# 키는 서버 /opt/sb-backend/.env 에 ACCOUNT_CRYPTO_KEY=Base64(32바이트) 로 주입 (git 미추적).
|
||||
# 미설정이면 암호화 비활성(평문 저장). 키 분실 시 기존 암호문 복호화 불가하므로 안전하게 보관.
|
||||
app:
|
||||
crypto:
|
||||
account-key: ${ACCOUNT_CRYPTO_KEY:}
|
||||
|
||||
# ===== Logging =====
|
||||
logging:
|
||||
level:
|
||||
|
||||
@@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS wallet (
|
||||
type VARCHAR(10) NOT NULL COMMENT 'BANK / CARD / LOAN / INVEST',
|
||||
name VARCHAR(50) NOT NULL COMMENT '별칭',
|
||||
issuer VARCHAR(50) NULL COMMENT '은행명/카드사/대출기관/증권사',
|
||||
account_number VARCHAR(50) NULL COMMENT '계좌번호(BANK)',
|
||||
account_number VARCHAR(255) NULL COMMENT '계좌번호(BANK) — AES-GCM 암호화 저장',
|
||||
card_type VARCHAR(10) NULL COMMENT 'CREDIT / CHECK (CARD)',
|
||||
opening_balance BIGINT NOT NULL DEFAULT 0 COMMENT '초기 잔액(부호있음: 자산+, 부채-)',
|
||||
opening_date DATE NULL COMMENT '초기잔액 기준일',
|
||||
@@ -28,6 +28,8 @@ 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;
|
||||
-- 계좌번호 암호화 저장(AES-GCM, enc: 접두)으로 평문보다 길어져 컬럼 확장 (멱등)
|
||||
ALTER TABLE wallet MODIFY account_number VARCHAR(255) NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS account_entry (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
@@ -62,11 +64,13 @@ CREATE TABLE IF NOT EXISTS account_tag (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
member_id BIGINT NOT NULL COMMENT '소유자 member.id',
|
||||
name VARCHAR(50) NOT NULL,
|
||||
sort_order INT NOT NULL DEFAULT 0 COMMENT '표시 순서',
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_account_tag_member_name (member_id, name),
|
||||
KEY idx_account_tag_member (member_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
ALTER TABLE account_tag ADD COLUMN IF NOT EXISTS sort_order INT NOT NULL DEFAULT 0;
|
||||
|
||||
-- 정기/반복 거래 규칙 (사용자별)
|
||||
CREATE TABLE IF NOT EXISTS recurring (
|
||||
|
||||
@@ -13,15 +13,19 @@ CREATE TABLE IF NOT EXISTS post (
|
||||
view_count INT NOT NULL DEFAULT 0,
|
||||
blocked TINYINT(1) NOT NULL DEFAULT 0 COMMENT '관리자 열람 제한 여부',
|
||||
block_reason VARCHAR(255) NULL COMMENT '제한 사유',
|
||||
category VARCHAR(30) NOT NULL DEFAULT 'community' COMMENT '게시판 구분: community/saving/tips',
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_post_created (created_at)
|
||||
KEY idx_post_created (created_at),
|
||||
KEY idx_post_category (category, id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 기존 post 테이블에 컬럼 추가 (멱등)
|
||||
ALTER TABLE post ADD COLUMN IF NOT EXISTS blocked TINYINT(1) NOT NULL DEFAULT 0;
|
||||
ALTER TABLE post ADD COLUMN IF NOT EXISTS block_reason VARCHAR(255) NULL;
|
||||
-- 게시판 구분(커뮤니티/짠테크 수다방/재테크 팁). 기존 글은 community 로 이전 (멱등)
|
||||
ALTER TABLE post ADD COLUMN IF NOT EXISTS category VARCHAR(30) NOT NULL DEFAULT 'community';
|
||||
-- 큰 이미지(base64 인라인) 수용을 위해 content 를 LONGTEXT 로 확대 (멱등)
|
||||
ALTER TABLE post MODIFY content LONGTEXT NOT NULL;
|
||||
|
||||
|
||||
@@ -7,18 +7,19 @@
|
||||
<id property="id" column="id"/>
|
||||
<result property="memberId" column="member_id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="sortOrder" column="sort_order"/>
|
||||
<result property="createdAt" column="created_at"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="findByMember" parameterType="long" resultMap="tagResultMap">
|
||||
SELECT id, member_id, name, created_at
|
||||
SELECT id, member_id, name, sort_order, created_at
|
||||
FROM account_tag
|
||||
WHERE member_id = #{memberId}
|
||||
ORDER BY name
|
||||
ORDER BY sort_order, name
|
||||
</select>
|
||||
|
||||
<select id="findByIdAndMember" resultMap="tagResultMap">
|
||||
SELECT id, member_id, name, created_at
|
||||
SELECT id, member_id, name, sort_order, created_at
|
||||
FROM account_tag
|
||||
WHERE id = #{id} AND member_id = #{memberId}
|
||||
</select>
|
||||
@@ -31,8 +32,8 @@
|
||||
|
||||
<insert id="insert" parameterType="com.sb.web.account.domain.AccountTag"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO account_tag (member_id, name, created_at)
|
||||
VALUES (#{memberId}, #{name}, NOW())
|
||||
INSERT INTO account_tag (member_id, name, sort_order, created_at)
|
||||
VALUES (#{memberId}, #{name}, COALESCE(#{sortOrder}, 0), NOW())
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.sb.web.account.domain.AccountTag">
|
||||
@@ -40,6 +41,15 @@
|
||||
WHERE id = #{id} AND member_id = #{memberId}
|
||||
</update>
|
||||
|
||||
<update id="updateSortOrder">
|
||||
UPDATE account_tag SET sort_order = #{sortOrder}
|
||||
WHERE id = #{id} AND member_id = #{memberId}
|
||||
</update>
|
||||
|
||||
<select id="maxSortOrder" resultType="java.lang.Integer">
|
||||
SELECT MAX(sort_order) FROM account_tag WHERE member_id = #{memberId}
|
||||
</select>
|
||||
|
||||
<delete id="delete">
|
||||
DELETE FROM account_tag WHERE id = #{id} AND member_id = #{memberId}
|
||||
</delete>
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
JOIN tag t ON t.id = pt.tag_id
|
||||
</if>
|
||||
<where>
|
||||
<if test="category != null and category != ''">
|
||||
AND p.category = #{category}
|
||||
</if>
|
||||
<if test="tag != null and tag != ''">
|
||||
t.name = #{tag}
|
||||
AND t.name = #{tag}
|
||||
</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
<choose>
|
||||
@@ -48,15 +51,15 @@
|
||||
|
||||
<select id="findById" parameterType="long" resultType="com.sb.web.board.domain.Post">
|
||||
SELECT id, title, content, author_id, author_name, view_count,
|
||||
blocked, block_reason, created_at, updated_at
|
||||
blocked, block_reason, category, created_at, updated_at
|
||||
FROM post
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.sb.web.board.domain.Post"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO post (title, content, author_id, author_name, view_count, created_at, updated_at)
|
||||
VALUES (#{title}, #{content}, #{authorId}, #{authorName}, 0, NOW(), NOW())
|
||||
INSERT INTO post (title, content, author_id, author_name, view_count, category, created_at, updated_at)
|
||||
VALUES (#{title}, #{content}, #{authorId}, #{authorName}, 0, #{category}, NOW(), NOW())
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.sb.web.board.domain.Post">
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<result property="type" column="type"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="issuer" column="issuer"/>
|
||||
<result property="accountNumber" column="account_number"/>
|
||||
<result property="accountNumber" column="account_number"
|
||||
typeHandler="com.sb.web.common.crypto.EncryptedStringTypeHandler"/>
|
||||
<result property="cardType" column="card_type"/>
|
||||
<result property="openingBalance" column="opening_balance"/>
|
||||
<result property="openingDate" column="opening_date"/>
|
||||
@@ -37,14 +38,16 @@
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO wallet (member_id, type, name, issuer, account_number, card_type,
|
||||
opening_balance, opening_date, current_value, sort_order, created_at, updated_at)
|
||||
VALUES (#{memberId}, #{type}, #{name}, #{issuer}, #{accountNumber}, #{cardType},
|
||||
VALUES (#{memberId}, #{type}, #{name}, #{issuer},
|
||||
#{accountNumber, typeHandler=com.sb.web.common.crypto.EncryptedStringTypeHandler}, #{cardType},
|
||||
#{openingBalance}, #{openingDate}, #{currentValue}, #{sortOrder}, NOW(), NOW())
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.sb.web.account.domain.Wallet">
|
||||
UPDATE wallet
|
||||
SET type = #{type}, name = #{name}, issuer = #{issuer},
|
||||
account_number = #{accountNumber}, card_type = #{cardType},
|
||||
account_number = #{accountNumber, typeHandler=com.sb.web.common.crypto.EncryptedStringTypeHandler},
|
||||
card_type = #{cardType},
|
||||
opening_balance = #{openingBalance}, opening_date = #{openingDate},
|
||||
current_value = #{currentValue}
|
||||
WHERE id = #{id} AND member_id = #{memberId}
|
||||
|
||||
Reference in New Issue
Block a user