Browse Source

树形部门菜单

marxjaw 3 months ago
parent
commit
d384b03fc2

+ 1 - 1
yt-app/app-service/src/main/resources/mapper/AppUserMapper.xml

@@ -201,7 +201,7 @@
                     #{item}
                 </foreach>
         </if>
-        order by last_login_time desc
+        order by user_id desc
     </select>
     <select id="selectPrimaryKey" resultType="com.ytpm.app.model.YtDyzUser">
         select

+ 2 - 0
yt-common/src/main/java/com/ytpm/middle/view/DropDownVO.java

@@ -19,6 +19,8 @@ public class DropDownVO {
     private Integer optionVal;
     @ApiModelProperty("上级ID")
     private Integer parentId;
+    @ApiModelProperty("是否选中")
+    private boolean checked;
     @ApiModelProperty("子级列表")
     private List<DropDownVO> children;
 }

+ 7 - 0
yt-middle/middle-platform/src/main/java/com/ytpm/middle/controller/DeptController.java

@@ -38,4 +38,11 @@ public class DeptController {
         param.setDefaultParam(userInfo.getUserId());
         return deptService.addOne(param);
     }
+
+    @ApiOperation("修改部门")
+    @PostMapping("/updateOne")
+    public Result<String> updateOne(@RequestBody MiddleDeptParam param,@ApiIgnore @AuthenticationPrincipal MiddleUserInfo userInfo) {
+        param.setUpdateParam(userInfo.getUserId());
+        return deptService.updateOne(param);
+    }
 }

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

@@ -25,8 +25,18 @@ public interface MiddleDeptMapper {
      */
     YtMiddleDept selectByName(@Param("deptName") String deptName);
 
+    /**
+     * 主键查询
+     */
+    YtMiddleDept selectPrimary(@Param("deptId") Integer deptId);
+
     /**
      * 新增部门信息
      */
     void insertOne(YtMiddleDept dept);
+
+    /**
+     * 主键修改
+     */
+    void updateById(YtMiddleDept dept);
 }

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

@@ -22,4 +22,9 @@ public interface DeptService {
      * 查询部门树形菜单
      */
     Result<DropDownVO> getDeptTree();
+
+    /**
+     * 修改部门信息
+     */
+    Result<String> updateOne(MiddleDeptParam param);
 }

+ 15 - 0
yt-middle/middle-platform/src/main/java/com/ytpm/middle/service/impl/DeptServiceImpl.java

@@ -64,6 +64,21 @@ public class DeptServiceImpl implements DeptService {
         return Result.resultObjOk(parent);
     }
 
+    /**
+     * 修改部门信息
+     */
+    @Override
+    public Result<String> updateOne(MiddleDeptParam param) {
+        YtMiddleDept old = deptMapper.selectPrimary(param.getDeptId());
+        if(Objects.nonNull(old)){
+            return Result.resultErr(RepMessage.OBJECT_ALREADY_EXIST);
+        }
+        YtMiddleDept dept = new YtMiddleDept();
+        BeanUtils.copyProperties(param, dept);
+        deptMapper.updateById(dept);
+        return Result.resultOk(RepMessage.MODIFY_SUCCESS);
+    }
+
     /**
      * 递归处理部门列表
      */

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

@@ -23,6 +23,33 @@
          #{available}
         )
     </insert>
+    <update id="updateById">
+        update yt_middle_dept
+        <set>
+            <if test=" parentId!=null" >
+                parent_id = #{parentId},
+            </if>
+            <if test=" deptId!=null" >
+                dept_name = #{deptId},
+            </if>
+            <if test=" describe!=null" >
+                `describe` = #{describe},
+            </if>
+            <if test=" !=null" >
+                sort = #{sort},
+            </if>
+            <if test=" !=null" >
+                update_time = #{updateTime},
+            </if>
+            <if test=" !=null" >
+                update_user_id = #{updateUserId},
+            </if>
+            <if test=" !=null" >
+                available = #{available}
+            </if>
+        </set>
+        where dept_id = #{deptId}
+    </update>
 
     <select id="queryList" resultType="com.ytpm.middle.view.MiddleDeptVO">
         select
@@ -46,4 +73,10 @@
         from yt_middle_dept
         where available = 1 and dept_name = #{deptName}
     </select>
+    <select id="selectPrimary" resultType="com.ytpm.middle.model.YtMiddleDept">
+        select
+            dept_id, parent_id, dept_name, `describe`, sort, create_time, create_user_id, update_time, update_user_id, available
+        from yt_middle_dept
+        where dept_id = #{deptId}
+    </select>
 </mapper>