Browse Source

整理 dept、post 模块的 url 地址

YunaiV 4 years ago
parent
commit
78e847a81a
17 changed files with 256 additions and 339 deletions
  1. 2 2
      ruoyi-ui/src/api/system/dept.js
  2. 2 2
      ruoyi-ui/src/api/system/post.js
  3. 13 54
      ruoyi-ui/src/views/system/dept/index.vue
  4. 15 60
      ruoyi-ui/src/views/system/post/index.vue
  5. 8 6
      src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysAuthController.java
  6. 4 4
      src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysUserSessionController.java
  7. 36 35
      src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java
  8. 37 36
      src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysPostController.java
  9. 30 30
      src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java
  10. 25 25
      src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java
  11. 45 48
      src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java
  12. 30 28
      src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysPostServiceImpl.java
  13. 2 2
      src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysPermissionService.java
  14. 2 2
      src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysPermissionServiceImpl.java
  15. 2 2
      src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java
  16. 1 1
      src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptServiceTest.java
  17. 2 2
      src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostServiceTest.java

+ 2 - 2
ruoyi-ui/src/api/system/dept.js

@@ -46,7 +46,7 @@ export function addDept(data) {
 export function updateDept(data) {
   return request({
     url: '/system/dept/update',
-    method: 'post',
+    method: 'put',
     data: data
   })
 }
@@ -55,6 +55,6 @@ export function updateDept(data) {
 export function delDept(id) {
   return request({
     url: '/system/dept/delete?id=' + id,
-    method: 'post'
+    method: 'delete'
   })
 }

+ 2 - 2
ruoyi-ui/src/api/system/post.js

@@ -38,7 +38,7 @@ export function addPost(data) {
 export function updatePost(data) {
   return request({
     url: '/system/post/update',
-    method: 'post',
+    method: 'put',
     data: data
   })
 }
@@ -47,7 +47,7 @@ export function updatePost(data) {
 export function delPost(postId) {
   return request({
     url: '/system/post/delete?id=' + postId,
-    method: 'post'
+    method: 'delete'
   })
 }
 

+ 13 - 54
ruoyi-ui/src/views/system/dept/index.vue

@@ -2,22 +2,11 @@
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
       <el-form-item label="部门名称" prop="name">
-        <el-input
-          v-model="queryParams.name"
-          placeholder="请输入部门名称"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.name" placeholder="请输入部门名称" clearable size="small" @keyup.enter.native="handleQuery"/>
       </el-form-item>
       <el-form-item label="状态" prop="status">
         <el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small">
-          <el-option
-              v-for="dict in statusDictDatas"
-              :key="parseInt(dict.value)"
-              :label="dict.label"
-              :value="parseInt(dict.value)"
-          />
+          <el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
         </el-select>
       </el-form-item>
       <el-form-item>
@@ -28,24 +17,13 @@
 
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button
-          type="primary"
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd"
-          v-hasPermi="['system:dept:add']"
-        >新增</el-button>
+        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:dept:create']">新增</el-button>
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table
-      v-loading="loading"
-      :data="deptList"
-      row-key="id"
-      default-expand-all
-      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
-    >
+    <el-table v-loading="loading" :data="deptList" row-key="id" default-expand-all
+              :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
       <el-table-column prop="name" label="部门名称" width="260"></el-table-column>
       <el-table-column prop="sort" label="排序" width="200"></el-table-column>
       <el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column>
@@ -56,28 +34,12 @@
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-edit"
-            @click="handleUpdate(scope.row)"
-            v-hasPermi="['system:dept:edit']"
-          >修改</el-button>
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-plus"
-            @click="handleAdd(scope.row)"
-            v-hasPermi="['system:dept:add']"
-          >新增</el-button>
-          <el-button
-            v-if="scope.row.parentId !== 0"
-            size="mini"
-            type="text"
-            icon="el-icon-delete"
-            @click="handleDelete(scope.row)"
-            v-hasPermi="['system:dept:remove']"
-          >删除</el-button>
+          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
+                     v-hasPermi="['system:dept:update']">修改</el-button>
+          <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
+                     v-hasPermi="['system:dept:create']">新增</el-button>
+          <el-button v-if="scope.row.parentId !== 0" size="mini" type="text" icon="el-icon-delete"
+                     @click="handleDelete(scope.row)" v-hasPermi="['system:dept:delete']">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -119,11 +81,8 @@
           <el-col :span="12">
             <el-form-item label="部门状态" prop="status">
               <el-radio-group v-model="form.status">
-                <el-radio
-                    v-for="dict in statusDictDatas"
-                    :key="parseInt(dict.value)"
-                    :label="parseInt(dict.value)"
-                >{{dict.label}}</el-radio>
+                <el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
+                  {{dict.label}}</el-radio>
               </el-radio-group>
             </el-form-item>
           </el-col>

+ 15 - 60
ruoyi-ui/src/views/system/post/index.vue

@@ -2,31 +2,14 @@
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="岗位编码" prop="code">
-        <el-input
-          v-model="queryParams.code"
-          placeholder="请输入岗位编码"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.code" placeholder="请输入岗位编码" clearable size="small" @keyup.enter.native="handleQuery"/>
       </el-form-item>
       <el-form-item label="岗位名称" prop="name">
-        <el-input
-          v-model="queryParams.name"
-          placeholder="请输入岗位名称"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.name" placeholder="请输入岗位名称" clearable size="small" @keyup.enter.native="handleQuery"/>
       </el-form-item>
       <el-form-item label="状态" prop="status">
         <el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
-          <el-option
-              v-for="dict in statusDictDatas"
-              :key="parseInt(dict.value)"
-              :label="dict.label"
-              :value="parseInt(dict.value)"
-          />
+          <el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
         </el-select>
       </el-form-item>
       <el-form-item>
@@ -37,22 +20,12 @@
 
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button
-          type="primary"
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd"
-          v-hasPermi="['system:post:add']"
-        >新增</el-button>
+        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
+                   v-hasPermi="['system:post:create']">新增</el-button>
       </el-col>
       <el-col :span="1.5">
-        <el-button
-          type="warning"
-          icon="el-icon-download"
-          size="mini"
-          @click="handleExport"
-          v-hasPermi="['system:post:export']"
-        >导出</el-button>
+        <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
+                   v-hasPermi="['system:post:export']">导出</el-button>
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
@@ -70,31 +43,16 @@
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-edit"
-            @click="handleUpdate(scope.row)"
-            v-hasPermi="['system:post:edit']"
-          >修改</el-button>
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-delete"
-            @click="handleDelete(scope.row)"
-            v-hasPermi="['system:post:remove']"
-          >删除</el-button>
+          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
+                     v-hasPermi="['system:post:update']">修改</el-button>
+          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
+                     v-hasPermi="['system:post:delete']">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
 
-    <pagination
-      v-show="total>0"
-      :total="total"
-      :page.sync="queryParams.pageNo"
-      :limit.sync="queryParams.pageSize"
-      @pagination="getList"
-    />
+    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
+                @pagination="getList"/>
 
     <!-- 添加或修改岗位对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@@ -110,11 +68,8 @@
         </el-form-item>
         <el-form-item label="岗位状态" prop="status">
           <el-radio-group v-model="form.status">
-            <el-radio
-                v-for="dict in statusDictDatas"
-                :key="parseInt(dict.value)"
-                :label="parseInt(dict.value)"
-            >{{dict.label}}</el-radio>
+            <el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
+              {{dict.label}}</el-radio>
           </el-radio-group>
         </el-form-item>
         <el-form-item label="备注" prop="remark">

+ 8 - 6
src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysAuthController.java

@@ -19,6 +19,7 @@ import cn.iocoder.dashboard.modules.system.service.user.SysUserService;
 import cn.iocoder.dashboard.util.collection.SetUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -34,6 +35,7 @@ import static cn.iocoder.dashboard.util.servlet.ServletUtils.getUserAgent;
 @Api(tags = "认证")
 @RestController
 @RequestMapping("/")
+@Validated
 public class SysAuthController {
 
     @Resource
@@ -45,8 +47,8 @@ public class SysAuthController {
     @Resource
     private SysPermissionService permissionService;
 
-    @ApiOperation("使用账号密码登录")
     @PostMapping("/login")
+    @ApiOperation("使用账号密码登录")
     @OperateLog(enable = false) // 避免 Post 请求被记录操作日志
     public CommonResult<SysAuthLoginRespVO> login(@RequestBody @Valid SysAuthLoginReqVO reqVO) {
         String token = authService.login(reqVO, getClientIP(), getUserAgent());
@@ -54,8 +56,8 @@ public class SysAuthController {
         return success(SysAuthLoginRespVO.builder().token(token).build());
     }
 
-    @ApiOperation("获取登陆用户的权限信息")
     @GetMapping("/get-permission-info")
+    @ApiOperation("获取登陆用户的权限信息")
     public CommonResult<SysAuthPermissionInfoRespVO> getPermissionInfo() {
         // 获得用户信息
         SysUserDO user = userService.getUser(getLoginUserId());
@@ -65,7 +67,7 @@ public class SysAuthController {
         // 获得角色列表
         List<SysRoleDO> roleList = roleService.listRolesFromCache(getLoginUserRoleIds());
         // 获得菜单列表
-        List<SysMenuDO> menuList = permissionService.listRoleMenusFromCache(
+        List<SysMenuDO> menuList = permissionService.getRoleMenusFromCache(
                 getLoginUserRoleIds(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它
                 SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType(), MenuTypeEnum.BUTTON.getType()),
                 SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus()));
@@ -73,11 +75,11 @@ public class SysAuthController {
         return success(SysAuthConvert.INSTANCE.convert(user, roleList, menuList));
     }
 
-    @ApiOperation("获得登陆用户的菜单列表")
     @GetMapping("list-menus")
-    public CommonResult<List<SysAuthMenuRespVO>> listMenus() {
+    @ApiOperation("获得登陆用户的菜单列表")
+    public CommonResult<List<SysAuthMenuRespVO>> getMenus() {
         // 获得用户拥有的菜单列表
-        List<SysMenuDO> menuList = permissionService.listRoleMenusFromCache(
+        List<SysMenuDO> menuList = permissionService.getRoleMenusFromCache(
                 getLoginUserRoleIds(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它
                 SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType()), // 只要目录和菜单类型
                 SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus())); // 只要开启的

+ 4 - 4
src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysUserSessionController.java

@@ -39,9 +39,9 @@ public class SysUserSessionController {
     @Resource
     private SysDeptService deptService;
 
+    @GetMapping("/page")
     @ApiOperation("获得 Session 分页列表")
     @PreAuthorize("@ss.hasPermission('system:user-session:page')")
-    @GetMapping("/page")
     public CommonResult<PageResult<SysUserSessionPageItemRespVO>> getUserSessionPage(@Validated SysUserSessionPageReqVO reqVO) {
         // 获得 Session 分页
         PageResult<SysUserSessionDO> pageResult = userSessionService.getUserSessionPage(reqVO);
@@ -66,12 +66,12 @@ public class SysUserSessionController {
         return success(new PageResult<>(sessionList, pageResult.getTotal()));
     }
 
-    @ApiOperation("删除 Session")
-    @PreAuthorize("@ss.hasPermission('system:user-session:delete')")
     @DeleteMapping("/delete")
+    @ApiOperation("删除 Session")
     @ApiImplicitParam(name = "id", value = "Session 编号", required = true, dataTypeClass = String.class,
             example = "fe50b9f6-d177-44b1-8da9-72ea34f63db7")
-    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
+    @PreAuthorize("@ss.hasPermission('system:user-session:delete')")
+    public CommonResult<Boolean> deleteUserSession(@RequestParam("id") String id) {
         userSessionService.deleteUserSession(id);
         return success(true);
     }

+ 36 - 35
src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java

@@ -9,10 +9,12 @@ import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.validation.Valid;
 import java.util.Comparator;
 import java.util.List;
 
@@ -21,65 +23,64 @@ import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
 @Api(tags = "部门")
 @RestController
 @RequestMapping("/system/dept")
+@Validated
 public class SysDeptController {
 
     @Resource
     private SysDeptService deptService;
 
-    @ApiOperation("获取部门列表")
-//    @PreAuthorize("@ss.hasPermi('system:dept:list')")
+    @PostMapping("create")
+    @ApiOperation("创建部门")
+    @PreAuthorize("@ss.hasPermission('system:dept:create')")
+    public CommonResult<Long> createDept(@Valid @RequestBody SysDeptCreateReqVO reqVO) {
+        Long deptId = deptService.createDept(reqVO);
+        return success(deptId);
+    }
+
+    @PutMapping("update")
+    @ApiOperation("更新部门")
+    @PreAuthorize("@ss.hasPermission('system:dept:update')")
+    public CommonResult<Boolean> updateDept(@Valid @RequestBody SysDeptUpdateReqVO reqVO) {
+        deptService.updateDept(reqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("delete")
+    @ApiOperation("删除部门")
+    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+    @PreAuthorize("@ss.hasPermission('system:dept:delete')")
+    public CommonResult<Boolean> deleteDept(@RequestParam("id") Long id) {
+        deptService.deleteDept(id);
+        return success(true);
+    }
+
     @GetMapping("/list")
+    @ApiOperation("获取部门列表")
+    @PreAuthorize("@ss.hasPermission('system:dept:query')")
     public CommonResult<List<SysDeptRespVO>> listDepts(SysDeptListReqVO reqVO) {
-        List<SysDeptDO> list = deptService.listDepts(reqVO);
+        List<SysDeptDO> list = deptService.getSimpleDepts(reqVO);
         list.sort(Comparator.comparing(SysDeptDO::getSort));
         return success(SysDeptConvert.INSTANCE.convertList(list));
     }
 
-    @ApiOperation(value = "获取部门精简信息列表", notes = "只包含被开启的部门,主要用于前端的下拉选项")
     @GetMapping("/list-all-simple")
-    public CommonResult<List<SysDeptSimpleRespVO>> listSimpleDepts() {
+    @ApiOperation(value = "获取部门精简信息列表", notes = "只包含被开启的部门,主要用于前端的下拉选项")
+    public CommonResult<List<SysDeptSimpleRespVO>> getSimpleDepts() {
         // 获得部门列表,只要开启状态的
         SysDeptListReqVO reqVO = new SysDeptListReqVO();
         reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
-        List<SysDeptDO> list = deptService.listDepts(reqVO);
+        List<SysDeptDO> list = deptService.getSimpleDepts(reqVO);
         // 排序后,返回给前端
         list.sort(Comparator.comparing(SysDeptDO::getSort));
         return success(SysDeptConvert.INSTANCE.convertList02(list));
     }
 
+    @GetMapping("/get")
     @ApiOperation("获得部门信息")
     @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
-//    @PreAuthorize("@ss.hasPermi('system:dept:query')")
-    @GetMapping("/get")
+    @PreAuthorize("@ss.hasPermission('system:dept:query')")
     public CommonResult<SysDeptRespVO> getDept(@RequestParam("id") Long id) {
         return success(SysDeptConvert.INSTANCE.convert(deptService.getDept(id)));
     }
 
-    @ApiOperation("新增部门")
-    @PostMapping("create")
-//    @PreAuthorize("@ss.hasPermi('system:dept:add')")
-//    @Log(title = "部门管理", businessType = BusinessType.INSERT)
-    public CommonResult<Long> createDept(@Validated @RequestBody SysDeptCreateReqVO reqVO) {
-        Long deptId = deptService.createDept(reqVO);
-        return success(deptId);
-    }
-
-    @ApiOperation("修改部门")
-    @PostMapping("update")
-//    @PreAuthorize("@ss.hasPermi('system:dept:edit')")
-//    @Log(title = "部门管理", businessType = BusinessType.UPDATE)
-    public CommonResult<Boolean> updateDept(@Validated @RequestBody SysDeptUpdateReqVO reqVO) {
-        deptService.updateDept(reqVO);
-        return success(true);
-    }
-
-    @ApiOperation("删除部门")
-    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
-    @PostMapping("delete")
-//    @PreAuthorize("@ss.hasPermi('system:dept:remove')")
-//    @Log(title = "部门管理", businessType = BusinessType.DELETE)
-    public CommonResult<Boolean> deleteDept(@RequestParam("id") Long id) {
-        deptService.deleteDept(id);
-        return success(true);
-    }
 }

+ 37 - 36
src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysPostController.java

@@ -4,6 +4,7 @@ import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
 import cn.iocoder.dashboard.common.pojo.CommonResult;
 import cn.iocoder.dashboard.common.pojo.PageResult;
 import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog;
 import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.*;
 import cn.iocoder.dashboard.modules.system.convert.dept.SysPostConvert;
 import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysPostDO;
@@ -11,88 +12,88 @@ import cn.iocoder.dashboard.modules.system.service.dept.SysPostService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
 import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
+import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum.EXPORT;
 
 @Api(tags = "岗位")
 @RestController
 @RequestMapping("/system/post")
+@Valid
 public class SysPostController {
 
     @Resource
     private SysPostService postService;
 
-    @ApiOperation(value = "获取岗位精简信息列表", notes = "只包含被开启的岗位,主要用于前端的下拉选项")
-    @GetMapping("/list-all-simple")
-    public CommonResult<List<SysPostSimpleRespVO>> listSimplePosts() {
-        // 获得岗位列表,只要开启状态的
-        List<SysPostDO> list = postService.listPosts(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
-        // 排序后,返回给前端
-        list.sort(Comparator.comparing(SysPostDO::getSort));
-        return success(SysPostConvert.INSTANCE.convertList02(list));
-    }
-
-    @ApiOperation("获得岗位分页列表")
-    @GetMapping("/page")
-//    @PreAuthorize("@ss.hasPermi('system:post:list')")
-    public CommonResult<PageResult<SysPostRespVO>> pagePosts(@Validated SysPostPageReqVO reqVO) {
-        return success(SysPostConvert.INSTANCE.convertPage(postService.pagePosts(reqVO)));
-    }
-
-    @ApiOperation("新增岗位")
     @PostMapping("/create")
-//    @PreAuthorize("@ss.hasPermi('system:post:add')")
-//    @Log(title = "岗位管理", businessType = BusinessType.INSERT)
-    public CommonResult<Long> createPost(@Validated @RequestBody SysPostCreateReqVO reqVO) {
+    @ApiOperation("创建岗位")
+    @PreAuthorize("@ss.hasPermission('system:post:create')")
+    public CommonResult<Long> createPost(@Valid @RequestBody SysPostCreateReqVO reqVO) {
         Long postId = postService.createPost(reqVO);
         return success(postId);
     }
 
+    @PutMapping("/update")
     @ApiOperation("修改岗位")
-    @PostMapping("/update")
-//    @PreAuthorize("@ss.hasPermi('system:post:edit')")
-//    @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
-    public CommonResult<Boolean> updatePost(@Validated @RequestBody SysPostUpdateReqVO reqVO) {
+    @PreAuthorize("@ss.hasPermission('system:post:update')")
+    public CommonResult<Boolean> updatePost(@Valid @RequestBody SysPostUpdateReqVO reqVO) {
         postService.updatePost(reqVO);
         return success(true);
     }
 
+    @DeleteMapping("/delete")
     @ApiOperation("删除岗位")
-    @PostMapping("/delete")
-//    @PreAuthorize("@ss.hasPermi('system:post:remove')")
-//    @Log(title = "岗位管理", businessType = BusinessType.DELETE)
+    @PreAuthorize("@ss.hasPermission('system:post:delete')")
     public CommonResult<Boolean> deletePost(@RequestParam("id") Long id) {
         postService.deletePost(id);
         return success(true);
     }
 
+    @GetMapping(value = "/get")
     @ApiOperation("获得岗位信息")
     @ApiImplicitParam(name = "id", value = "岗位编号", required = true, example = "1024", dataTypeClass = Long.class)
-//    @PreAuthorize("@ss.hasPermi('system:post:query')")
-    @GetMapping(value = "/get")
+    @PreAuthorize("@ss.hasPermission('system:post:query')")
     public CommonResult<SysPostRespVO> getPost(@RequestParam("id") Long id) {
         return success(SysPostConvert.INSTANCE.convert(postService.getPost(id)));
     }
 
+    @GetMapping("/list-all-simple")
+    @ApiOperation(value = "获取岗位精简信息列表", notes = "只包含被开启的岗位,主要用于前端的下拉选项")
+    public CommonResult<List<SysPostSimpleRespVO>> getSimplePosts() {
+        // 获得岗位列表,只要开启状态的
+        List<SysPostDO> list = postService.getPosts(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
+        // 排序后,返回给前端
+        list.sort(Comparator.comparing(SysPostDO::getSort));
+        return success(SysPostConvert.INSTANCE.convertList02(list));
+    }
+
+    @GetMapping("/page")
+    @ApiOperation("获得岗位分页列表")
+    @PreAuthorize("@ss.hasPermission('system:post:query')")
+    public CommonResult<PageResult<SysPostRespVO>> getPostPage(@Validated SysPostPageReqVO reqVO) {
+        return success(SysPostConvert.INSTANCE.convertPage(postService.getPostPage(reqVO)));
+    }
+
     @GetMapping("/export")
     @ApiOperation("岗位管理")
-//    @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
-//    @PreAuthorize("@ss.hasPermi('system:post:export')")
+    @PreAuthorize("@ss.hasPermission('system:post:export')")
+    @OperateLog(type = EXPORT)
     public void export(HttpServletResponse response, @Validated SysPostExportReqVO reqVO) throws IOException {
-        List<SysPostDO> posts = postService.listPosts(reqVO);
-        List<SysPostExcelVO> excelDataList = SysPostConvert.INSTANCE.convertList03(posts);
+        List<SysPostDO> posts = postService.getPosts(reqVO);
+        List<SysPostExcelVO> data = SysPostConvert.INSTANCE.convertList03(posts);
         // 输出
-        ExcelUtils.write(response, "岗位数据.xls", "岗位列表",
-                SysPostExcelVO.class, excelDataList);
+        ExcelUtils.write(response, "岗位数据.xls", "岗位列表", SysPostExcelVO.class, data);
     }
 
 }

+ 30 - 30
src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java

@@ -24,13 +24,35 @@ public interface SysDeptService {
      */
     void initLocalCache();
 
+    /**
+     * 创建部门
+     *
+     * @param reqVO 部门信息
+     * @return 部门编号
+     */
+    Long createDept(SysDeptCreateReqVO reqVO);
+
+    /**
+     * 更新部门
+     *
+     * @param reqVO 部门信息
+     */
+    void updateDept(SysDeptUpdateReqVO reqVO);
+
+    /**
+     * 删除部门
+     *
+     * @param id 部门编号
+     */
+    void deleteDept(Long id);
+
     /**
      * 获得指定编号的部门列表
      *
      * @param ids 部门编号数组
      * @return 部门列表
      */
-    List<SysDeptDO> listDepts(Collection<Long> ids);
+    List<SysDeptDO> getSimpleDepts(Collection<Long> ids);
 
     /**
      * 获得指定编号的部门 Map
@@ -42,7 +64,7 @@ public interface SysDeptService {
         if (CollUtil.isEmpty(ids)) {
             return Collections.emptyMap();
         }
-        List<SysDeptDO> list = listDepts(ids);
+        List<SysDeptDO> list = getSimpleDepts(ids);
         return CollectionUtils.convertMap(list, SysDeptDO::getId);
     }
 
@@ -52,16 +74,7 @@ public interface SysDeptService {
      * @param reqVO 筛选条件请求 VO
      * @return 部门列表
      */
-    List<SysDeptDO> listDepts(SysDeptListReqVO reqVO);
-
-    /**
-     * 获得所有子部门,从缓存中
-     *
-     * @param parentId 部门编号
-     * @param recursive 是否递归获取所有
-     * @return 子部门列表
-     */
-    List<SysDeptDO> listDeptsByParentIdFromCache(Long parentId, boolean recursive);
+    List<SysDeptDO> getSimpleDepts(SysDeptListReqVO reqVO);
 
     /**
      * 获得部门信息
@@ -72,25 +85,12 @@ public interface SysDeptService {
     SysDeptDO getDept(Long id);
 
     /**
-     * 创建部门
-     *
-     * @param reqVO 部门信息
-     * @return 部门编号
-     */
-    Long createDept(SysDeptCreateReqVO reqVO);
-
-    /**
-     * 更新部门
-     *
-     * @param reqVO 部门信息
-     */
-    void updateDept(SysDeptUpdateReqVO reqVO);
-
-    /**
-     * 删除部门
+     * 获得所有子部门,从缓存中
      *
-     * @param id 部门编号
+     * @param parentId 部门编号
+     * @param recursive 是否递归获取所有
+     * @return 子部门列表
      */
-    void deleteDept(Long id);
+    List<SysDeptDO> getDeptsByParentIdFromCache(Long parentId, boolean recursive);
 
 }

+ 25 - 25
src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java

@@ -18,6 +18,28 @@ import java.util.List;
  */
 public interface SysPostService {
 
+    /**
+     * 创建岗位
+     *
+     * @param reqVO 岗位信息
+     * @return 岗位编号
+     */
+    Long createPost(SysPostCreateReqVO reqVO);
+
+    /**
+     * 更新岗位
+     *
+     * @param reqVO 岗位信息
+     */
+    void updatePost(SysPostUpdateReqVO reqVO);
+
+    /**
+     * 删除岗位信息
+     *
+     * @param id 岗位编号
+     */
+    void deletePost(Long id);
+
     /**
      * 获得符合条件的岗位列表
      *
@@ -25,7 +47,7 @@ public interface SysPostService {
      * @param statuses 状态数组。如果为空,不进行筛选
      * @return 部门列表
      */
-    List<SysPostDO> listPosts(@Nullable Collection<Long> ids, @Nullable Collection<Integer> statuses);
+    List<SysPostDO> getPosts(@Nullable Collection<Long> ids, @Nullable Collection<Integer> statuses);
 
     /**
      * 获得岗位分页列表
@@ -33,7 +55,7 @@ public interface SysPostService {
      * @param reqVO 分页条件
      * @return 部门分页列表
      */
-    PageResult<SysPostDO> pagePosts(SysPostPageReqVO reqVO);
+    PageResult<SysPostDO> getPostPage(SysPostPageReqVO reqVO);
 
     /**
      * 获得岗位列表
@@ -41,7 +63,7 @@ public interface SysPostService {
      * @param reqVO 查询条件
      * @return 部门列表
      */
-    List<SysPostDO> listPosts(SysPostExportReqVO reqVO);
+    List<SysPostDO> getPosts(SysPostExportReqVO reqVO);
 
     /**
      * 获得岗位信息
@@ -51,26 +73,4 @@ public interface SysPostService {
      */
     SysPostDO getPost(Long id);
 
-    /**
-     * 创建岗位
-     *
-     * @param reqVO 岗位信息
-     * @return 岗位编号
-     */
-    Long createPost(SysPostCreateReqVO reqVO);
-
-    /**
-     * 更新岗位
-     *
-     * @param reqVO 岗位信息
-     */
-    void updatePost(SysPostUpdateReqVO reqVO);
-
-    /**
-     * 删除岗位信息
-     *
-     * @param id 岗位编号
-     */
-    void deletePost(Long id);
-
 }

+ 45 - 48
src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java

@@ -19,6 +19,7 @@ import com.google.common.collect.Multimap;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
@@ -32,6 +33,7 @@ import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
  * @author 芋道源码
  */
 @Service
+@Validated
 @Slf4j
 public class SysDeptServiceImpl implements SysDeptService {
 
@@ -47,6 +49,7 @@ public class SysDeptServiceImpl implements SysDeptService {
      *
      * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
      */
+    @SuppressWarnings("FieldCanBeLocal")
     private volatile Map<Long, SysDeptDO> deptCache;
     /**
      * 父部门缓存
@@ -118,17 +121,55 @@ public class SysDeptServiceImpl implements SysDeptService {
     }
 
     @Override
-    public List<SysDeptDO> listDepts(Collection<Long> ids) {
+    public Long createDept(SysDeptCreateReqVO reqVO) {
+        // 校验正确性
+        checkCreateOrUpdate(null, reqVO.getParentId(), reqVO.getName());
+        // 插入部门
+        SysDeptDO dept = SysDeptConvert.INSTANCE.convert(reqVO);
+        deptMapper.insert(dept);
+        // 发送刷新消息
+        deptProducer.sendDeptRefreshMessage();
+        return dept.getId();
+    }
+
+    @Override
+    public void updateDept(SysDeptUpdateReqVO reqVO) {
+        // 校验正确性
+        checkCreateOrUpdate(reqVO.getId(), reqVO.getParentId(), reqVO.getName());
+        // 更新部门
+        SysDeptDO updateObj = SysDeptConvert.INSTANCE.convert(reqVO);
+        deptMapper.updateById(updateObj);
+        // 发送刷新消息
+        deptProducer.sendDeptRefreshMessage();
+    }
+
+    @Override
+    public void deleteDept(Long id) {
+        // 校验是否存在
+        checkDeptExists(id);
+        // 校验是否有子部门
+        if (deptMapper.selectCountByParentId(id) > 0) {
+            throw ServiceExceptionUtil.exception(DEPT_EXITS_CHILDREN);
+        }
+        // 删除部门
+        deptMapper.deleteById(id);
+        // TODO 需要处理下与角色的数据权限关联,等做数据权限一起处理下
+        // 发送刷新消息
+        deptProducer.sendDeptRefreshMessage();
+    }
+
+    @Override
+    public List<SysDeptDO> getSimpleDepts(Collection<Long> ids) {
         return deptMapper.selectBatchIds(ids);
     }
 
     @Override
-    public List<SysDeptDO> listDepts(SysDeptListReqVO reqVO) {
+    public List<SysDeptDO> getSimpleDepts(SysDeptListReqVO reqVO) {
         return deptMapper.selectList(reqVO);
     }
 
     @Override
-    public List<SysDeptDO> listDeptsByParentIdFromCache(Long parentId, boolean recursive) {
+    public List<SysDeptDO> getDeptsByParentIdFromCache(Long parentId, boolean recursive) {
         List<SysDeptDO> result = new ArrayList<>();
         // 递归,简单粗暴
         this.listDeptsByParentIdFromCache(result, parentId,
@@ -167,44 +208,6 @@ public class SysDeptServiceImpl implements SysDeptService {
         return deptMapper.selectById(id);
     }
 
-    @Override
-    public Long createDept(SysDeptCreateReqVO reqVO) {
-        // 校验正确性
-        checkCreateOrUpdate(null, reqVO.getParentId(), reqVO.getName());
-        // 插入部门
-        SysDeptDO dept = SysDeptConvert.INSTANCE.convert(reqVO);
-        deptMapper.insert(dept);
-        // 发送刷新消息
-        deptProducer.sendDeptRefreshMessage();
-        return dept.getId();
-    }
-
-    @Override
-    public void updateDept(SysDeptUpdateReqVO reqVO) {
-        // 校验正确性
-        checkCreateOrUpdate(reqVO.getId(), reqVO.getParentId(), reqVO.getName());
-        // 更新部门
-        SysDeptDO updateObj = SysDeptConvert.INSTANCE.convert(reqVO);
-        deptMapper.updateById(updateObj);
-        // 发送刷新消息
-        deptProducer.sendDeptRefreshMessage();
-    }
-
-    @Override
-    public void deleteDept(Long id) {
-        // 校验是否存在
-        checkDeptExists(id);
-        // 校验是否有子部门
-        if (deptMapper.selectCountByParentId(id) > 0) {
-            throw ServiceExceptionUtil.exception(DEPT_EXITS_CHILDREN);
-        }
-        // 删除部门
-        deptMapper.deleteById(id);
-        // TODO 需要处理下与角色的数据权限关联,等做数据权限一起处理下
-        // 发送刷新消息
-        deptProducer.sendDeptRefreshMessage();
-    }
-
     private void checkCreateOrUpdate(Long id, Long parentId, String name) {
         // 校验自己存在
         checkDeptExists(id);
@@ -232,7 +235,7 @@ public class SysDeptServiceImpl implements SysDeptService {
             throw ServiceExceptionUtil.exception(DEPT_NOT_ENABLE);
         }
         // 父部门不能是原来的子部门
-        List<SysDeptDO> children = this.listDeptsByParentIdFromCache(id, true);
+        List<SysDeptDO> children = this.getDeptsByParentIdFromCache(id, true);
         if (children.stream().anyMatch(dept1 -> dept1.getId().equals(parentId))) {
             throw ServiceExceptionUtil.exception(DEPT_PARENT_IS_CHILD);
         }
@@ -262,12 +265,6 @@ public class SysDeptServiceImpl implements SysDeptService {
         }
     }
 
-//    /**
-//     * 查询部门管理数据
-//     *
-//     * @param dept 部门信息
-//     * @return 部门信息集合
-//     */
 //    @Override
 //    @DataScope(deptAlias = "d")
 //    public List<SysDept> selectDeptList(SysDept dept)

+ 30 - 28
src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysPostServiceImpl.java

@@ -11,6 +11,7 @@ import cn.iocoder.dashboard.modules.system.dal.mysql.dept.SysPostMapper;
 import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysPostDO;
 import cn.iocoder.dashboard.modules.system.service.dept.SysPostService;
 import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
 import java.util.Collection;
@@ -24,31 +25,12 @@ import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
  * @author 芋道源码
  */
 @Service
+@Validated
 public class SysPostServiceImpl implements SysPostService {
 
     @Resource
     private SysPostMapper postMapper;
 
-    @Override
-    public List<SysPostDO> listPosts(Collection<Long> ids, Collection<Integer> statuses) {
-        return postMapper.selectList(ids, statuses);
-    }
-
-    @Override
-    public PageResult<SysPostDO> pagePosts(SysPostPageReqVO reqVO) {
-        return postMapper.selectPage(reqVO);
-    }
-
-    @Override
-    public List<SysPostDO> listPosts(SysPostExportReqVO reqVO) {
-        return postMapper.selectList(reqVO);
-    }
-
-    @Override
-    public SysPostDO getPost(Long id) {
-        return postMapper.selectById(id);
-    }
-
     @Override
     public Long createPost(SysPostCreateReqVO reqVO) {
         // 校验正确性
@@ -68,6 +50,34 @@ public class SysPostServiceImpl implements SysPostService {
         postMapper.updateById(updateObj);
     }
 
+    @Override
+    public void deletePost(Long id) {
+        // 校验是否存在
+        this.checkPostExists(id);
+        // 删除部门
+        postMapper.deleteById(id);
+    }
+
+    @Override
+    public List<SysPostDO> getPosts(Collection<Long> ids, Collection<Integer> statuses) {
+        return postMapper.selectList(ids, statuses);
+    }
+
+    @Override
+    public PageResult<SysPostDO> getPostPage(SysPostPageReqVO reqVO) {
+        return postMapper.selectPage(reqVO);
+    }
+
+    @Override
+    public List<SysPostDO> getPosts(SysPostExportReqVO reqVO) {
+        return postMapper.selectList(reqVO);
+    }
+
+    @Override
+    public SysPostDO getPost(Long id) {
+        return postMapper.selectById(id);
+    }
+
     private void checkCreateOrUpdate(Long id, String name, String code) {
         // 校验自己存在
         checkPostExists(id);
@@ -105,14 +115,6 @@ public class SysPostServiceImpl implements SysPostService {
         }
     }
 
-    @Override
-    public void deletePost(Long id) {
-        // 校验是否存在
-        this.checkPostExists(id);
-        // 删除部门
-        postMapper.deleteById(id);
-    }
-
     private void checkPostExists(Long id) {
         if (id == null) {
             return;

+ 2 - 2
src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysPermissionService.java

@@ -32,8 +32,8 @@ public interface SysPermissionService extends SecurityPermissionFrameworkService
      * @param menusStatuses 菜单状态数组
      * @return 菜单列表
      */
-    List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
-                                           Collection<Integer> menusStatuses);
+    List<SysMenuDO> getRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
+                                          Collection<Integer> menusStatuses);
 
     /**
      * 获得用户拥有的角色编号集合

+ 2 - 2
src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysPermissionServiceImpl.java

@@ -133,8 +133,8 @@ public class SysPermissionServiceImpl implements SysPermissionService {
     }
 
     @Override
-    public List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
-                                                  Collection<Integer> menusStatuses) {
+    public List<SysMenuDO> getRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
+                                                 Collection<Integer> menusStatuses) {
         // 任一一个参数为空时,不返回任何菜单
         if (CollectionUtils.isAnyEmpty(roleIds, menusStatuses, menusStatuses)) {
             return Collections.emptyList();

+ 2 - 2
src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java

@@ -113,7 +113,7 @@ public class SysUserServiceImpl implements SysUserService {
         if (deptId == null) {
             return Collections.emptySet();
         }
-        Set<Long> deptIds = CollectionUtils.convertSet(deptService.listDeptsByParentIdFromCache(
+        Set<Long> deptIds = CollectionUtils.convertSet(deptService.getDeptsByParentIdFromCache(
             deptId, true), SysDeptDO::getId);
         deptIds.add(deptId); // 包括自身
         return deptIds;
@@ -287,7 +287,7 @@ public class SysUserServiceImpl implements SysUserService {
         if (CollUtil.isEmpty(postIds)) { // 允许不选择
             return;
         }
-        List<SysPostDO> posts = postService.listPosts(postIds, null);
+        List<SysPostDO> posts = postService.getPosts(postIds, null);
         if (CollUtil.isEmpty(posts)) {
             throw ServiceExceptionUtil.exception(POST_NOT_FOUND);
         }

+ 1 - 1
src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptServiceTest.java

@@ -92,7 +92,7 @@ class SysDeptServiceTest extends BaseDbUnitTest {
         reqVO.setName("开");
         reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
         // 调用
-        List<SysDeptDO> sysDeptDOS = deptService.listDepts(reqVO);
+        List<SysDeptDO> sysDeptDOS = deptService.getSimpleDepts(reqVO);
         // 断言
         assertEquals(1, sysDeptDOS.size());
         assertPojoEquals(dept, sysDeptDOS.get(0));

+ 2 - 2
src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostServiceTest.java

@@ -59,7 +59,7 @@ class SysPostServiceTest extends BaseDbUnitTest {
         reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
 
         // 调用
-        PageResult<SysPostDO> pageResult = postService.pagePosts(reqVO);
+        PageResult<SysPostDO> pageResult = postService.getPostPage(reqVO);
 
         // 断言
         assertEquals(1, pageResult.getTotal());
@@ -85,7 +85,7 @@ class SysPostServiceTest extends BaseDbUnitTest {
         reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
 
         // 调用
-        List<SysPostDO> list = postService.listPosts(reqVO);
+        List<SysPostDO> list = postService.getPosts(reqVO);
         // 断言
         assertEquals(1, list.size());
         assertPojoEquals(postDO, list.get(0));