Procházet zdrojové kódy

fix(backend): 修复 DatabaseInitializer git 冲突标记残留及预存注释行 try{ bug,编译失败

iwt před 1 týdnem
rodič
revize
130b3d0646

+ 41 - 20
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -1775,7 +1775,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("初始化商品能量比例配置失败: {}", e.getMessage());
         }
 
-        // ==================== 精准营养 P0: health_report_survey =============        try {
+        // ==================== 精准营养 P0: health_report_survey =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS health_report_survey (" +
                     "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
                     "report_id BIGINT NOT NULL COMMENT '关联报告ID', " +
@@ -1793,6 +1794,7 @@ public class DatabaseInitializer implements CommandLineRunner {
         }
 
         // ==================== 精准营养 P0: health_gut_flora + health_disease_risk =============
+        
         try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS health_gut_flora (" +
                     "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
@@ -1826,7 +1828,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("创建 health_disease_risk 表失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移: health_reports 表添加新字段 =============        try {
+        // ==================== 迁移: health_reports 表添加新字段 =============        
+        try {
             jdbcTemplate.execute("ALTER TABLE health_reports ADD COLUMN balance_score INT DEFAULT NULL COMMENT '菌群平衡分'");
             log.info("已添加balance_score列到health_reports表");
         } catch (Exception e) {
@@ -1876,7 +1879,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             // 列已存在,忽略错误
         }
 
-        // ==================== 迁移: health_gut_flora 表添加新字段 =============        try {
+        // ==================== 迁移: health_gut_flora 表添加新字段 =============        
+        try {
             jdbcTemplate.execute("ALTER TABLE health_gut_flora ADD COLUMN population_level VARCHAR(50) DEFAULT NULL COMMENT '处于人群%水平'");
             log.info("已添加population_level列到health_gut_flora表");
         } catch (Exception e) {
@@ -2485,7 +2489,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("创建 danshop_addresses 表失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移: activities表添加visible_scope列 =============        try {
+        // ==================== 迁移: activities表添加visible_scope列 =============        
+        try {
             Integer colExists = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'activities' AND COLUMN_NAME = 'visible_scope'",
                     Integer.class);
@@ -2499,7 +2504,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("检查/添加activities表visible_scope列失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移: articles表添加article_type列 =============        try {
+        // ==================== 迁移: articles表添加article_type列 =============        
+        try {
             Integer colExists = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'articles' AND COLUMN_NAME = 'article_type'",
                     Integer.class);
@@ -2513,7 +2519,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("检查/添加articles表article_type列失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移: articles表添加word_count列 =============        try {
+        // ==================== 迁移: articles表添加word_count列 =============        
+        try {
             Integer colExists = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'articles' AND COLUMN_NAME = 'word_count'",
                     Integer.class);
@@ -2527,7 +2534,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("检查/添加articles表word_count列失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移: article_reading_records表添加task_id列 =============        try {
+        // ==================== 迁移: article_reading_records表添加task_id列 =============        
+        try {
             Integer colExists = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'article_reading_records' AND COLUMN_NAME = 'task_id'",
                     Integer.class);
@@ -2541,7 +2549,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("检查/添加article_reading_records表task_id列失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移: tasks表添加source_type列 =============        try {
+        // ==================== 迁移: tasks表添加source_type列 =============        
+        try {
             Integer colExists = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'tasks' AND COLUMN_NAME = 'source_type'",
                     Integer.class);
@@ -2555,7 +2564,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("检查/添加tasks表source_type列失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移: tasks表添加source_id列 =============        try {
+        // ==================== 迁移: tasks表添加source_id列 =============        
+        try {
             Integer colExists = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'tasks' AND COLUMN_NAME = 'source_id'",
                     Integer.class);
@@ -2569,7 +2579,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("检查/添加tasks表source_id列失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移: activities表添加checkin_points列 =============        try {
+        // ==================== 迁移: activities表添加checkin_points列 =============        
+        try {
             Integer colExists = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'activities' AND COLUMN_NAME = 'checkin_points'",
                     Integer.class);
@@ -2603,7 +2614,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("创建family_invitations表失败: {}", e.getMessage());
         }
 
-        // ==================== P0 营养师: nutrition_indicator_mapping =============        try {
+        // ==================== P0 营养师: nutrition_indicator_mapping =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS nutrition_indicator_mapping (" +
                     "id BIGINT AUTO_INCREMENT PRIMARY KEY," +
                     "indicator_name_pattern VARCHAR(200) NOT NULL COMMENT '指标名匹配模式(SQL LIKE语法,%为通配符)'," +
@@ -2682,7 +2694,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("nutrition_indicator_mapping 种子数据初始化失败: {}", e.getMessage());
         }
 
-        // ==================== 心版块 Phase 1: emotion_checkin 表 =============        try {
+        // ==================== 心版块 Phase 1: emotion_checkin 表 =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS emotion_checkin (" +
                     "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
                     "child_id BIGINT NOT NULL COMMENT '孩子ID', " +
@@ -2754,7 +2767,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             }
         }
 
-        // ==================== 1b-1: bazi_reading_template 五行命理解读表 =============        try {
+        // ==================== 1b-1: bazi_reading_template 五行命理解读表 =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS bazi_reading_template (" +
                     "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
                     "element VARCHAR(20) NOT NULL COMMENT '五行: wood/fire/earth/metal/water', " +
@@ -2770,7 +2784,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("创建 bazi_reading_template 表失败: {}", e.getMessage());
         }
 
-        // ==================== 1b-1: numsoul_config 生命灵数配置表 =============        try {
+        // ==================== 1b-1: numsoul_config 生命灵数配置表 =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS numsoul_config (" +
                     "number INT PRIMARY KEY COMMENT '灵数1-9', " +
                     "title VARCHAR(50) NOT NULL COMMENT '称号', " +
@@ -2784,7 +2799,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("创建 numsoul_config 表失败: {}", e.getMessage());
         }
 
-        // ==================== 1b-1: bazi_reading_template 种子数据 =============        try {
+        // ==================== 1b-1: bazi_reading_template 种子数据 =============        
+        try {
             Integer count = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM bazi_reading_template", Integer.class);
             if (count == null || count == 0) {
@@ -2814,7 +2830,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("bazi_reading_template 种子数据初始化失败: {}", e.getMessage());
         }
 
-        // ==================== 1b-1: numsoul_config 种子数据 =============        try {
+        // ==================== 1b-1: numsoul_config 种子数据 =============        
+        try {
             Integer count = jdbcTemplate.queryForObject(
                     "SELECT COUNT(*) FROM numsoul_config", Integer.class);
             if (count == null || count == 0) {
@@ -2895,7 +2912,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("创建member_discount_configs表失败: {}", e.getMessage());
         }
 
-        // ==================== 食材推荐指数 Phase: food_recommend_idx / food_recommend_idx_log =============        try {
+        // ==================== 食材推荐指数 Phase: food_recommend_idx / food_recommend_idx_log =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `food_recommend_idx` (" +
                     "`id` BIGINT NOT NULL AUTO_INCREMENT, " +
                     "`user_id` BIGINT NOT NULL COMMENT '用户ID', " +
@@ -3119,7 +3137,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("sleep_record 时间列修改失败(可能已为 TIME): {}", e.getMessage());
         }
 
-        // ==================== 迁移270: 先天画像来源权重配置表 =============        try {
+        // ==================== 迁移270: 先天画像来源权重配置表 =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS innate_portrait_config (" +
                     "id BIGINT AUTO_INCREMENT PRIMARY KEY," +
                     "source_type VARCHAR(20) NOT NULL," +
@@ -3150,7 +3169,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("迁移270失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移271: 先天画像报告缓存表 =============        try {
+        // ==================== 迁移271: 先天画像报告缓存表 =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS innate_portrait_report (" +
                     "id BIGINT AUTO_INCREMENT PRIMARY KEY," +
                     "member_id BIGINT NOT NULL," +
@@ -3167,7 +3187,8 @@ public class DatabaseInitializer implements CommandLineRunner {
             log.warn("迁移271失败: {}", e.getMessage());
         }
 
-        // ==================== 迁移272: 数字能量详细配置表 =============        try {
+        // ==================== 迁移272: 数字能量详细配置表 =============        
+        try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS numsoul_detail_config (" +
                     "id BIGINT AUTO_INCREMENT PRIMARY KEY," +
                     "number_type VARCHAR(20) NOT NULL," +