From 9969bea2a8c1eab64c12a51a2d24d65e5b6c0dd0 Mon Sep 17 00:00:00 2001
From: wl <173@qq.com>
Date: 星期一, 24 十月 2022 18:12:41 +0800
Subject: [PATCH] 日志导出乱码 日志查询导出 代码重构

---
 ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java |   39 ++++++++++++---------------------------
 1 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java b/ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java
index 5979651..bc40ae3 100644
--- a/ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java
+++ b/ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java
@@ -1,14 +1,9 @@
 package com.ycl.service.depart.impl;
 
-import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ycl.dto.user.AdminDepartDTO;
 import com.ycl.entity.depart.UmsDepart;
-import com.ycl.entity.dict.DataDictionary;
-import com.ycl.entity.user.UmsDepartManage;
 import com.ycl.enums.common.ResultCode;
 import com.ycl.exception.ApiException;
 import com.ycl.mapper.depart.UmsDepartMapper;
@@ -17,7 +12,6 @@
 import com.ycl.service.depart.UmsDepartService;
 import com.ycl.service.user.UmsAdminService;
 import com.ycl.service.user.UmsDepartManageService;
-import com.ycl.utils.common.PojoUtils;
 import com.ycl.vo.depart.DepartVO;
 import com.ycl.vo.depart.UmsDepartVO;
 import org.apache.commons.lang3.StringUtils;
@@ -27,7 +21,6 @@
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -86,27 +79,20 @@
     @Transactional(rollbackFor = Exception.class)
     public void update(DepartVO.UpdateDepartVO updateDepartVO) {
         UmsDepart sccgDepart = this.queryByName(updateDepartVO.getDepartName());
-        if (null != sccgDepart && sccgDepart.getId() != updateDepartVO.getId()) {
+        if (null != sccgDepart && !sccgDepart.getId().equals(updateDepartVO.getId())) {
             throw new ApiException(ResultCode.RECORD_ALREADY_EXISTS);
         }
-        UmsDepart depart = this.getById(updateDepartVO.getId());
+        UmsDepart depart = new UmsDepart();
         BeanUtils.copyProperties(updateDepartVO, depart);
-        List<Long> userIds = updateDepartVO.getUserIds();
-        if (CollUtil.isNotEmpty(userIds)) {
-            Long departId = updateDepartVO.getId();
-            List<UmsDepartManage> departList = umsAdminDepartService.queryByDepartId(departId);
-            if (CollUtil.isNotEmpty(departList)) {
-                umsAdminDepartService.deletedByDepartId(departId);
-            }
-            userIds.forEach(e -> {
-                UmsDepartManage adminDepart = new UmsDepartManage();
-                adminDepart.setDepartId(departId);
-                adminDepart.setUserId(e);
-                umsAdminDepartService.save(adminDepart);
-            });
-        }
-        if (sccgDepartMapper.updateById(depart) != 1) {
-            throw new ApiException(ResultCode.RECORD_UPDATE_FAIL);
+        umsDepartService.updateById(depart);
+        if (updateDepartVO.getDepartManagerList().size() > 0) {
+            iDepartManagerService.deleteByDepartId(depart.getId());
+            updateDepartVO.getDepartManagerList()
+                    .forEach(item -> {
+                        item.setCreateTime(LocalDateTime.now());
+                        item.setDepartId(depart.getId());
+                    });
+            iDepartManagerService.saveBatch(updateDepartVO.getDepartManagerList());
         }
     }
 
@@ -202,5 +188,4 @@
         UmsDepart sccgDepart = this.sccgDepartMapper.selectOne(queryWrapper);
         return sccgDepart;
     }
-
-}
+}
\ No newline at end of file

--
Gitblit v1.8.0