Explorar o código

增加用户管理、用户角色相关接口
增加部门管理列表和新增接口
增加通用获取下拉选项管理
去掉import * 优化打包

marxjaw hai 3 meses
pai
achega
562a82b425

+ 2 - 0
yt-common/src/main/java/com/ytpm/middle/param/MiddleUserListParam.java

@@ -23,4 +23,6 @@ public class MiddleUserListParam extends BaseParam {
     private String loginName;
     @ApiModelProperty("账户状态")
     private Integer accountStatus;
+    @ApiModelProperty("部门ID")
+    private Integer deptId;
 }

+ 7 - 1
yt-common/src/main/java/com/ytpm/middle/view/DropDownVO.java

@@ -6,6 +6,8 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.List;
+
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
@@ -14,5 +16,9 @@ public class DropDownVO {
     @ApiModelProperty("下拉选项名")
     private String optionName;
     @ApiModelProperty("下拉选项值")
-    private String optionVal;
+    private Integer optionVal;
+    @ApiModelProperty("上级ID")
+    private Integer parentId;
+    @ApiModelProperty("子级列表")
+    private List<DropDownVO> children;
 }

+ 5 - 4
yt-middle/middle-platform/src/main/java/com/ytpm/middle/controller/DropdownController.java

@@ -1,5 +1,6 @@
 package com.ytpm.middle.controller;
 
+import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 import com.ytpm.middle.service.DeptService;
 import com.ytpm.middle.view.DropDownVO;
@@ -19,9 +20,9 @@ public class DropdownController {
     @Resource
     private DeptService deptService;
 
-    @ApiOperation("查询部门列表")
-    @GetMapping("/deptList")
-    public ResultTable<DropDownVO> deptList() {
-        return deptService.getDropDownList();
+    @ApiOperation("查询部门树形菜单")
+    @GetMapping("/deptTree")
+    public Result<DropDownVO> deptTree() {
+        return deptService.getDeptTree();
     }
 }

+ 1 - 1
yt-middle/middle-platform/src/main/java/com/ytpm/middle/dao/MiddleDeptMapper.java

@@ -18,7 +18,7 @@ public interface MiddleDeptMapper {
     /**
      * 获取部门下拉列表
      */
-    List<DropDownVO> getDropDownList();
+    List<DropDownVO> getAllDeptList();
 
     /**
      * 根据部门名称查询部门信息

+ 2 - 2
yt-middle/middle-platform/src/main/java/com/ytpm/middle/service/DeptService.java

@@ -19,7 +19,7 @@ public interface DeptService {
     Result<String> addOne(MiddleDeptParam param);
 
     /**
-     * 查询部门下拉列表
+     * 查询部门树形菜单
      */
-    ResultTable<DropDownVO> getDropDownList();
+    Result<DropDownVO> getDeptTree();
 }

+ 22 - 3
yt-middle/middle-platform/src/main/java/com/ytpm/middle/service/impl/DeptServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ytpm.middle.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ytpm.general.RepMessage;
@@ -16,7 +17,9 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 @Service
 public class DeptServiceImpl implements DeptService {
@@ -50,10 +53,26 @@ public class DeptServiceImpl implements DeptService {
     }
 
     /**
-     * 获取部门下拉列表
+     * 查询部门树形菜单
      */
     @Override
-    public ResultTable<DropDownVO> getDropDownList() {
-        return ResultTable.resultTableOk(new PageInfo<>(deptMapper.getDropDownList()));
+    public Result<DropDownVO> getDeptTree() {
+        List<DropDownVO> all = deptMapper.getAllDeptList();
+        DropDownVO parent = all.stream().filter(s -> Objects.isNull(s.getParentId())).collect(Collectors.toList()).get(0);
+        List<DropDownVO> next = all.stream().filter(s -> Objects.nonNull(s.getParentId())).collect(Collectors.toList());
+        recursionChildOption(parent,next);
+        return Result.resultObjOk(parent);
+    }
+
+    /**
+     * 递归处理部门列表
+     */
+    private void recursionChildOption(DropDownVO parent, List<DropDownVO> next) {
+        List<DropDownVO> collect = next.stream().filter(s -> Objects.equals(s.getParentId(), parent.getOptionVal())).collect(Collectors.toList());
+        if(CollUtil.isEmpty(collect))return;
+        parent.setChildren(collect);
+        for (DropDownVO vo : next) {
+            recursionChildOption(vo,next);
+        }
     }
 }

+ 4 - 1
yt-middle/middle-platform/src/main/resources/mapper/MiddleUserMapper.xml

@@ -114,7 +114,7 @@
         select
             ypu.user_id,
             ypu.dept_id,
-            ymd.dept_id,
+            ymd.dept_name,
             ymur.role_id,
             (select role_name from yt_middle_role where role_id = ymur.role_id) roleName,
             ypu.nick_name,
@@ -126,6 +126,9 @@
         left join yt_middle_user_role ymur on ypu.user_id = ymur.user_id
         left join yt_middle_dept ymd on ypu.dept_id = ymd.dept_id
         where ypu.user_type = 99 and ypu.account_status = 1
+        <if test=" deptId != null ">
+            and ypu.dept_id = #{deptId}
+        </if>
         <if test=" nickName!= null and nickName!= ''">
             and ypu.nick_name like concat('%', #{nickName} ,'%')
         </if>

+ 2 - 2
yt-middle/middle-platform/src/main/resources/mapper/MiddlerDeptMapper.xml

@@ -34,9 +34,9 @@
             </if>
         </where>
     </select>
-    <select id="getDropDownList" resultType="com.ytpm.middle.view.DropDownVO">
+    <select id="getAllDeptList" resultType="com.ytpm.middle.view.DropDownVO">
         select
-            dept_id optionName, dept_name optionVal
+            dept_id optionVal, dept_name optionName, parent_id
         from yt_middle_dept
         where available = 1
     </select>