From 7ffd310e52ef6135197379f0ac2c4522780e53b9 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期三, 26 八月 2026 17:42:27 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsTypeServiceImpl.java |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsTypeServiceImpl.java
index 6ca11a2..d9e986d 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsTypeServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsTypeServiceImpl.java
@@ -3,6 +3,7 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.common.basic.PageInfo;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.constant.GoodsTypeConstants;
 import com.ruoyi.system.model.TErpGoodsType;
 import com.ruoyi.system.mapper.TErpGoodsTypeMapper;
 import com.ruoyi.system.query.TErpGoodsTypeQuery;
@@ -11,6 +12,7 @@
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -35,9 +37,23 @@
 
     @Override
     public PageInfo<TErpGoodsType> pageList(TErpGoodsTypeQuery query) {
+        ensureBuiltinTypes();
         PageInfo<TErpGoodsType> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
         List<TErpGoodsType> list = this.baseMapper.pageList(query,pageInfo);
         pageInfo.setRecords(list);
         return pageInfo;
     }
+
+    @Override
+    public void ensureBuiltinTypes() {
+        for (Map.Entry<String, String> entry : GoodsTypeConstants.BUILTIN_TYPES.entrySet()) {
+            if (this.getById(entry.getKey()) == null) {
+                TErpGoodsType type = new TErpGoodsType();
+                type.setId(entry.getKey());
+                type.setTypeName(entry.getValue());
+                type.setDisabled(false);
+                this.save(type);
+            }
+        }
+    }
 }

--
Gitblit v1.7.1