Files
novel_server/novel.sql
2025-07-16 15:16:40 +08:00

504 lines
43 KiB
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
Navicat Premium Dump SQL
Source Server : Mac
Source Server Type : MySQL
Source Server Version : 80041 (8.0.41)
Source Host : localhost:3306
Source Schema : novel
Target Server Type : MySQL
Target Server Version : 80041 (8.0.41)
File Encoding : 65001
Date: 16/07/2025 09:37:05
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for admins
-- ----------------------------
DROP TABLE IF EXISTS `admins`;
CREATE TABLE `admins` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '管理员ID',
`username` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '管理员用户名',
`password_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码哈希',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
`deleted_at` timestamp NULL DEFAULT NULL COMMENT '软删除时间戳',
PRIMARY KEY (`id`),
KEY `idx_username_deleted` (`username`,`deleted_at`),
KEY `idx_email_deleted` (`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='系统管理员表';
-- ----------------------------
-- Records of admins
-- ----------------------------
BEGIN;
INSERT INTO `admins` (`id`, `username`, `password_hash`, `created_at`, `updated_at`, `deleted_at`) VALUES (1, 'admin', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', '2025-07-09 13:40:54', '2025-07-09 13:40:54', NULL);
COMMIT;
-- ----------------------------
-- Table structure for authors
-- ----------------------------
DROP TABLE IF EXISTS `authors`;
CREATE TABLE `authors` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '作者ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`pen_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '笔名',
`bio` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '作者简介',
`status` tinyint NOT NULL DEFAULT '1' COMMENT '状态1=正常2=禁用',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
`deleted_at` timestamp NULL DEFAULT NULL COMMENT '软删除时间戳',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_id` (`user_id`),
KEY `idx_status` (`status`),
CONSTRAINT `fk_authors_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='作者表';
-- ----------------------------
-- Records of authors
-- ----------------------------
BEGIN;
INSERT INTO `authors` (`id`, `user_id`, `pen_name`, `bio`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES (1, 6, 'MoonScribe', 'A fantasy writer crafting magical worlds and epic quests.', 1, '2023-01-11 09:30:00', '2025-07-10 14:00:00', NULL);
INSERT INTO `authors` (`id`, `user_id`, `pen_name`, `bio`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES (2, 7, 'NebulaTale', 'Sci-fi author exploring interstellar adventures and cosmic mysteries.', 1, '2023-03-16 12:00:00', '2025-06-25 10:15:00', NULL);
INSERT INTO `authors` (`id`, `user_id`, `pen_name`, `bio`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES (3, 8, 'MistWalker', 'Mystery novelist weaving intricate plots in shadowy settings.', 1, '2023-05-21 14:00:00', '2025-05-10 16:20:00', NULL);
INSERT INTO `authors` (`id`, `user_id`, `pen_name`, `bio`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES (4, 9, 'LegendWeaver', 'Epic storyteller inspired by ancient myths and heroic sagas.', 1, '2023-07-26 10:30:00', '2025-07-01 12:30:00', NULL);
INSERT INTO `authors` (`id`, `user_id`, `pen_name`, `bio`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES (5, 10, 'StarBloom', 'Romantic writer penning heartfelt stories under the stars.', 1, '2023-09-11 15:30:00', NULL, NULL);
INSERT INTO `authors` (`id`, `user_id`, `pen_name`, `bio`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES (6, 11, 'NightShade', 'Thriller and horror author delving into the darkest corners of the mind.', 2, '2023-11-06 09:00:00', '2025-06-15 09:00:00', '2025-07-05 11:00:00');
COMMIT;
-- ----------------------------
-- Table structure for book_ratings
-- ----------------------------
DROP TABLE IF EXISTS `book_ratings`;
CREATE TABLE `book_ratings` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '评分ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`book_id` bigint NOT NULL COMMENT '小说ID',
`score` decimal(4,2) NOT NULL COMMENT '评分0~10',
`comment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '用户评论',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_book` (`user_id`,`book_id`),
KEY `idx_book_id` (`book_id`),
CONSTRAINT `fk_book_ratings_book_id` FOREIGN KEY (`book_id`) REFERENCES `books` (`id`),
CONSTRAINT `fk_book_ratings_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='小说评分与评论表';
-- ----------------------------
-- Records of book_ratings
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for books
-- ----------------------------
DROP TABLE IF EXISTS `books`;
CREATE TABLE `books` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '小说ID',
`author_id` bigint NOT NULL COMMENT '作者ID',
`category_id` bigint NOT NULL COMMENT '分类ID',
`title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '小说标题',
`cover_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '封面图片URL',
`description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '小说简介',
`status` tinyint NOT NULL DEFAULT '1' COMMENT '状态1=连载中2=完结3=下架',
`words_count` int DEFAULT '0' COMMENT '字数',
`chapters_count` int DEFAULT '0' COMMENT '章节数',
`rating` decimal(4,2) DEFAULT '0.00' COMMENT '评分0.00~10.00',
`read_count` bigint DEFAULT '0' COMMENT '阅读人数',
`current_readers` bigint DEFAULT '0' COMMENT '在读人数',
`tags` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '标签(逗号分隔)',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
`deleted_at` timestamp NULL DEFAULT NULL COMMENT '软删除时间戳',
`is_recommended` tinyint NOT NULL DEFAULT '0' COMMENT '是否推荐0=否1=是',
`is_featured` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否精选0=否1=是',
`language` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'zh' COMMENT '语言,如 zh=中文en=英文jp=日文',
PRIMARY KEY (`id`),
KEY `idx_author_id` (`author_id`),
KEY `idx_category_id` (`category_id`),
KEY `idx_status` (`status`),
CONSTRAINT `fk_books_author_id` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`),
CONSTRAINT `fk_books_category_id` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='小说表';
-- ----------------------------
-- Records of books
-- ----------------------------
BEGIN;
INSERT INTO `books` (`id`, `author_id`, `category_id`, `title`, `cover_url`, `description`, `status`, `words_count`, `chapters_count`, `rating`, `read_count`, `current_readers`, `tags`, `created_at`, `updated_at`, `deleted_at`, `is_recommended`, `is_featured`, `language`) VALUES (1, 1, 1, 'Echoes of the Lost Realm', 'https://example.com/covers/echoes_realm.jpg', 'A young sorcerer uncovers secrets of a forgotten kingdom.', 1, 160000, 48, 8.60, 13000, 0, 'fantasy,magic,adventure', '2024-02-15 10:00:00', '2025-07-10 12:00:00', NULL, 1, 0, 'en');
INSERT INTO `books` (`id`, `author_id`, `category_id`, `title`, `cover_url`, `description`, `status`, `words_count`, `chapters_count`, `rating`, `read_count`, `current_readers`, `tags`, `created_at`, `updated_at`, `deleted_at`, `is_recommended`, `is_featured`, `language`) VALUES (2, 2, 2, 'Void Wanderers', 'https://example.com/covers/void_wanderers.jpg', 'A crew of explorers navigates uncharted galaxies.', 2, 210000, 62, 9.00, 22000, 0, 'sci-fi,space,exploration', '2023-09-10 11:00:00', '2025-06-20 13:30:00', NULL, 1, 0, 'en');
INSERT INTO `books` (`id`, `author_id`, `category_id`, `title`, `cover_url`, `description`, `status`, `words_count`, `chapters_count`, `rating`, `read_count`, `current_readers`, `tags`, `created_at`, `updated_at`, `deleted_at`, `is_recommended`, `is_featured`, `language`) VALUES (3, 3, 3, 'Shadows of Doubt', 'https://example.com/covers/shadows_doubt.jpg', 'A detective solves a murder in a city shrouded in secrets.', 1, 100000, 32, 8.20, 7000, 0, 'mystery,detective,crime', '2024-05-25 14:00:00', '2025-07-05 09:45:00', NULL, 0, 0, 'en');
INSERT INTO `books` (`id`, `author_id`, `category_id`, `title`, `cover_url`, `description`, `status`, `words_count`, `chapters_count`, `rating`, `read_count`, `current_readers`, `tags`, `created_at`, `updated_at`, `deleted_at`, `is_recommended`, `is_featured`, `language`) VALUES (4, 4, 4, 'The Eternal Saga', 'https://example.com/covers/eternal_saga.jpg', 'Heroes battle to fulfill an ancient prophecy.', 2, 340000, 85, 9.40, 28000, 0, 'epic,fantasy,mythology', '2023-12-01 12:00:00', '2025-07-01 11:15:00', NULL, 1, 0, 'en');
INSERT INTO `books` (`id`, `author_id`, `category_id`, `title`, `cover_url`, `description`, `status`, `words_count`, `chapters_count`, `rating`, `read_count`, `current_readers`, `tags`, `created_at`, `updated_at`, `deleted_at`, `is_recommended`, `is_featured`, `language`) VALUES (5, 5, 5, 'Love Beyond the Stars', 'https://example.com/covers/love_stars.jpg', 'A romance blossoms during an interstellar journey.', 1, 115000, 38, 8.50, 11000, 0, 'romance,sci-fi,drama', '2024-07-15 13:00:00', '2025-07-11 02:00:00', NULL, 0, 0, 'en');
INSERT INTO `books` (`id`, `author_id`, `category_id`, `title`, `cover_url`, `description`, `status`, `words_count`, `chapters_count`, `rating`, `read_count`, `current_readers`, `tags`, `created_at`, `updated_at`, `deleted_at`, `is_recommended`, `is_featured`, `language`) VALUES (6, 6, 7, 'Curse of the Forgotten', NULL, 'A haunted village hides a terrifying secret.', 3, 65000, 18, 6.90, 2500, 0, 'horror,supernatural,mystery', '2024-03-10 16:00:00', '2025-07-11 02:00:00', '2025-07-05 10:00:00', 0, 0, 'en');
INSERT INTO `books` (`id`, `author_id`, `category_id`, `title`, `cover_url`, `description`, `status`, `words_count`, `chapters_count`, `rating`, `read_count`, `current_readers`, `tags`, `created_at`, `updated_at`, `deleted_at`, `is_recommended`, `is_featured`, `language`) VALUES (7, 2, 6, 'Pulse of Danger', 'https://example.com/covers/pulse_danger.jpg', 'A rogue agent uncovers a global conspiracy.', 1, 140000, 40, 8.70, 9500, 0, 'thriller,action,conspiracy', '2024-04-20 09:30:00', '2025-06-30 15:00:00', NULL, 1, 0, 'en');
COMMIT;
-- ----------------------------
-- Table structure for bookshelves
-- ----------------------------
DROP TABLE IF EXISTS `bookshelves`;
CREATE TABLE `bookshelves` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`book_id` bigint NOT NULL COMMENT '小说ID',
`added_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '加入书架时间',
`last_read_chapter_id` bigint DEFAULT NULL COMMENT '最后阅读章节ID',
`last_read_percent` decimal(5,2) DEFAULT '0.00' COMMENT '阅读进度百分比0.00~100.00',
`last_read_at` timestamp NULL DEFAULT NULL COMMENT '最后阅读时间',
`read_status` tinyint NOT NULL DEFAULT '1' COMMENT '阅读状态1=正在读2=已读完3=已收藏',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_book` (`user_id`,`book_id`),
KEY `idx_user_id` (`user_id`),
KEY `idx_book_id` (`book_id`),
CONSTRAINT `fk_bookshelves_book_id` FOREIGN KEY (`book_id`) REFERENCES `books` (`id`),
CONSTRAINT `fk_bookshelves_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户书架表';
-- ----------------------------
-- Records of bookshelves
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for casbin_rule
-- ----------------------------
DROP TABLE IF EXISTS `casbin_rule`;
CREATE TABLE `casbin_rule` (
`id` int NOT NULL AUTO_INCREMENT,
`p_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`v0` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`v1` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`v2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`v3` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`v4` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`v5` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='路由权限表';
-- ----------------------------
-- Records of casbin_rule
-- ----------------------------
BEGIN;
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (1, 'g', 'user', 'guest', '', '', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (2, 'g', 'author', 'user', '', '', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (3, 'g', 'admin', 'author', '', '', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (4, 'p', 'guest', '/book/app/list', 'GET', 'App获取书籍列表', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (5, 'p', 'guest', '/book/app/detail', 'GET', 'App获取书籍详情', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (6, 'p', 'guest', '/chapter/app/list', 'GET', 'App获取章节列表', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (7, 'p', 'guest', '/chapter/app/detail', 'GET', 'App获取章节详情', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (8, 'p', 'guest', '/category', 'GET', '获取分类列表', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (9, 'p', 'user', '/book/shelf/add', 'POST', '加入书架', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (10, 'p', 'user', '/book/shelf/remove', 'POST', '移除书架', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (11, 'p', 'user', '/book/history/add', 'POST', '添加历史记录', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (12, 'p', 'user', '/book/history/remove', 'POST', '删除历史记录', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (13, 'p', 'user', '/book/app/rate', 'POST', 'App用户评分', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (14, 'p', 'user', '/chapter/app/purchase', 'POST', 'App购买章节', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (15, 'p', 'user', '/chapter/app/progress', 'POST', 'App上传阅读进度', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (16, 'p', 'user', '/feedback', 'POST', '新增反馈', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (17, 'p', 'user', '/user/info', 'GET', '获取用户信息', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (18, 'p', 'user', '/user/delete', 'POST', '删除用户', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (19, 'p', 'user', '/user/logout', 'POST', '用户登出', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (20, 'p', 'user', '/author/follow', 'POST', '关注作者', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (21, 'p', 'user', '/author/unfollow', 'POST', '取消关注作者', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (22, 'p', 'author', '/book', 'GET', '获取图书列表', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (23, 'p', 'author', '/book', 'POST', '新增图书', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (24, 'p', 'author', '/book', 'PUT', '编辑图书', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (25, 'p', 'author', '/book', 'DELETE', '删除图书', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (26, 'p', 'author', '/chapter', 'GET', '获取章节列表', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (27, 'p', 'author', '/chapter', 'POST', '创建章节', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (28, 'p', 'author', '/chapter', 'PUT', '更新章节', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (29, 'p', 'author', '/chapter', 'DELETE', '删除章节', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (30, 'p', 'admin', '/author', 'GET', '获取作者列表', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (31, 'p', 'admin', '/author', 'POST', '创建作者', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (32, 'p', 'admin', '/author', 'PUT', '更新作者', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (33, 'p', 'admin', '/author', 'DELETE', '删除作者', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (34, 'p', 'admin', '/feedback', 'GET', '获取反馈列表', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (35, 'p', 'admin', '/category', 'POST', '创建分类', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (36, 'p', 'admin', '/category', 'PUT', '更新分类', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (37, 'p', 'admin', '/category', 'DELETE', '删除分类', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (38, 'p', 'admin', '/admin/info', 'GET', '获取管理员用户信息', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (39, 'p', 'admin', '/admin/editPass', 'POST', '管理员修改密码', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (40, 'p', 'user', '/book/app/my-books', 'GET', '获取我的书籍列表', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (41, 'p', 'admin', '/book/set-featured', 'POST', '设置书籍精选状态', '', '');
INSERT INTO `casbin_rule` (`id`, `p_type`, `v0`, `v1`, `v2`, `v3`, `v4`, `v5`) VALUES (42, 'p', 'admin', '/book/set-recommended', 'POST', '设置书籍推荐状态', '', '');
COMMIT;
-- ----------------------------
-- Table structure for categories
-- ----------------------------
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类ID',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
`deleted_at` timestamp NULL DEFAULT NULL COMMENT '软删除时间戳',
`channel` tinyint(1) NOT NULL DEFAULT '1' COMMENT '频道类型1=男频2=女频',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='小说分类表';
-- ----------------------------
-- Records of categories
-- ----------------------------
BEGIN;
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (1, 'Fantasy', '2023-01-10 09:00:00', '2025-07-10 15:30:00', NULL, 1);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (2, 'Science Fiction', '2023-02-15 10:30:00', '2025-06-20 12:00:00', NULL, 1);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (3, 'Mystery', '2023-03-20 14:00:00', '2025-05-15 09:45:00', NULL, 1);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (4, 'Epic', '2023-04-05 11:15:00', '2025-07-01 16:20:00', NULL, 1);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (5, 'Romance', '2023-05-12 08:45:00', NULL, NULL, 1);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (6, 'Thriller', '2023-06-18 13:20:00', '2025-04-10 10:10:00', NULL, 1);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (8, 'Modern Romance', '2025-07-15 21:00:00', NULL, NULL, 2);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (9, 'Historical Romance', '2025-07-15 21:00:00', NULL, NULL, 2);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (10, 'School Life', '2025-07-15 21:00:00', NULL, NULL, 2);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (11, 'CEO Romance', '2025-07-15 21:00:00', NULL, NULL, 2);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (12, 'Time Travel', '2025-07-15 21:00:00', NULL, NULL, 2);
INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`, `channel`) VALUES (13, 'Fantasy Romance', '2025-07-15 21:00:00', NULL, NULL, 2);
COMMIT;
-- ----------------------------
-- Table structure for chapters
-- ----------------------------
DROP TABLE IF EXISTS `chapters`;
CREATE TABLE `chapters` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '章节ID',
`book_id` bigint NOT NULL COMMENT '小说ID',
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '章节标题',
`content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '章节内容',
`word_count` int DEFAULT '0' COMMENT '章节字数',
`sort` int DEFAULT '0' COMMENT '排序序号',
`is_locked` tinyint NOT NULL DEFAULT '0' COMMENT '是否锁定0=免费1=需积分解锁',
`required_score` int NOT NULL DEFAULT '0' COMMENT '解锁该章节所需积分',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
`deleted_at` timestamp NULL DEFAULT NULL COMMENT '软删除时间戳',
PRIMARY KEY (`id`),
KEY `idx_book_id` (`book_id`),
CONSTRAINT `fk_chapters_book_id` FOREIGN KEY (`book_id`) REFERENCES `books` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='章节表';
-- ----------------------------
-- Records of chapters
-- ----------------------------
BEGIN;
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (1, 1, 'The Fated Dawn', 'Aelar discovers a shimmering crystal in the ruins, pulsing with ancient magic...', 3700, 1, 0, 0, '2024-02-15 10:10:00', '2025-07-11 20:23:43', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (2, 1, 'The Oracles Vision', 'Aelar seeks guidance from a reclusive seer in the enchanted forest...', 4000, 2, 0, 0, '2024-03-05 11:45:00', '2024-03-05 11:45:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (3, 1, 'The Veiled Kingdom', 'Aelar battles a mystical guardian to enter the Lost Realm...', 4200, 3, 1, 70, '2025-07-10 12:00:00', '2025-07-10 12:00:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (4, 2, 'The Cosmic Leap', 'The Starfarer crew prepares for a daring jump into uncharted space...', 4400, 1, 0, 0, '2023-09-10 11:10:00', '2023-09-10 11:10:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (5, 2, 'Anomaly Detected', 'A mysterious signal causes chaos aboard the Starfarer...', 4700, 2, 0, 0, '2023-10-25 12:30:00', '2023-10-25 12:30:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (6, 2, 'The Starborn Legacy', 'The crew uncovers an alien artifact that holds the key to their mission...', 5000, 3, 1, 130, '2025-06-20 13:30:00', '2025-06-20 13:30:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (7, 3, 'The Cryptic Note', 'Detective Lila finds a hidden message that changes the case...', 3400, 1, 0, 0, '2024-05-25 14:10:00', '2024-05-25 14:10:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (8, 3, 'Suspects Secrets', 'Lila interrogates a key witness with a dark past...', 3600, 2, 1, 50, '2024-06-20 15:15:00', '2024-06-20 15:15:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (9, 3, 'The Shadows Trail', 'A late-night pursuit leads Lila to a shocking discovery...', 3800, 3, 1, 70, '2025-07-05 09:45:00', '2025-07-05 09:45:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (10, 4, 'The Oracles Call', 'Kael is summoned to lead the fight against an ancient evil...', 5200, 1, 0, 0, '2023-12-01 12:10:00', '2023-12-01 12:10:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (11, 4, 'The Great Clash', 'Kaels forces face the dark army in a battle for the ages...', 5400, 2, 0, 0, '2024-01-25 13:15:00', '2024-01-25 13:15:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (12, 4, 'The Prophecys End', 'Kaels final stand determines the fate of the world...', 5700, 3, 1, 200, '2025-07-01 11:15:00', '2025-07-01 11:15:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (13, 5, 'First Glance', 'Elara and Kian meet aboard the starship, their connection instant...', 3200, 1, 0, 0, '2024-07-15 13:10:00', '2024-07-15 13:10:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (14, 5, 'Under the Stars', 'A quiet evening reveals the depth of Elara and Kians feelings...', 3400, 2, 1, 60, '2024-08-30 14:15:00', '2024-08-30 14:15:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (15, 5, 'Tempest of Love', 'A galactic storm threatens to tear Elara and Kian apart...', 3700, 3, 1, 80, '2025-07-11 02:00:00', '2025-07-11 02:00:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (16, 6, 'The Fog Descends', 'A chilling mist engulfs the village, hiding unspeakable horrors...', 2900, 1, 0, 0, '2024-03-10 16:15:00', '2024-03-10 16:15:00', '2025-07-05 10:00:00');
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (17, 6, 'The Haunted Relic', 'A cursed artifact in the village square awakens dark forces...', 3100, 2, 0, 0, '2024-04-05 17:00:00', '2024-04-05 17:00:00', '2025-07-05 10:00:00');
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (18, 6, 'Whispers in the Dark', 'The villagers hear eerie voices as the curse tightens its grip...', 3300, 3, 0, 0, '2024-04-20 17:30:00', '2024-04-20 17:30:00', '2025-07-05 10:00:00');
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (19, 7, 'The Covert Operation', 'Agent Jace infiltrates a secret facility with a deadly agenda...', 3700, 1, 0, 0, '2024-04-20 09:45:00', '2024-04-20 09:45:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (20, 7, 'The Hidden Truth', 'Jace uncovers evidence of a global conspiracy...', 3900, 2, 1, 80, '2024-05-20 10:30:00', '2024-05-20 10:30:00', NULL);
INSERT INTO `chapters` (`id`, `book_id`, `title`, `content`, `word_count`, `sort`, `is_locked`, `required_score`, `created_at`, `updated_at`, `deleted_at`) VALUES (21, 7, 'The Final Countdown', 'Jace races to stop a catastrophic event...', 4100, 3, 1, 90, '2025-06-30 15:00:00', '2025-06-30 15:00:00', NULL);
COMMIT;
-- ----------------------------
-- Table structure for feedbacks
-- ----------------------------
DROP TABLE IF EXISTS `feedbacks`;
CREATE TABLE `feedbacks` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '反馈ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '反馈内容',
`status` tinyint NOT NULL DEFAULT '1' COMMENT '处理状态1=未处理2=处理中3=已处理',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '反馈时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_user_id` (`user_id`),
CONSTRAINT `fk_feedbacks_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户反馈表';
-- ----------------------------
-- Records of feedbacks
-- ----------------------------
BEGIN;
INSERT INTO `feedbacks` (`id`, `user_id`, `content`, `status`, `created_at`, `updated_at`) VALUES (1, 1, 'App crashes during photo upload.', 1, '2025-07-01 10:15:23', NULL);
INSERT INTO `feedbacks` (`id`, `user_id`, `content`, `status`, `created_at`, `updated_at`) VALUES (2, 2, 'Please add dark mode support.', 2, '2025-07-02 14:30:45', '2025-07-05 09:20:10');
INSERT INTO `feedbacks` (`id`, `user_id`, `content`, `status`, `created_at`, `updated_at`) VALUES (3, 3, 'Slow login process needs optimization.', 3, '2025-07-03 08:45:12', '2025-07-06 16:00:00');
INSERT INTO `feedbacks` (`id`, `user_id`, `content`, `status`, `created_at`, `updated_at`) VALUES (4, 4, 'More filter options would be great.', 1, '2025-07-04 19:22:33', NULL);
INSERT INTO `feedbacks` (`id`, `user_id`, `content`, `status`, `created_at`, `updated_at`) VALUES (5, 5, 'Payment section has a bug.', 2, '2025-07-05 11:10:50', '2025-07-07 13:45:22');
COMMIT;
-- ----------------------------
-- Table structure for user_chapter_purchases
-- ----------------------------
DROP TABLE IF EXISTS `user_chapter_purchases`;
CREATE TABLE `user_chapter_purchases` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '购买记录ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`book_id` bigint NOT NULL COMMENT '小说ID',
`chapter_id` bigint NOT NULL COMMENT '章节ID',
`points_used` int NOT NULL COMMENT '消耗积分数',
`purchase_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '购买时间',
PRIMARY KEY (`id`),
KEY `idx_user_id` (`user_id`),
KEY `idx_book_id` (`book_id`),
KEY `idx_chapter_id` (`chapter_id`),
CONSTRAINT `fk_user_chapter_purchases_book_id` FOREIGN KEY (`book_id`) REFERENCES `books` (`id`),
CONSTRAINT `fk_user_chapter_purchases_chapter_id` FOREIGN KEY (`chapter_id`) REFERENCES `chapters` (`id`),
CONSTRAINT `fk_user_chapter_purchases_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户章节购买记录表';
-- ----------------------------
-- Records of user_chapter_purchases
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for user_follow_authors
-- ----------------------------
DROP TABLE IF EXISTS `user_follow_authors`;
CREATE TABLE `user_follow_authors` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '关注ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`author_id` bigint NOT NULL COMMENT '作者ID',
`followed_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '关注时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_author` (`user_id`,`author_id`),
KEY `idx_user_id` (`user_id`),
KEY `idx_author_id` (`author_id`),
CONSTRAINT `fk_user_follow_authors_author_id` FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`),
CONSTRAINT `fk_user_follow_authors_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户关注作者表';
-- ----------------------------
-- Records of user_follow_authors
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for user_points_logs
-- ----------------------------
DROP TABLE IF EXISTS `user_points_logs`;
CREATE TABLE `user_points_logs` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '积分流水ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`change_type` tinyint NOT NULL COMMENT '变动类型1=消费(spend), 2=收入(earn)',
`points_change` int NOT NULL COMMENT '积分变化数,正数增加,负数减少',
`related_order_id` bigint DEFAULT NULL COMMENT '关联ID当change_type=1时为chapter_purchases.id当change_type=2时为advertisement_records.id',
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '变动说明',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '变动时间',
PRIMARY KEY (`id`),
KEY `idx_user_id` (`user_id`),
KEY `idx_related_order_id` (`related_order_id`),
CONSTRAINT `fk_user_points_logs_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户积分流水表';
-- ----------------------------
-- Records of user_points_logs
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for user_read_history
-- ----------------------------
DROP TABLE IF EXISTS `user_read_history`;
CREATE TABLE `user_read_history` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '历史记录ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`book_id` bigint NOT NULL COMMENT '小说ID',
`chapter_id` bigint NOT NULL COMMENT '最后阅读章节ID',
`read_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后阅读时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_book` (`user_id`,`book_id`),
KEY `idx_user_id` (`user_id`),
KEY `idx_book_id` (`book_id`),
KEY `fk_user_read_history_chapter_id` (`chapter_id`),
CONSTRAINT `fk_user_read_history_book_id` FOREIGN KEY (`book_id`) REFERENCES `books` (`id`),
CONSTRAINT `fk_user_read_history_chapter_id` FOREIGN KEY (`chapter_id`) REFERENCES `chapters` (`id`),
CONSTRAINT `fk_user_read_history_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户阅读历史记录表';
-- ----------------------------
-- Records of user_read_history
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for user_read_records
-- ----------------------------
DROP TABLE IF EXISTS `user_read_records`;
CREATE TABLE `user_read_records` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '记录ID',
`user_id` bigint NOT NULL COMMENT '用户ID',
`book_id` bigint NOT NULL COMMENT '小说ID',
`chapter_id` bigint NOT NULL COMMENT '章节ID',
`progress` int NOT NULL DEFAULT '0' COMMENT '阅读进度百分比(0-100)',
`read_at` datetime NOT NULL COMMENT '阅读时间',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_book_chapter` (`user_id`,`book_id`,`chapter_id`),
KEY `idx_user_id` (`user_id`),
KEY `idx_book_id` (`book_id`),
KEY `idx_chapter_id` (`chapter_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户阅读记录表';
-- ----------------------------
-- Records of user_read_records
-- ----------------------------
BEGIN;
COMMIT;
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID',
`username` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名',
`password_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码哈希',
`avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '头像URL',
`email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '邮箱',
`points` bigint unsigned NOT NULL DEFAULT '0' COMMENT '积分',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '注册时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
`deleted_at` timestamp NULL DEFAULT NULL COMMENT '软删除时间戳',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_username` (`username`),
KEY `idx_email_deleted` (`email`,`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户表';
-- ----------------------------
-- Records of users
-- ----------------------------
BEGIN;
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (1, 'john_doe', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', 'https://example.com/avatars/john.jpg', 'john.doe@example.com', 150, '2025-06-01 09:00:00', '2025-07-05 14:20:30', NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (2, 'jane_smith', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', 'https://example.com/avatars/jane.jpg', 'jane.smith@example.com', 320, '2025-06-02 12:15:45', '2025-07-06 10:10:10', NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (3, 'alice_wong', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', NULL, 'alice.wong@example.com', 50, '2025-06-03 15:30:22', NULL, NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (4, 'bob_lee', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', 'https://example.com/avatars/bob.jpg', 'bob.lee@example.com', 200, '2025-06-04 08:45:00', '2025-07-07 16:00:00', NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (5, 'emma_brown', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', NULL, 'emma.brown@example.com', 0, '2025-06-05 11:20:15', NULL, NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (6, 'MoonScribe', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', 'https://example.com/avatars/moonscribe.jpg', 'moonscribe@example.com', 1800, '2023-01-10 09:00:00', '2025-07-10 14:00:00', NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (7, 'NebulaTale', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', 'https://example.com/avatars/nebulatale.jpg', 'nebulatale@example.com', 2500, '2023-03-15 11:30:00', '2025-06-25 10:15:00', NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (8, 'MistWalker', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', NULL, 'mistwalker@example.com', 900, '2023-05-20 13:45:00', '2025-05-10 16:20:00', NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (9, 'LegendWeaver', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', 'https://example.com/avatars/legendweaver.jpg', 'legendweaver@example.com', 3200, '2023-07-25 10:00:00', '2025-07-01 12:30:00', NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (10, 'StarBloom', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', 'https://example.com/avatars/starbloom.jpg', 'starbloom@example.com', 1400, '2023-09-10 15:00:00', NULL, NULL);
INSERT INTO `users` (`id`, `username`, `password_hash`, `avatar`, `email`, `points`, `created_at`, `updated_at`, `deleted_at`) VALUES (11, 'NightShade', '$2a$10$cin1jkkEiKg0GW2blAWEb.1V8QeUCHV350yZ6sTbmIC/4fdbFqnTW', NULL, 'nightshade@example.com', 700, '2023-11-05 08:30:00', '2025-06-15 09:00:00', '2025-07-05 11:00:00');
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;