From 1ca4c6c6c7861c07980ad0dcd8d5df4b0219bfdc Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期三, 06 九月 2023 19:01:48 +0800
Subject: [PATCH] bug

---
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java
index 9e21529..cbeedb4 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java
@@ -15,6 +15,7 @@
 import com.ruoyi.system.mapper.sys.SysDeptMapper;
 import com.ruoyi.system.mapper.sys.SysDeptMenuMapper;
 import com.ruoyi.system.mapper.sys.SysRoleMapper;
+import com.ruoyi.system.service.staff.SysWxCpService;
 import com.ruoyi.system.service.sys.ISysDeptService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -40,6 +41,9 @@
 
     @Autowired
     private SysDeptMenuMapper deptMenuMapper;
+
+    @Autowired
+    private SysWxCpService sysWxCpService;
 
     /**
      * 查询部门管理数据
@@ -224,6 +228,8 @@
             throw new ServiceException("部门停用,不允许新增");
         }
         dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
+        Long wxDeptId = sysWxCpService.addWxCpDept(1L,dept.getDeptName());
+        dept.setWxDeptId(wxDeptId);
         //新增部门
         int i = deptMapper.insertDept(dept);
         if(dept.getMenuIds()!=null||dept.getStaffMenuIds()!=null){
@@ -283,6 +289,9 @@
             String oldAncestors = oldDept.getAncestors();
             dept.setAncestors(newAncestors);
             updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+        }
+        if(oldDept.getWxDeptId()!=null&&!oldDept.getDeptName().equals(dept.getDeptName())){
+            sysWxCpService.updateWxCpDept(oldDept.getWxDeptId(),dept.getDeptName());
         }
         int result = deptMapper.updateDept(dept);
         if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
@@ -396,4 +405,6 @@
     public SysDept getByWxDeptId(Long wxDeptId){
         return deptMapper.getByWxDeptId(wxDeptId);
     }
+
+
 }

--
Gitblit v1.7.1