|
@@ -17,7 +17,7 @@ import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Component
|
|
@Component
|
|
|
-public class DatabaseInitializer implements CommandLineRunner {
|
|
|
|
|
|
|
+public class DatabaseInitializer implements CommandLineRunner {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
@@ -100,7 +100,7 @@ public class DatabaseInitializer implements CommandLineRunner {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void runMigrations() {
|
|
private void runMigrations() {
|
|
|
- // 迁移1: 任务表添加执行者字段
|
|
|
|
|
|
|
+ // 迁移1: 任务表添加执行者字段
|
|
|
try {
|
|
try {
|
|
|
jdbcTemplate.execute("ALTER TABLE tasks ADD COLUMN executor_type ENUM('child', 'parent') DEFAULT 'child' COMMENT '执行者类型'");
|
|
jdbcTemplate.execute("ALTER TABLE tasks ADD COLUMN executor_type ENUM('child', 'parent') DEFAULT 'child' COMMENT '执行者类型'");
|
|
|
log.info("已添加executor_type列到tasks表");
|
|
log.info("已添加executor_type列到tasks表");
|
|
@@ -766,8 +766,8 @@ log.info("已添加template_id列到tasks表");
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.warn("检查/添加category列失败: {}", e.getMessage());
|
|
log.warn("检查/添加category列失败: {}", e.getMessage());
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 迁移22: 创建invite_card表
|
|
// 迁移22: 创建invite_card表
|
|
|
try {
|
|
try {
|
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS invite_card (" +
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS invite_card (" +
|
|
@@ -1041,7 +1041,7 @@ log.info("已添加template_id列到tasks表");
|
|
|
insertContentSectionSeed("mind", "premium_content", "会员专属内容", "[\"parent\",\"teacher\"]", 4);
|
|
insertContentSectionSeed("mind", "premium_content", "会员专属内容", "[\"parent\",\"teacher\"]", 4);
|
|
|
insertContentSectionSeed("mind", "mind_tasks", "心智任务", "[\"parent\",\"child\"]", 5);
|
|
insertContentSectionSeed("mind", "mind_tasks", "心智任务", "[\"parent\",\"child\"]", 5);
|
|
|
insertContentSectionSeed("mind", "related_activities", "相关活动", "[\"parent\",\"child\"]", 6);
|
|
insertContentSectionSeed("mind", "related_activities", "相关活动", "[\"parent\",\"child\"]", 6);
|
|
|
- insertContentSectionSeed("mind", "purchased_courses", "已购课程", "[\"parent\",\"child\"]", 7);
|
|
|
|
|
|
|
+ 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);
|
|
@@ -2543,9 +2543,10 @@ log.info("已添加template_id列到tasks表");
|
|
|
);
|
|
);
|
|
|
log.info("numsoul_config 种子数据已加载 (9条)");
|
|
log.info("numsoul_config 种子数据已加载 (9条)");
|
|
|
}
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
|
|
|
|
+} catch (Exception e) {
|
|
|
log.warn("numsoul_config 种子数据初始化失败: {}", e.getMessage());
|
|
log.warn("numsoul_config 种子数据初始化失败: {}", e.getMessage());
|
|
|
- // Migration: user_address table (收货地址)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS user_address (" +
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS user_address (" +
|
|
|
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
"id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
@@ -2564,7 +2565,6 @@ log.info("已添加template_id列到tasks表");
|
|
|
log.info("已创建 user_address 表");
|
|
log.info("已创建 user_address 表");
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.warn("创建 user_address 表失败: {}", e.getMessage());
|
|
log.warn("创建 user_address 表失败: {}", e.getMessage());
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
log.info("数据库迁移完成");
|
|
log.info("数据库迁移完成");
|
|
@@ -2655,7 +2655,7 @@ log.info("已添加template_id列到tasks表");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void initializeDefaultData() {
|
|
|
|
|
|
|
+ private void initializeDefaultData() {
|
|
|
// 初始化预设奖励模板
|
|
// 初始化预设奖励模板
|
|
|
try {
|
|
try {
|
|
|
// 检查是否已有预设奖励
|
|
// 检查是否已有预设奖励
|