From aaeb8af6dfb7334b72fe9e655024867686e4e56c Mon Sep 17 00:00:00 2001 From: wangwei <1610949092@qq.com> Date: Sun, 23 Apr 2023 11:52:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E5=92=8C=E4=BE=9B=E5=BA=94=E5=95=86?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E4=BF=A1=E6=81=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/auth/DeptUserController.java | 28 +++++++++++++++++++ .../controller/auth/SysUserController.java | 27 +++++++++++++++--- .../api/service/inout/IoOrderService.java | 1 + .../inout/impl/IoOrderServiceImpl.java | 6 ++++ 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/glxp/api/controller/auth/DeptUserController.java b/src/main/java/com/glxp/api/controller/auth/DeptUserController.java index 74a63577..a726a289 100644 --- a/src/main/java/com/glxp/api/controller/auth/DeptUserController.java +++ b/src/main/java/com/glxp/api/controller/auth/DeptUserController.java @@ -6,6 +6,7 @@ import com.glxp.api.annotation.Log; import com.glxp.api.constant.BusinessType; import com.glxp.api.entity.auth.DeptEntity; import com.glxp.api.entity.auth.DeptUserEntity; +import com.glxp.api.entity.inout.IoOrderEntity; import com.glxp.api.req.auth.FilterDeptUserReqeust; import com.glxp.api.req.auth.FilterInvWarehouseRequest; import com.glxp.api.res.PageSimpleResponse; @@ -14,6 +15,8 @@ import com.glxp.api.service.auth.DeptService; import com.glxp.api.service.auth.DeptUserService; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.service.auth.WarehouseUserService; +import com.glxp.api.service.inout.IoOrderService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -30,6 +33,11 @@ public class DeptUserController { DeptUserService deptUserService; @Resource DeptService deptService; + @Resource + IoOrderService ioOrderService; + + @Resource + WarehouseUserService warehouseUserService; @AuthRuleAnnotation("") @@ -56,6 +64,26 @@ public class DeptUserController { @PostMapping("udi/auth/dept/user/delete") @Log(title = "用户管理", businessType = BusinessType.DELETE) public BaseResponse delete(@RequestBody DeptUserEntity deptUserEntity) { + // 判断此用户是否创建单据 + List ioOrderEntities = ioOrderService.selectList(deptUserEntity.getUserId()); + if( ioOrderEntities != null){ + return ResultVOUtils.error(500,"该用户已创建单据,不能移除!"); + } + //判断此用户是否与仓库有关联 + List listWareHouse = warehouseUserService.selectCodeByUser(deptUserEntity.getUserId() + ""); + if( listWareHouse != null ){ + return ResultVOUtils.error(500,"该用户已绑定仓库,不能移除!"); + } + + //判断此用户是否与除一级部门 还绑定其他部门 + FilterDeptUserReqeust filterDeptUserReqeust = new FilterDeptUserReqeust(); + filterDeptUserReqeust.setUserId(deptUserEntity.getUserId()); + List deptUserEntities = deptUserService.selectDeptUser(filterDeptUserReqeust); + if( deptUserEntities != null && deptUserEntities.size()>1){ + return ResultVOUtils.error(500,"该用户已绑定多个部门,不能移除!"); + } + + boolean b = deptUserService.delete(deptUserEntity.getDeptId(), deptUserEntity.getUserId()); if (b) return ResultVOUtils.success("移除成功!"); diff --git a/src/main/java/com/glxp/api/controller/auth/SysUserController.java b/src/main/java/com/glxp/api/controller/auth/SysUserController.java index 5ea31ca1..ac1e44f7 100644 --- a/src/main/java/com/glxp/api/controller/auth/SysUserController.java +++ b/src/main/java/com/glxp/api/controller/auth/SysUserController.java @@ -11,6 +11,7 @@ import com.glxp.api.controller.BaseController; import com.glxp.api.entity.auth.*; import com.glxp.api.req.auth.FilterAuthUserRequest; import com.glxp.api.req.auth.AuthUserSaveRequest; +import com.glxp.api.req.auth.FilterDeptUserReqeust; import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.auth.AuthAdminResponse; import com.glxp.api.res.auth.DeptUserResponse; @@ -24,6 +25,7 @@ import com.glxp.api.util.StringUtils; import lombok.RequiredArgsConstructor; import org.codehaus.groovy.util.StringUtil; import org.springframework.beans.BeanUtils; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -42,6 +44,7 @@ import java.util.stream.Collectors; @RequiredArgsConstructor @RestController @RequestMapping("/system/user") +@Transactional(rollbackFor = Exception.class) public class SysUserController extends BaseController { private final AuthAdminService userService; @@ -293,10 +296,26 @@ public class SysUserController extends BaseController { userService.updateAuthAdmin(authAdmin); - //默认插入第一部门 - List deptCodeList=authUserSaveRequest.getDepts(); - deptCodeList.add(1L); - authUserSaveRequest.setDepts(deptCodeList); + //默认插入第一部门 + List deptCodeList = null; + FilterDeptUserReqeust filterDeptUserReqeust = new FilterDeptUserReqeust(); + filterDeptUserReqeust.setUserId(authUserSaveRequest.getId()); + List deptUserEntities = deptUserService.selectDeptUser(filterDeptUserReqeust); + if(deptUserEntities == null){ + deptCodeList.add(1L); + authUserSaveRequest.setDepts(deptCodeList); + }else{ + Boolean checkDeptId=false; + for (DeptUserEntity deptUserEntity : deptUserEntities) { + if(deptUserEntity.getDeptId() == 1){ + checkDeptId=true; + } + } + if(checkDeptId==false){ + deptCodeList.add(1L); + authUserSaveRequest.setDepts(deptCodeList); + } + } //修改所属部门 deptUserService.deleteByUser(authUserSaveRequest.getId()); diff --git a/src/main/java/com/glxp/api/service/inout/IoOrderService.java b/src/main/java/com/glxp/api/service/inout/IoOrderService.java index ca1b8386..0c4af4fd 100644 --- a/src/main/java/com/glxp/api/service/inout/IoOrderService.java +++ b/src/main/java/com/glxp/api/service/inout/IoOrderService.java @@ -122,4 +122,5 @@ public interface IoOrderService { boolean isExitByAction(String action); + List selectList(Long userId); } diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java index 637bb6b1..be308d25 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java @@ -803,6 +803,12 @@ public class IoOrderServiceImpl implements IoOrderService { return orderDao.exists(new QueryWrapper().eq("action", action)); } + @Override + public List selectList(Long userId) { + List ioOrderEntities = orderDao.selectList(new QueryWrapper().eq("createUser",userId)); + return ioOrderEntities; + } + /** * 查询此单据关联的所有单据 *