- board_image 테이블 + BoardImageController/Service/Mapper
· POST /api/board/images(로그인) → {url:/api/images/{id}}
· GET /api/images/{id}(공개, img src 로 로드) — 1년 캐시
- 본문엔 짧은 URL 만 들어가 글이 비대해지지 않음
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -70,6 +70,18 @@ CREATE TABLE IF NOT EXISTS board_setting (
|
||||
|
||||
INSERT IGNORE INTO board_setting (id, tag_category_id) VALUES (1, NULL);
|
||||
|
||||
-- 게시글 인라인 이미지 (DB 저장). 본문에는 /api/images/{id} URL 만 포함(base64 미사용).
|
||||
CREATE TABLE IF NOT EXISTS board_image (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
member_id BIGINT NOT NULL,
|
||||
content_type VARCHAR(100) NOT NULL,
|
||||
data LONGBLOB NOT NULL,
|
||||
byte_size INT NOT NULL DEFAULT 0,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_board_image_member (member_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- 댓글
|
||||
CREATE TABLE IF NOT EXISTS comment (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sb.web.board.mapper.BoardImageMapper">
|
||||
|
||||
<insert id="insert" parameterType="com.sb.web.board.domain.BoardImage"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO board_image (member_id, content_type, data, byte_size, created_at)
|
||||
VALUES (#{memberId}, #{contentType}, #{data}, #{byteSize}, NOW())
|
||||
</insert>
|
||||
|
||||
<select id="findById" resultType="com.sb.web.board.domain.BoardImage">
|
||||
SELECT id, member_id, content_type, data, byte_size, created_at
|
||||
FROM board_image
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user