bug
jiangqs
2023-09-06 1ca4c6c6c7861c07980ad0dcd8d5df4b0219bfdc
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())
@@ -383,4 +392,19 @@
    {
        return getChildList(list, t).size() > 0 ? true : false;
    }
    /**
     * @description  通过微信部门id获取部门
     * @author  jqs
     * @date    2023/8/17 16:21
     * @param wxDeptId
     * @return  SysDept
     */
    @Override
    public SysDept getByWxDeptId(Long wxDeptId){
        return deptMapper.getByWxDeptId(wxDeptId);
    }
}