基础项目
Some checks failed
CI / init (pull_request) Has been cancelled
CI / Frontend node 18.16.0 (pull_request) Has been cancelled
CI / Backend go (1.22) (pull_request) Has been cancelled
CI / release-pr (pull_request) Has been cancelled
CI / devops-test (1.22, 18.16.0) (pull_request) Has been cancelled
CI / release-please (pull_request) Has been cancelled
CI / devops-prod (1.22, 18.x) (pull_request) Has been cancelled
CI / docker (pull_request) Has been cancelled

This commit is contained in:
2026-04-26 15:32:21 +08:00
parent cc40d743cb
commit 1e33640629
102 changed files with 4088 additions and 197 deletions

View File

@@ -0,0 +1,40 @@
-- # 书籍章节表
--
-- ## 基本信息
--
-- 模块book
-- 表名book_chapter
-- 模型model/book/book_chapter.go
-- 迁移接入initialize/gorm_biz.go
-- 删除策略硬删表
-- 职责承载书籍章节发布单元章节文件地址和阅读锚点基础信息保证同一本书内章节编号稳定且唯一
CREATE TABLE book_chapter (
id bigserial PRIMARY KEY,
created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
book_id bigint NOT NULL,
title varchar(255) NOT NULL,
chapter_no integer NOT NULL CHECK (chapter_no > 0),
is_readable boolean NOT NULL DEFAULT false,
content_file_url varchar(500) NOT NULL,
total_lines integer NOT NULL DEFAULT 0 CHECK (total_lines >= 0),
is_enabled boolean NOT NULL DEFAULT true,
CHECK (NOT is_readable OR total_lines > 0)
);
COMMENT ON TABLE book_chapter IS '书籍章节表';
COMMENT ON COLUMN book_chapter.id IS '主键';
COMMENT ON COLUMN book_chapter.created_at IS '创建时间';
COMMENT ON COLUMN book_chapter.updated_at IS '更新时间';
COMMENT ON COLUMN book_chapter.book_id IS '所属书籍 ID';
COMMENT ON COLUMN book_chapter.title IS '章节标题';
COMMENT ON COLUMN book_chapter.chapter_no IS '同书内章节顺序编号';
COMMENT ON COLUMN book_chapter.is_readable IS '是否对 app 端开放阅读';
COMMENT ON COLUMN book_chapter.content_file_url IS '章节内容文件 URL';
COMMENT ON COLUMN book_chapter.total_lines IS '章节正文总行数';
COMMENT ON COLUMN book_chapter.is_enabled IS '章节是否启用';
CREATE UNIQUE INDEX uk_book_chapter_book_id_chapter_no ON book_chapter (book_id, chapter_no);
CREATE INDEX idx_book_chapter_book_id_is_enabled_is_readable ON book_chapter (book_id, is_enabled, is_readable);
CREATE INDEX idx_book_chapter_created_at ON book_chapter (created_at);