Explorar el Código

feat: nutrition_product 增加成份/配料表(ingredients)字段及后台管理展示

- entity: NutritionProduct 新增 ingredients 字段
- schema.sql: nutrition_product 建表同步 ingredients TEXT 列, suitable_for 升级为 TEXT
- DatabaseInitializer: 新增迁移228(ingredients 列 + suitable_for MODIFY), 幂等
- cfc-web: NutritionProducts 列表/详情展示成份配料表
- 数据已通过独立脚本提交至京东云 RDS 生产库(zxyj)
asus hace 2 meses
padre
commit
7d3476207b

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -8888,5 +8888,14 @@ private void runMigration100() {
 
 
 		// 迁移224: health_reports 添加 shannon_index 列(修复 Unknown column 错误)
 		// 迁移224: health_reports 添加 shannon_index 列(修复 Unknown column 错误)
 		ensureColumn("health_reports", "shannon_index", "VARCHAR(32) DEFAULT NULL COMMENT '香农指数'");
 		ensureColumn("health_reports", "shannon_index", "VARCHAR(32) DEFAULT NULL COMMENT '香农指数'");
+
+		// 迁移228: nutrition_product 添加 ingredients 列 + suitable_for 升级为 TEXT(存放详情页图像提取的成份/配料表与适用说明)
+		ensureColumn("nutrition_product", "ingredients", "TEXT DEFAULT NULL COMMENT '成份/配料表(从详情页图片提取)'");
+		try {
+			jdbcTemplate.execute("ALTER TABLE nutrition_product MODIFY COLUMN suitable_for TEXT DEFAULT NULL COMMENT '适用人群/使用方法'");
+			log.info("已将nutrition_product.suitable_for升级为TEXT类型");
+		} catch (Exception e) {
+			// 修改失败,忽略错误(幂等)
+		}
 	}
 	}
 }
 }

+ 3 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/NutritionProduct.java

@@ -31,6 +31,9 @@ public class NutritionProduct implements Serializable {
 
 
     private String suitableFor;
     private String suitableFor;
 
 
+    /** 成份/配料表(从详情页图片提取) */
+    private String ingredients;
+
     private String imageUrl;
     private String imageUrl;
 
 
     private String description;
     private String description;

+ 2 - 1
cfc-backend/src/main/resources/schema.sql

@@ -4517,7 +4517,8 @@ CREATE TABLE IF NOT EXISTS nutrition_product (
     form VARCHAR(30) DEFAULT NULL COMMENT '剂型',
     form VARCHAR(30) DEFAULT NULL COMMENT '剂型',
     net_content VARCHAR(50) DEFAULT NULL COMMENT '净含量',
     net_content VARCHAR(50) DEFAULT NULL COMMENT '净含量',
     shelf_life VARCHAR(50) DEFAULT NULL COMMENT '保质期',
     shelf_life VARCHAR(50) DEFAULT NULL COMMENT '保质期',
-    suitable_for VARCHAR(200) DEFAULT NULL COMMENT '适用人群',
+    suitable_for TEXT DEFAULT NULL COMMENT '适用人群',
+    ingredients TEXT DEFAULT NULL COMMENT '成份/配料表(从详情页图片提取)',
     image_url VARCHAR(500) DEFAULT NULL COMMENT '产品图',
     image_url VARCHAR(500) DEFAULT NULL COMMENT '产品图',
     description TEXT COMMENT '产品描述',
     description TEXT COMMENT '产品描述',
     status TINYINT DEFAULT 1 COMMENT '状态 0下架/1上架',
     status TINYINT DEFAULT 1 COMMENT '状态 0下架/1上架',

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-add05488a3676f6b5dc640c34260f74083e67756
+0b5c2033055af74999a5f97348a4af94023dac2a

+ 2 - 2
cfc-web/package-lock.json

@@ -1,12 +1,12 @@
 {
 {
   "name": "cfc-web",
   "name": "cfc-web",
-  "version": "1.0.1011",
+  "version": "1.0.1013",
   "lockfileVersion": 3,
   "lockfileVersion": 3,
   "requires": true,
   "requires": true,
   "packages": {
   "packages": {
     "": {
     "": {
       "name": "cfc-web",
       "name": "cfc-web",
-      "version": "1.0.1011",
+      "version": "1.0.1013",
       "dependencies": {
       "dependencies": {
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor-for-vue": "^1.0.2",
         "@wangeditor/editor-for-vue": "^1.0.2",

+ 1 - 1
cfc-web/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "cfc-web",
   "name": "cfc-web",
-  "version": "1.0.1012",
+  "version": "1.0.1013",
   "private": true,
   "private": true,
   "scripts": {
   "scripts": {
     "dev": "vue-cli-service serve",
     "dev": "vue-cli-service serve",

+ 7 - 0
cfc-web/src/views/admin/NutritionProducts.vue

@@ -76,6 +76,12 @@
         <el-table-column label="适用人群" width="120">
         <el-table-column label="适用人群" width="120">
           <template slot-scope="{ row }">{{ row.suitableFor || '-' }}</template>
           <template slot-scope="{ row }">{{ row.suitableFor || '-' }}</template>
         </el-table-column>
         </el-table-column>
+        <el-table-column label="成份/配料" min-width="200" show-overflow-tooltip>
+          <template slot-scope="{ row }">
+            <span v-if="row.ingredients">{{ row.ingredients }}</span>
+            <span v-else class="no-data">-</span>
+          </template>
+        </el-table-column>
         <el-table-column label="关联商品" width="120" align="center">
         <el-table-column label="关联商品" width="120" align="center">
           <template slot-scope="{ row }">
           <template slot-scope="{ row }">
             <el-tag v-if="row.localProductId" type="success" size="mini">已关联</el-tag>
             <el-tag v-if="row.localProductId" type="success" size="mini">已关联</el-tag>
@@ -106,6 +112,7 @@
           <el-descriptions-item label="净含量">{{ detailData.product.netContent || '-' }}</el-descriptions-item>
           <el-descriptions-item label="净含量">{{ detailData.product.netContent || '-' }}</el-descriptions-item>
           <el-descriptions-item label="保质期">{{ detailData.product.shelfLife || '-' }}</el-descriptions-item>
           <el-descriptions-item label="保质期">{{ detailData.product.shelfLife || '-' }}</el-descriptions-item>
           <el-descriptions-item label="适用人群">{{ detailData.product.suitableFor || '-' }}</el-descriptions-item>
           <el-descriptions-item label="适用人群">{{ detailData.product.suitableFor || '-' }}</el-descriptions-item>
+          <el-descriptions-item label="成份/配料表">{{ detailData.product.ingredients || '-' }}</el-descriptions-item>
           <el-descriptions-item label="关联商品ID" :span="2">
           <el-descriptions-item label="关联商品ID" :span="2">
             <el-tag v-if="detailData.product.localProductId" type="success">
             <el-tag v-if="detailData.product.localProductId" type="success">
               {{ detailData.product.localProductId }}
               {{ detailData.product.localProductId }}