Sfoglia il codice sorgente

企业部门创建时插入字典

ZC 3 settimane fa
parent
commit
65e8add7fe

+ 20 - 0
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java

@@ -4,7 +4,9 @@ import java.util.ArrayList;
 import java.util.List;
 
 import com.ruoyi.common.security.annotation.InnerAuth;
+import com.ruoyi.system.api.domain.SysDictData;
 import com.ruoyi.system.domain.vo.TreeSelect;
+import com.ruoyi.system.service.ISysDictDataService;
 import org.apache.commons.lang3.ArrayUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -32,6 +34,9 @@ public class SysDeptController extends BaseController
     @Autowired
     private ISysDeptService deptService;
 
+    @Autowired
+    private ISysDictDataService dictDataService;
+
     /**
      * 获取部门列表
      */
@@ -79,6 +84,21 @@ public class SysDeptController extends BaseController
             return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
         }
         dept.setCreateBy(SecurityUtils.getUsername());
+
+        if(dept.getDeptName().matches(".*公司$")){
+            SysDictData dict = new SysDictData();
+
+            dict.setDictType("mast_enterprise");
+            List<SysDictData> sysDictDatas = dictDataService.selectDictDataList(dict);
+            dict.setListClass("default");
+            dict.setDictLabel(dept.getDeptName());
+            dict.setDictSort((long) (sysDictDatas.size()+1));
+            dict.setDictValue(String.valueOf(sysDictDatas.size()+1));
+            dict.setStatus("0");
+
+            dictDataService.insertDictData(dict);
+        }
+
         return toAjax(deptService.insertDept(dept));
     }
 

+ 0 - 14
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java

@@ -218,20 +218,6 @@ public class SysUserController extends BaseController
             remoteExpertService.insertExpert(bsExpert, SecurityConstants.INNER);
         }
 
-        if(user.getUserName().matches(".*公司$")){
-            SysDictData dict = new SysDictData();
-
-            List<SysDictData> sysDictDatas = dictDataService.selectDictDataList(new SysDictData());
-            dict.setDictType("mast_enterprise");
-            dict.setListClass("default");
-            dict.setDictLabel(user.getUserName());
-            dict.setDictSort((long) (sysDictDatas.size()+1));
-            dict.setDictValue(String.valueOf(sysDictDatas.size()+1));
-            dict.setStatus("0");
-
-            dictDataService.insertDictData(dict);
-        }
-
         return toAjax(i);
     }