From 99132a43bf344f2aafdd9894b0762d2eedd9767b Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期二, 01 七月 2025 17:15:25 +0800
Subject: [PATCH] 修改

---
 multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java |   59 ++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
index a186588..4f5bd1a 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
@@ -226,7 +226,7 @@
     @Override
     public void checkDeptDataScope(Long deptId)
     {
-        if (!SecurityUtils.isAdmin(SecurityUtils.getUserId()) && ObjectUtil.isNotNull(deptId))
+        if (!SecurityUtils.adminUser() && ObjectUtil.isNotNull(deptId))
         {
             SysDept dept = new SysDept();
             dept.setDeptId(deptId);
@@ -260,13 +260,12 @@
     @Override
     @Transactional
     public int saveDept(SysDeptSaveDTOReq dept) {
-        Long companyId = SecurityUtils.getCompanyId();
-        if (!companyId.equals(dept.getCompanyId())){
-            throw new ApiException("无权操作!");
-        }
+//        Long companyId = SecurityUtils.getCompanyId();
+//        if (!companyId.equals(dept.getCompanyId())){
+//            throw new ApiException("无权操作!");
+//        }
         SysDept sysDept = new SysDept();
         BeanUtils.copyProperties(dept, sysDept);
-        sysDept.setCompanyId(companyId);
         boolean b = checkDeptNameUnique(sysDept);
         if (!b){
             throw new ApiException("部门名称已存在!");
@@ -287,7 +286,7 @@
                 delCaluse(sysDept.getDeptId(), delCaluseIds);
             }
             //处理条款
-            batchSaveCaluse(sysDept.getDeptId(), companyId, dept.getCaluseVO1List());
+            batchSaveCaluse(sysDept.getDeptId(), dept.getCompanyId(), dept.getCaluseVO1List());
 
         }
 
@@ -297,15 +296,15 @@
     @Override
     @Transactional
     public int saveDeptResponsibility(SysDeptResponsibilityReqVo reqVo) {
-        Long companyId = SecurityUtils.getCompanyId();
-        if (!companyId.equals(reqVo.getCompanyId())){
-            throw new ApiException("无权操作!");
-        }
+//        Long companyId = SecurityUtils.getCompanyId();
+//        if (!companyId.equals(reqVo.getCompanyId())){
+//            throw new ApiException("无权操作!");
+//        }
         SysDept sysDept = deptMapper.selectDeptById(reqVo.getDeptId());
         if (null == sysDept){
             throw new ApiException("部门不存在!");
         }
-        if (!companyId.equals(sysDept.getCompanyId())){
+        if (!reqVo.getCompanyId().equals(sysDept.getCompanyId())){
             throw new ApiException("无权操作!");
         }
         SysDept dept = new SysDept();
@@ -326,20 +325,19 @@
 
     @Override
     public List<SysFunctionalDistribution> getFunctionalDistributionList(Long companyId) {
-        if (companyId != null){
-            companyId = SecurityUtils.getCompanyId();
-        }
+
        return sysFunctionalDistributionMapper.selectListVo(companyId);
     }
 
     @Override
+    @Transactional
     public int initFunctionalDistribution(Long companyId) {
 
-        if (!companyId.equals(SecurityUtils.getCompanyId())){
-            throw new ApiException("无权操作!");
-        }
-        sysFunctionalDistributionMapper.delete(new LambdaQueryWrapper<SysFunctionalDistribution>().eq(SysFunctionalDistribution::getCompanyId, SecurityUtils.getLoginUser().getUser().getCompanyId()));
+//        if (!companyId.equals(SecurityUtils.getCompanyId())){
+//            throw new ApiException("无权操作!");
+//        }
 
+        sysFunctionalDistributionMapper.delByCompanyId(companyId);
         SysDept sysDept = new SysDept();
         sysDept.setCompanyId(companyId);
         List<DeptVo> deptVos = deptMapper.selectDeptList(sysDept);
@@ -369,11 +367,19 @@
 
     @Override
     public int saveFunctionalDistribution(FunctionalDistributionVo reqVo) {
-        Long companyId = SecurityUtils.getLoginUser().getUser().getCompanyId();
-        if (!companyId.equals(reqVo.getCompanyId())){
-            throw new ApiException("无权操作!");
-        }
+//        Long companyId = SecurityUtils.getCompanyId();
+//        if (!companyId.equals(reqVo.getCompanyId())){
+//            throw new ApiException("无权操作!");
+//        }
         List<SysFunctionalDistribution> list = reqVo.getList();
+        if (list != null && !list.isEmpty())
+        {
+            for (SysFunctionalDistribution sysFunctionalDistribution : list) {
+                sysFunctionalDistribution.setCompanyId(reqVo.getCompanyId());
+                sysFunctionalDistribution.setUpdateBy(SecurityUtils.getUsername());
+                sysFunctionalDistribution.setUpdateTime(LocalDateTime.now());
+            }
+        }
         int i = sysFunctionalDistributionMapper.batchUpdate(list);
         if (i < 1){
             throw new ApiException("保存失败!");
@@ -408,7 +414,9 @@
 
         if (!emptyIdClauseNums.isEmpty()){
             List<SysDeptResponsibility> sysDeptResponsibilities = deptResponsibilityMapper.selectList(new LambdaQueryWrapper<SysDeptResponsibility>()
-                    .eq(SysDeptResponsibility::getDeptId, reqVo.getDeptId()).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums).notIn(SysDeptResponsibility::getId, emptyIdClauseIds));
+                    .eq(SysDeptResponsibility::getDeptId, reqVo.getDeptId())
+                    .in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums)
+                    .notIn(SysDeptResponsibility::getId, emptyIdClauseIds).eq(SysDeptResponsibility::getDelFlag, "0"));
             if (!sysDeptResponsibilities.isEmpty()){
                 throw new ApiException("部门条款编码重复!");
             }
@@ -447,7 +455,8 @@
                 .collect(Collectors.toList());
         if (!emptyIdClauseNums.isEmpty()){
             List<SysDeptResponsibility> sysDeptResponsibilities = deptResponsibilityMapper.selectList(new LambdaQueryWrapper<SysDeptResponsibility>()
-                    .eq(SysDeptResponsibility::getDeptId, deptId).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums));
+                    .eq(SysDeptResponsibility::getDeptId, deptId).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums)
+                    .eq(SysDeptResponsibility::getCompanyId, companyId).eq(SysDeptResponsibility::getDelFlag, "0"));
             if (!sysDeptResponsibilities.isEmpty()){
                 throw new ApiException("部门条款编码重复!");
             }

--
Gitblit v1.9.2