From 56dfe0d4bf81262622a1919cceb2b039fd356209 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期二, 03 九月 2024 16:52:49 +0800
Subject: [PATCH] 代码提交 bug解决

---
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java |   61 +++++++++++-------------------
 1 files changed, 23 insertions(+), 38 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java
index 875dd67..d067ba4 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDeptController.java
@@ -1,12 +1,15 @@
 package com.ruoyi.system.controller;
 
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import java.util.List;
 
+import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.system.domain.dto.deptQuery;
 import com.ruoyi.system.service.ISysDeptService;
 import io.swagger.annotations.Api;
-import org.apache.commons.lang3.ArrayUtils;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -16,8 +19,6 @@
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.common.core.constant.UserConstants;
-import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.log.annotation.Log;
@@ -42,31 +43,35 @@
     /**
      * 获取部门列表
      */
-    @RequiresPermissions("system:dept:list")
     @GetMapping("/list")
+    @ApiOperation("获取部门列表")
     public AjaxResult list(SysDept dept)
     {
         List<SysDept> depts = deptService.selectDeptList(dept);
         return success(depts);
     }
 
-    /**
-     * 查询部门列表(排除节点)
-     */
-    @RequiresPermissions("system:dept:list")
-    @GetMapping("/list/exclude/{deptId}")
-    public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
+    @GetMapping("/pagelist")
+    @ApiOperation("分页获取部门列表")
+    public AjaxResult pagelist(deptQuery dept)
     {
-        List<SysDept> depts = deptService.selectDeptList(new SysDept());
-        depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
-        return success(depts);
+        PageInfo<SysDept> pageInfo = new PageInfo<>(dept.getPageCurr(), dept.getPageSize());
+
+        PageInfo<SysDept> page = deptService.page(pageInfo,
+                new LambdaQueryWrapper<SysDept>().orderByDesc(SysDept::getCreateTime)
+                        .like(StringUtils.hasLength(dept.getDeptName()), SysDept::getDeptName,
+                                dept.getDeptName()).eq(SysDept::getDelFlag, "0"));
+        return AjaxResult.success(page);
     }
 
     /**
+     * 查询部门列表(排除节点)
+     */
+    /**
      * 根据部门编号获取详细信息
      */
-    @RequiresPermissions("system:dept:query")
     @GetMapping(value = "/{deptId}")
+    @ApiOperation("根据部门编号获取详细信息")
     public AjaxResult getInfo(@PathVariable Long deptId)
     {
         deptService.checkDeptDataScope(deptId);
@@ -76,15 +81,11 @@
     /**
      * 新增部门
      */
-    @RequiresPermissions("system:dept:add")
+    @ApiOperation("新增部门")
     @Log(title = "部门管理", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@Validated @RequestBody SysDept dept)
     {
-        if (!deptService.checkDeptNameUnique(dept))
-        {
-            return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
-        }
         dept.setCreateBy(SecurityUtils.getUsername());
         return toAjax(deptService.insertDept(dept));
     }
@@ -92,25 +93,13 @@
     /**
      * 修改部门
      */
-    @RequiresPermissions("system:dept:edit")
     @Log(title = "部门管理", businessType = BusinessType.UPDATE)
+    @ApiOperation("修改部门")
     @PutMapping
     public AjaxResult edit(@Validated @RequestBody SysDept dept)
     {
         Long deptId = dept.getDeptId();
         deptService.checkDeptDataScope(deptId);
-        if (!deptService.checkDeptNameUnique(dept))
-        {
-            return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
-        }
-        else if (dept.getParentId().equals(deptId))
-        {
-            return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
-        }
-        else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
-        {
-            return error("该部门包含未停用的子部门!");
-        }
         dept.setUpdateBy(SecurityUtils.getUsername());
         return toAjax(deptService.updateDept(dept));
     }
@@ -118,15 +107,11 @@
     /**
      * 删除部门
      */
-    @RequiresPermissions("system:dept:remove")
     @Log(title = "部门管理", businessType = BusinessType.DELETE)
     @DeleteMapping("/{deptId}")
+    @ApiOperation("删除部门管理")
     public AjaxResult remove(@PathVariable Long deptId)
     {
-        if (deptService.hasChildByDeptId(deptId))
-        {
-            return warn("存在下级部门,不允许删除");
-        }
         if (deptService.checkDeptExistUser(deptId))
         {
             return warn("部门存在用户,不允许删除");

--
Gitblit v1.7.1