|
@@ -1003,6 +1003,9 @@ log.info("已添加template_id列到tasks表");
|
|
|
insertContentSectionSeed("mind", "daily_tip", "每日心理", "[\"anonymous\"]", 2);
|
|
insertContentSectionSeed("mind", "daily_tip", "每日心理", "[\"anonymous\"]", 2);
|
|
|
insertContentSectionSeed("mind", "recommended_reading", "推荐阅读", "[\"anonymous\"]", 3);
|
|
insertContentSectionSeed("mind", "recommended_reading", "推荐阅读", "[\"anonymous\"]", 3);
|
|
|
insertContentSectionSeed("mind", "premium_content", "会员专属内容", "[\"parent\",\"teacher\"]", 4);
|
|
insertContentSectionSeed("mind", "premium_content", "会员专属内容", "[\"parent\",\"teacher\"]", 4);
|
|
|
|
|
+ insertContentSectionSeed("mind", "mind_tasks", "心智任务", "[\"parent\",\"child\"]", 5);
|
|
|
|
|
+ insertContentSectionSeed("mind", "related_activities", "相关活动", "[\"parent\",\"child\"]", 6);
|
|
|
|
|
+ insertContentSectionSeed("mind", "purchased_courses", "已购课程", "[\"parent\",\"child\"]", 7);
|
|
|
insertContentSectionSeed("body", "func_entries", "功能入口", "[\"anonymous\"]", 1);
|
|
insertContentSectionSeed("body", "func_entries", "功能入口", "[\"anonymous\"]", 1);
|
|
|
insertContentSectionSeed("body", "daily_stats", "今日数据", "[\"anonymous\"]", 2);
|
|
insertContentSectionSeed("body", "daily_stats", "今日数据", "[\"anonymous\"]", 2);
|
|
|
insertContentSectionSeed("body", "health_tips", "健康小贴士", "[\"anonymous\"]", 3);
|
|
insertContentSectionSeed("body", "health_tips", "健康小贴士", "[\"anonymous\"]", 3);
|
|
@@ -1460,6 +1463,85 @@ log.info("已添加template_id列到tasks表");
|
|
|
log.warn("检查/添加 dan_assessment_results 认知维度字段失败: {}", e.getMessage());
|
|
log.warn("检查/添加 dan_assessment_results 认知维度字段失败: {}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 迁移: dan_assessment_results 表添加 EMI 维度字段(v1.2 心智模型重构)
|
|
|
|
|
+ try {
|
|
|
|
|
+ Integer colExists = jdbcTemplate.queryForObject(
|
|
|
|
|
+ "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'dan_assessment_results' AND COLUMN_NAME = 'emotion_management_score'",
|
|
|
|
|
+ Integer.class);
|
|
|
|
|
+ if (colExists == null || colExists == 0) {
|
|
|
|
|
+ jdbcTemplate.execute("ALTER TABLE dan_assessment_results " +
|
|
|
|
|
+ "ADD COLUMN emotion_management_score INT COMMENT '情绪管理得分(EMI)', " +
|
|
|
|
|
+ "ADD COLUMN empathy_score INT COMMENT '同理心得分(EMI)', " +
|
|
|
|
|
+ "ADD COLUMN social_adaptability_score INT COMMENT '社会适应得分(EMI)', " +
|
|
|
|
|
+ "ADD COLUMN self_motivation_score INT COMMENT '自我激励得分(EMI)'");
|
|
|
|
|
+ log.info("已为 dan_assessment_results 表添加 EMI 维度字段");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("dan_assessment_results EMI 维度字段已存在,跳过");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("检查/添加 dan_assessment_results EMI 维度字段失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移: dan_assessment_results 表添加 EMI 心理子维度字段
|
|
|
|
|
+ try {
|
|
|
|
|
+ Integer colExists = jdbcTemplate.queryForObject(
|
|
|
|
|
+ "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'dan_assessment_results' AND COLUMN_NAME = 'emotion_score'",
|
|
|
|
|
+ Integer.class);
|
|
|
|
|
+ if (colExists == null || colExists == 0) {
|
|
|
|
|
+ jdbcTemplate.execute("ALTER TABLE dan_assessment_results " +
|
|
|
|
|
+ "ADD COLUMN emotion_score INT COMMENT '情绪商数(0-100)', " +
|
|
|
|
|
+ "ADD COLUMN resilience_score INT COMMENT '心理韧性(0-100)', " +
|
|
|
|
|
+ "ADD COLUMN stress_coping_score INT COMMENT '压力应对(0-100)', " +
|
|
|
|
|
+ "ADD COLUMN self_awareness_score INT COMMENT '自我认知(0-100)'");
|
|
|
|
|
+ log.info("已为 dan_assessment_results 表添加 EMI 心理子维度字段");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("dan_assessment_results EMI 心理子维度字段已存在,跳过");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("检查/添加 dan_assessment_results EMI 心理子维度字段失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移: users 表添加出生时辰字段
|
|
|
|
|
+ try {
|
|
|
|
|
+ jdbcTemplate.execute("ALTER TABLE users ADD COLUMN birth_hour VARCHAR(10) COMMENT '出生时辰: 子丑寅卯辰巳午未申酉戌亥'");
|
|
|
|
|
+ log.info("已添加birth_hour列到users表");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 列已存在,忽略错误
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移: 重建 family_member_attributes 表结构(v1.2 心智模型)
|
|
|
|
|
+ try {
|
|
|
|
|
+ Integer colExists = jdbcTemplate.queryForObject(
|
|
|
|
|
+ "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'family_member_attributes' AND COLUMN_NAME = 'member_id'",
|
|
|
|
|
+ Integer.class);
|
|
|
|
|
+ if (colExists == null || colExists == 0) {
|
|
|
|
|
+ // 旧表存在但结构不同,先删除旧表重建
|
|
|
|
|
+ jdbcTemplate.execute("DROP TABLE IF EXISTS family_member_attributes_old");
|
|
|
|
|
+ jdbcTemplate.execute("RENAME TABLE family_member_attributes TO family_member_attributes_old");
|
|
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS family_member_attributes (" +
|
|
|
|
|
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
|
|
|
+ "member_id BIGINT NOT NULL COMMENT '家庭成员ID(children表或users表)', " +
|
|
|
|
|
+ "member_type VARCHAR(10) NOT NULL COMMENT '成员类型: child/parent', " +
|
|
|
|
|
+ "birth_datetime DATETIME COMMENT '出生日期(精确到分钟,用于八字排盘)', " +
|
|
|
|
|
+ "eight_characters JSON COMMENT '八字四柱JSON', " +
|
|
|
|
|
+ "wuxing_elements JSON COMMENT '五行星盘元素JSON', " +
|
|
|
|
|
+ "zodiac VARCHAR(16) COMMENT '生肖: rat/ox/tiger/rabbit/dragon/snake/horse/sheep/monkey/rooster/dog/pig', " +
|
|
|
|
|
+ "blood_type VARCHAR(5) COMMENT '血型: A/B/AB/O', " +
|
|
|
|
|
+ "mind_base_score DECIMAL(5,2) DEFAULT 0 COMMENT '心维度基础分(先天)', " +
|
|
|
|
|
+ "wisdom_base_score DECIMAL(5,2) DEFAULT 0 COMMENT '智维度基础分(先天)', " +
|
|
|
|
|
+ "behavior_modifier JSON COMMENT '行为修正因子JSON', " +
|
|
|
|
|
+ "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
|
|
|
|
|
+ "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
|
|
|
|
|
+ "UNIQUE KEY uk_member (member_id, member_type)" +
|
|
|
|
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='家庭成员先天属性表'");
|
|
|
|
|
+ log.info("已重建 family_member_attributes 表(v1.2 心智模型)");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("family_member_attributes 表已为 v1.2 结构,跳过");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("重建 family_member_attributes 表失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
log.info("数据库迁移完成");
|
|
log.info("数据库迁移完成");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1697,6 +1779,80 @@ try {
|
|
|
log.warn("初始化测试用户失败: {}", e.getMessage());
|
|
log.warn("初始化测试用户失败: {}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 初始化星座配置种子数据
|
|
|
|
|
+ try {
|
|
|
|
|
+ Integer count = jdbcTemplate.queryForObject(
|
|
|
|
|
+ "SELECT COUNT(*) FROM zodiac_config", Integer.class);
|
|
|
|
|
+ if (count == null || count == 0) {
|
|
|
|
|
+ jdbcTemplate.execute("INSERT INTO zodiac_config (zodiac_code, zodiac_name, element, start_month, start_day, end_month, end_day, mind_base, wisdom_base, body_modifier, action_modifier, wealth_modifier) VALUES " +
|
|
|
|
|
+ "('aries', '白羊座', '火', 3, 21, 4, 19, 65, 70, 1.10, 1.05, 0.95), " +
|
|
|
|
|
+ "('taurus', '金牛座', '土', 4, 20, 5, 20, 60, 65, 1.05, 1.10, 1.15), " +
|
|
|
|
|
+ "('gemini', '双子座', '金', 5, 21, 6, 21, 70, 80, 0.95, 1.15, 0.90), " +
|
|
|
|
|
+ "('cancer', '巨蟹座', '水', 6, 22, 7, 22, 75, 60, 1.00, 0.90, 1.05), " +
|
|
|
|
|
+ "('leo', '狮子座', '火', 7, 23, 8, 22, 65, 75, 1.15, 1.00, 1.10), " +
|
|
|
|
|
+ "('virgo', '处女座', '土', 8, 23, 9, 22, 55, 85, 0.95, 1.05, 1.00), " +
|
|
|
|
|
+ "('libra', '天秤座', '金', 9, 23, 10, 23, 70, 75, 0.90, 0.95, 1.10), " +
|
|
|
|
|
+ "('scorpio', '天蝎座', '水', 10, 24, 11, 22, 80, 70, 1.10, 1.00, 1.15), " +
|
|
|
|
|
+ "('sagittarius', '射手座', '火', 11, 23, 12, 21, 60, 65, 1.15, 1.15, 0.95), " +
|
|
|
|
|
+ "('capricorn', '摩羯座', '土', 12, 22, 1, 19, 55, 75, 1.05, 1.10, 1.20), " +
|
|
|
|
|
+ "('aquarius', '水瓶座', '金', 1, 20, 2, 18, 75, 85, 0.95, 0.90, 1.00), " +
|
|
|
|
|
+ "('pisces', '双鱼座', '水', 2, 19, 3, 20, 80, 60, 0.90, 0.95, 0.95)");
|
|
|
|
|
+ log.info("星座配置种子数据已初始化");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("初始化星座配置失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化八字配置种子数据(十天干 + 十二地支)
|
|
|
|
|
+ try {
|
|
|
|
|
+ Integer count = jdbcTemplate.queryForObject(
|
|
|
|
|
+ "SELECT COUNT(*) FROM bazi_config", Integer.class);
|
|
|
|
|
+ if (count == null || count == 0) {
|
|
|
|
|
+ jdbcTemplate.execute("INSERT INTO bazi_config (stem_or_branch, type, element, yin_yang, mind_base, wisdom_base, body_modifier, action_modifier, wealth_modifier) VALUES " +
|
|
|
|
|
+ "('甲', 'stem', '木', 'yang', 60, 75, 1.05, 1.10, 1.00), " +
|
|
|
|
|
+ "('乙', 'stem', '木', 'yin', 65, 70, 0.95, 1.05, 1.00), " +
|
|
|
|
|
+ "('丙', 'stem', '火', 'yang', 75, 65, 1.10, 1.00, 0.95), " +
|
|
|
|
|
+ "('丁', 'stem', '火', 'yin', 70, 60, 1.05, 0.95, 1.00), " +
|
|
|
|
|
+ "('戊', 'stem', '土', 'yang', 60, 65, 1.15, 1.05, 1.10), " +
|
|
|
|
|
+ "('己', 'stem', '土', 'yin', 55, 60, 1.10, 1.00, 1.15), " +
|
|
|
|
|
+ "('庚', 'stem', '金', 'yang', 65, 80, 1.05, 1.10, 1.05), " +
|
|
|
|
|
+ "('辛', 'stem', '金', 'yin', 60, 75, 0.95, 1.00, 1.10), " +
|
|
|
|
|
+ "('壬', 'stem', '水', 'yang', 70, 70, 1.00, 0.95, 1.15), " +
|
|
|
|
|
+ "('癸', 'stem', '水', 'yin', 75, 65, 0.95, 0.90, 1.10), " +
|
|
|
|
|
+ "('子', 'branch', '水', 'yang', 70, 65, 1.00, 0.95, 1.05), " +
|
|
|
|
|
+ "('丑', 'branch', '土', 'yin', 55, 60, 1.10, 1.05, 1.10), " +
|
|
|
|
|
+ "('寅', 'branch', '木', 'yang', 65, 75, 1.15, 1.10, 1.00), " +
|
|
|
|
|
+ "('卯', 'branch', '木', 'yin', 60, 70, 1.05, 1.05, 0.95), " +
|
|
|
|
|
+ "('辰', 'branch', '土', 'yang', 60, 65, 1.10, 1.00, 1.10), " +
|
|
|
|
|
+ "('巳', 'branch', '火', 'yin', 75, 70, 1.05, 0.95, 1.00), " +
|
|
|
|
|
+ "('午', 'branch', '火', 'yang', 80, 65, 1.15, 1.00, 0.95), " +
|
|
|
|
|
+ "('未', 'branch', '土', 'yin', 55, 60, 1.05, 1.00, 1.05), " +
|
|
|
|
|
+ "('申', 'branch', '金', 'yang', 65, 80, 1.00, 1.10, 1.05), " +
|
|
|
|
|
+ "('酉', 'branch', '金', 'yin', 60, 75, 0.95, 1.05, 1.10), " +
|
|
|
|
|
+ "('戌', 'branch', '土', 'yang', 60, 65, 1.10, 1.00, 1.15), " +
|
|
|
|
|
+ "('亥', 'branch', '水', 'yin', 70, 60, 1.00, 0.95, 1.05)");
|
|
|
|
|
+ log.info("八字配置种子数据已初始化");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("初始化八字配置失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化血型配置种子数据
|
|
|
|
|
+ try {
|
|
|
|
|
+ Integer count = jdbcTemplate.queryForObject(
|
|
|
|
|
+ "SELECT COUNT(*) FROM blood_type_config", Integer.class);
|
|
|
|
|
+ if (count == null || count == 0) {
|
|
|
|
|
+ jdbcTemplate.execute("INSERT INTO blood_type_config (blood_type, description, mind_base, wisdom_base, body_modifier, action_modifier, wealth_modifier) VALUES " +
|
|
|
|
|
+ "('A', '认真负责、严谨细致,但易焦虑', 70, 75, 0.95, 1.00, 1.05), " +
|
|
|
|
|
+ "('B', '乐观开朗、好奇心强,但缺乏耐心', 65, 70, 1.05, 1.10, 0.95), " +
|
|
|
|
|
+ "('AB', '理性冷静、适应力强,但优柔寡断', 75, 80, 1.00, 0.95, 1.10), " +
|
|
|
|
|
+ "('O', '自信果断、行动力强,但固执己见', 60, 65, 1.15, 1.15, 1.15)");
|
|
|
|
|
+ log.info("血型配置种子数据已初始化");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("初始化血型配置失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 初始化成长规划师模块相关表
|
|
// 初始化成长规划师模块相关表
|
|
|
initGuideModuleTables(jdbcTemplate);
|
|
initGuideModuleTables(jdbcTemplate);
|
|
|
}
|
|
}
|