|
|
@@ -3695,6 +3695,10 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
|
|
|
// 迁移505: 内容安全敏感词库 content_sensitive_word + 降级FAQ话术 coach_fallback_faq
|
|
|
// (能力键 ai.coach.safetyGuard,SC-B-05/06;CREATE TABLE IF NOT EXISTS 幂等)
|
|
|
createCoachSafetyGuardTables();
|
|
|
+
|
|
|
+ // 迁移506: report_type_registry 补 icon / sort_order 列(小程序上传页「支持的报告类型」配置化)
|
|
|
+ // 并补种上传页所需的体检/舌象/体脂类型;幂等(先判断列存在 + 先 SELECT 再 INSERT/UPDATE)
|
|
|
+ addReportTypeRegistryIconSortOrderColumns();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -17152,4 +17156,75 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
log.warn("迁移504: user_current_food_recommend 表创建失败(忽略): {}", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 迁移506: {@code report_type_registry} 补 {@code icon}/{@code sort_order} 列并补种小程序上传页「支持的报告类型」5 类。
|
|
|
+ *
|
|
|
+ * <p>上传页原为硬编码模板,改为后台配置驱动后需图标与排序;已激活的 gut_flora/dan_a2
|
|
|
+ * 缺 icon/sort_order 用 UPDATE 补齐(COALESCE 保留已有值,不覆盖管理员已填),未注册的
|
|
|
+ * physical_exam/tongue/body_fat 用 INSERT 补种(is_active=1)。幂等:columnExists 判断列 +
|
|
|
+ * 先 SELECT 再 INSERT/UPDATE,可重复执行。</p>
|
|
|
+ */
|
|
|
+ void addReportTypeRegistryIconSortOrderColumns() {
|
|
|
+ try {
|
|
|
+ if (!columnExists("report_type_registry", "icon")) {
|
|
|
+ jdbcTemplate.execute("ALTER TABLE report_type_registry "
|
|
|
+ + "ADD COLUMN icon VARCHAR(50) DEFAULT NULL COMMENT '页面展示图标(emoji或图标类名)'");
|
|
|
+ log.info("迁移506: 已添加 report_type_registry.icon 列");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("迁移506: 添加 report_type_registry.icon 列失败(幂等容忍): {}", e.getMessage());
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (!columnExists("report_type_registry", "sort_order")) {
|
|
|
+ jdbcTemplate.execute("ALTER TABLE report_type_registry "
|
|
|
+ + "ADD COLUMN sort_order INT DEFAULT 100 COMMENT '展示排序,升序(小程序上传页支持的报告类型列表顺序)'");
|
|
|
+ log.info("迁移506: 已添加 report_type_registry.sort_order 列");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("迁移506: 添加 report_type_registry.sort_order 列失败(幂等容忍): {}", e.getMessage());
|
|
|
+ }
|
|
|
+ seedReportTypeRegistryIconSortOrder();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 迁移506 种子:确保小程序上传页 5 类有 icon/sort_order 且缺记录时补种(幂等,先 SELECT 再 INSERT/UPDATE) */
|
|
|
+ private void seedReportTypeRegistryIconSortOrder() {
|
|
|
+ Object[][] seeds = {
|
|
|
+ {"gut_flora", "gut_flora", "菌群检测报告", "肠道菌群 PDF,后台采集解析菌群指标", "📄", 1},
|
|
|
+ {"dan_a2", "dan", "素质测评", "核心素养/认知发展 PDF,系统解析能力、人格、情绪等", "🧠", 2},
|
|
|
+ {"physical_exam", null, "体检报告", "血常规、尿常规、生化检验等,支持 PDF 或清晰照片", "📋", 3},
|
|
|
+ {"tongue", null, "舌象照片", "拍摄舌象照片,AI 辅助舌诊分析", "👅", 4},
|
|
|
+ {"body_fat", null, "体脂秤报告", "拍摄体脂秤显示屏,自动提取体重、BMI、体脂率等", "⚖️", 5},
|
|
|
+ };
|
|
|
+ for (Object[] s : seeds) {
|
|
|
+ String typeId = (String) s[0];
|
|
|
+ String family = (String) s[1];
|
|
|
+ String displayName = (String) s[2];
|
|
|
+ String description = (String) s[3];
|
|
|
+ String icon = (String) s[4];
|
|
|
+ int sortOrder = (Integer) s[5];
|
|
|
+ try {
|
|
|
+ Integer count = jdbcTemplate.queryForObject(
|
|
|
+ "SELECT COUNT(*) FROM report_type_registry WHERE type_id = ?", Integer.class, typeId);
|
|
|
+ if (count == null || count == 0) {
|
|
|
+ jdbcTemplate.update(
|
|
|
+ "INSERT INTO report_type_registry (type_id, family, display_name, description, icon, "
|
|
|
+ + "sort_order, min_confidence, is_active, source, review_status, version, created_at, updated_at) "
|
|
|
+ + "VALUES (?, ?, ?, ?, ?, ?, 30, 1, 'prebuilt', 'approved', '1.0', NOW(), NOW())",
|
|
|
+ typeId, family, displayName, description, icon, sortOrder);
|
|
|
+ log.info("迁移506: 已补种报告类型 {}", typeId);
|
|
|
+ } else {
|
|
|
+ Integer patched = jdbcTemplate.update(
|
|
|
+ "UPDATE report_type_registry SET icon = COALESCE(icon, ?), sort_order = COALESCE(sort_order, ?), "
|
|
|
+ + "updated_at = NOW() WHERE type_id = ?",
|
|
|
+ icon, sortOrder, typeId);
|
|
|
+ if (patched != null && patched > 0) {
|
|
|
+ log.info("迁移506: 已为既有类型 {} 补齐 icon/sort_order", typeId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("迁移506: 处理报告类型 {} 失败(幂等容忍): {}", typeId, e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|