Просмотр исходного кода

重写schema.sql修复GBK乱码,所有中文注释使用正确UTF-8编码

User 5 месяцев назад
Родитель
Сommit
f227be2498
1 измененных файлов с 41 добавлено и 40 удалено
  1. 41 40
      zxyj-backend/src/main/resources/schema.sql

+ 41 - 40
zxyj-backend/src/main/resources/schema.sql

@@ -1,6 +1,7 @@
--- 蹇冪煡瀹跺涵鏁版嵁搴撳垵濮嬪寲鑴氭湰
--- 鑷姩鍒涘缓琛?
--- 瀹跺涵琛?
+-- 知行益家数据库初始化脚本
+-- 自动创建表
+
+-- 家庭表
 CREATE TABLE IF NOT EXISTS families (
 CREATE TABLE IF NOT EXISTS families (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     name VARCHAR(100),
     name VARCHAR(100),
@@ -10,7 +11,7 @@ CREATE TABLE IF NOT EXISTS families (
     INDEX idx_invite_code (invite_code)
     INDEX idx_invite_code (invite_code)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 鐢ㄦ埛琛?
+-- 用户表
 CREATE TABLE IF NOT EXISTS users (
 CREATE TABLE IF NOT EXISTS users (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     openid VARCHAR(64) NOT NULL,
     openid VARCHAR(64) NOT NULL,
@@ -26,7 +27,7 @@ CREATE TABLE IF NOT EXISTS users (
     INDEX idx_family_id (family_id)
     INDEX idx_family_id (family_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 瀛╁瓙璇︽儏琛?
+-- 孩子详情表
 CREATE TABLE IF NOT EXISTS children (
 CREATE TABLE IF NOT EXISTS children (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     user_id BIGINT NOT NULL,
     user_id BIGINT NOT NULL,
@@ -34,7 +35,7 @@ CREATE TABLE IF NOT EXISTS children (
     nickname VARCHAR(50) NOT NULL,
     nickname VARCHAR(50) NOT NULL,
     age TINYINT NOT NULL,
     age TINYINT NOT NULL,
     dan_level VARCHAR(2),
     dan_level VARCHAR(2),
-    penalty_enabled TINYINT DEFAULT 1 COMMENT '鏄惁寮€鍚墸鍒?0鍚?鏄?,
+    penalty_enabled TINYINT DEFAULT 1 COMMENT '是否开启扣分(0否1是)',
     theme VARCHAR(32) DEFAULT 'default',
     theme VARCHAR(32) DEFAULT 'default',
     total_points INT DEFAULT 0,
     total_points INT DEFAULT 0,
     streak_days INT DEFAULT 0,
     streak_days INT DEFAULT 0,
@@ -48,7 +49,7 @@ CREATE TABLE IF NOT EXISTS children (
     INDEX idx_family_id (family_id)
     INDEX idx_family_id (family_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 浠诲姟琛?
+-- 任务表
 CREATE TABLE IF NOT EXISTS tasks (
 CREATE TABLE IF NOT EXISTS tasks (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     family_id BIGINT NOT NULL,
     family_id BIGINT NOT NULL,
@@ -56,12 +57,12 @@ CREATE TABLE IF NOT EXISTS tasks (
     child_id BIGINT NOT NULL,
     child_id BIGINT NOT NULL,
     title VARCHAR(200) NOT NULL,
     title VARCHAR(200) NOT NULL,
     description VARCHAR(500),
     description VARCHAR(500),
-    points TINYINT DEFAULT 2 COMMENT '浠诲姟绉垎1-10',
+    points TINYINT DEFAULT 2 COMMENT '任务积分1-10',
     deadline DATETIME NOT NULL,
     deadline DATETIME NOT NULL,
     repeat_type ENUM('none', 'daily', 'weekly') DEFAULT 'none',
     repeat_type ENUM('none', 'daily', 'weekly') DEFAULT 'none',
     category VARCHAR(32),
     category VARCHAR(32),
-    need_review TINYINT DEFAULT 0 COMMENT '鏄惁闇€瑕佸鏍?,
-    review_by_category TINYINT DEFAULT 0 COMMENT '鏄惁鎸夊垎绫诲鏍?,
+    need_review TINYINT DEFAULT 0 COMMENT '是否需要审核',
+    review_by_category TINYINT DEFAULT 0 COMMENT '是否按分类审核',
     status ENUM('pending', 'completed', 'overdue', 'cancelled') DEFAULT 'pending',
     status ENUM('pending', 'completed', 'overdue', 'cancelled') DEFAULT 'pending',
     completed_at DATETIME,
     completed_at DATETIME,
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
@@ -71,12 +72,12 @@ CREATE TABLE IF NOT EXISTS tasks (
     INDEX idx_category (category)
     INDEX idx_category (category)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 绉垎娴佹按琛?
+-- 积分流水表
 CREATE TABLE IF NOT EXISTS points_log (
 CREATE TABLE IF NOT EXISTS points_log (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     child_id BIGINT NOT NULL,
     child_id BIGINT NOT NULL,
     task_id BIGINT,
     task_id BIGINT,
-    amount INT NOT NULL COMMENT '绉垎鏁伴噺姝h礋',
+    amount INT NOT NULL COMMENT '积分数量正负',
     type ENUM('earn', 'spend', 'bonus', 'penalty', 'adjust', 'reset', 'refund') NOT NULL,
     type ENUM('earn', 'spend', 'bonus', 'penalty', 'adjust', 'reset', 'refund') NOT NULL,
     description VARCHAR(255),
     description VARCHAR(255),
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
@@ -84,7 +85,7 @@ CREATE TABLE IF NOT EXISTS points_log (
     INDEX idx_type (type)
     INDEX idx_type (type)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 绉垎娓呴浂璁板綍琛?
+-- 积分清零记录表
 CREATE TABLE IF NOT EXISTS points_reset_log (
 CREATE TABLE IF NOT EXISTS points_reset_log (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     child_id BIGINT NOT NULL,
     child_id BIGINT NOT NULL,
@@ -95,7 +96,7 @@ CREATE TABLE IF NOT EXISTS points_reset_log (
     INDEX idx_child_id (child_id)
     INDEX idx_child_id (child_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 濂栧姳琛?
+-- 奖励表
 CREATE TABLE IF NOT EXISTS rewards (
 CREATE TABLE IF NOT EXISTS rewards (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     family_id BIGINT NOT NULL,
     family_id BIGINT NOT NULL,
@@ -104,16 +105,16 @@ CREATE TABLE IF NOT EXISTS rewards (
     points_required INT NOT NULL,
     points_required INT NOT NULL,
     category VARCHAR(32),
     category VARCHAR(32),
     status ENUM('available', 'pending', 'exchanged', 'rejected') DEFAULT 'available',
     status ENUM('available', 'pending', 'exchanged', 'rejected') DEFAULT 'available',
-    exchange_approved TINYINT COMMENT '鏄惁瀹℃壒閫氳繃',
+    exchange_approved TINYINT COMMENT '是否审批通过',
     exchanged_at DATETIME,
     exchanged_at DATETIME,
-    is_template TINYINT DEFAULT 0 COMMENT '鏄惁涓洪璁炬ā鏉?,
+    is_template TINYINT DEFAULT 0 COMMENT '是否为预设模板',
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
     updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
     updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
     INDEX idx_child_id_status (child_id, status),
     INDEX idx_child_id_status (child_id, status),
     INDEX idx_is_template (is_template)
     INDEX idx_is_template (is_template)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 濂栧姳鍒嗙被琛?
+-- 奖励分类表
 CREATE TABLE IF NOT EXISTS reward_categories (
 CREATE TABLE IF NOT EXISTS reward_categories (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     family_id BIGINT NOT NULL,
     family_id BIGINT NOT NULL,
@@ -124,22 +125,22 @@ CREATE TABLE IF NOT EXISTS reward_categories (
     INDEX idx_family_id (family_id)
     INDEX idx_family_id (family_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 棰勮濂栧姳妯℃澘鏁版嵁
+-- 预设奖励模板数据
 INSERT INTO rewards (family_id, child_id, title, points_required, category, is_template) VALUES
 INSERT INTO rewards (family_id, child_id, title, points_required, category, is_template) VALUES
-(0, 0, '鐪嬪姩鐢荤墖30鍒嗛挓', 30, '绮剧绫?, 1),
-(0, 0, '鐜╁钩鏉挎父鎴?0鍒嗛挓', 40, '鐗规潈绫?, 1),
-(0, 0, '鍘绘父涔愬満', 100, '鐗╄川绫?, 1),
-(0, 0, '涔扮帺鍏?, 150, '鐗╄川绫?, 1),
-(0, 0, '鍚冨啺娣囨穻', 20, '鐗╄川绫?, 1),
-(0, 0, '閫夋嫨鏅氶', 25, '鐗规潈绫?, 1);
+(0, 0, '看动画片30分钟', 30, '精神奖励', 1),
+(0, 0, '玩平板游戏30分钟', 40, '特权奖励', 1),
+(0, 0, '去游乐场', 100, '物质奖励', 1),
+(0, 0, '买玩具', 150, '物质奖励', 1),
+(0, 0, '吃冰淇淋', 20, '物质奖励', 1),
+(0, 0, '选择晚餐', 25, '特权奖励', 1);
 
 
--- 榛樿濂栧姳鍒嗙被
+-- 默认奖励分类
 INSERT INTO reward_categories (family_id, name, icon, sort_order) VALUES
 INSERT INTO reward_categories (family_id, name, icon, sort_order) VALUES
-(0, '鐗╄川绫?, 'gift', 1),
-(0, '绮剧绫?, 'star', 2),
-(0, '鐗规潈绫?, 'crown', 3);
+(0, '物质奖励', 'gift', 1),
+(0, '精神奖励', 'star', 2),
+(0, '特权奖励', 'crown', 3);
 
 
--- 鏁忔劅璇嶈〃
+-- 敏感词表
 CREATE TABLE IF NOT EXISTS sensitive_words (
 CREATE TABLE IF NOT EXISTS sensitive_words (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     word VARCHAR(50) NOT NULL,
     word VARCHAR(50) NOT NULL,
@@ -148,7 +149,7 @@ CREATE TABLE IF NOT EXISTS sensitive_words (
     INDEX idx_word (word)
     INDEX idx_word (word)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 浠诲姟瀹℃牳琛?
+-- 任务审核表
 CREATE TABLE IF NOT EXISTS task_reviews (
 CREATE TABLE IF NOT EXISTS task_reviews (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     task_id BIGINT NOT NULL,
     task_id BIGINT NOT NULL,
@@ -168,7 +169,7 @@ CREATE TABLE IF NOT EXISTS task_reviews (
     INDEX idx_ai_result (ai_result)
     INDEX idx_ai_result (ai_result)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 鍕嬬珷瀹氫箟琛?
+-- 勋章定义表
 CREATE TABLE IF NOT EXISTS badge_definitions (
 CREATE TABLE IF NOT EXISTS badge_definitions (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     badge_type VARCHAR(32) NOT NULL,
     badge_type VARCHAR(32) NOT NULL,
@@ -181,7 +182,7 @@ CREATE TABLE IF NOT EXISTS badge_definitions (
     INDEX idx_badge_type (badge_type)
     INDEX idx_badge_type (badge_type)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 鍕嬬珷琛?
+-- 勋章表
 CREATE TABLE IF NOT EXISTS badges (
 CREATE TABLE IF NOT EXISTS badges (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     child_id BIGINT NOT NULL,
     child_id BIGINT NOT NULL,
@@ -190,7 +191,7 @@ CREATE TABLE IF NOT EXISTS badges (
     INDEX idx_child_id_type (child_id, badge_type)
     INDEX idx_child_id_type (child_id, badge_type)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 鎵撳崱閲岀▼纰戣〃
+-- 打卡里程碑表
 CREATE TABLE IF NOT EXISTS streak_milestones (
 CREATE TABLE IF NOT EXISTS streak_milestones (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     days INT NOT NULL,
     days INT NOT NULL,
@@ -198,20 +199,20 @@ CREATE TABLE IF NOT EXISTS streak_milestones (
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 鎻掑叆鎵撳崱閲岀▼纰戞暟鎹?
+-- 插入打卡里程碑数据
 INSERT INTO streak_milestones (days, reward_points) VALUES
 INSERT INTO streak_milestones (days, reward_points) VALUES
 (3, 5),
 (3, 5),
 (7, 10),
 (7, 10),
 (30, 30),
 (30, 30),
 (100, 100);
 (100, 100);
 
 
--- 涓撴敞璁粌璁板綍琛?
+-- 专注训练记录表
 CREATE TABLE IF NOT EXISTS focus_sessions (
 CREATE TABLE IF NOT EXISTS focus_sessions (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     child_id BIGINT NOT NULL,
     child_id BIGINT NOT NULL,
     mode ENUM('simple', 'pomodoro') NOT NULL,
     mode ENUM('simple', 'pomodoro') NOT NULL,
     duration TINYINT NOT NULL,
     duration TINYINT NOT NULL,
-    stars TINYINT COMMENT '璇勫垎1-5',
+    stars TINYINT COMMENT '评分1-5',
     points_earned INT,
     points_earned INT,
     voice_note_url VARCHAR(255),
     voice_note_url VARCHAR(255),
     started_at DATETIME NOT NULL,
     started_at DATETIME NOT NULL,
@@ -219,16 +220,16 @@ CREATE TABLE IF NOT EXISTS focus_sessions (
     INDEX idx_child_id_completed (child_id, completed_at)
     INDEX idx_child_id_completed (child_id, completed_at)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 涓撴敞璁粌閰嶇疆琛?
+-- 专注训练配置表
 CREATE TABLE IF NOT EXISTS focus_config (
 CREATE TABLE IF NOT EXISTS focus_config (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     family_id BIGINT,
     family_id BIGINT,
     max_daily_count TINYINT DEFAULT 3,
     max_daily_count TINYINT DEFAULT 3,
-    allow_exit TINYINT DEFAULT 1 COMMENT '鏄惁鍏佽閫€鍑?鍚?鏄?,
+    allow_exit TINYINT DEFAULT 1 COMMENT '是否允许退出(0否1是)',
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- DAN娴嬭瘎琛?
+-- DAN测评表
 CREATE TABLE IF NOT EXISTS dan_assessments (
 CREATE TABLE IF NOT EXISTS dan_assessments (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     child_id BIGINT NOT NULL,
     child_id BIGINT NOT NULL,
@@ -241,7 +242,7 @@ CREATE TABLE IF NOT EXISTS dan_assessments (
     INDEX idx_child_id_level (child_id, dan_level)
     INDEX idx_child_id_level (child_id, dan_level)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
 
--- 浠诲姟妯℃澘琛?
+-- 任务模板表
 CREATE TABLE IF NOT EXISTS task_templates (
 CREATE TABLE IF NOT EXISTS task_templates (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     id BIGINT AUTO_INCREMENT PRIMARY KEY,
     dan_level VARCHAR(2) NOT NULL,
     dan_level VARCHAR(2) NOT NULL,