mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 19:50:06 +08:00
整理 dept、post 模块的 url 地址
This commit is contained in:
parent
472ff81dd9
commit
78e847a81a
@ -46,7 +46,7 @@ export function addDept(data) {
|
|||||||
export function updateDept(data) {
|
export function updateDept(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/dept/update',
|
url: '/system/dept/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -55,6 +55,6 @@ export function updateDept(data) {
|
|||||||
export function delDept(id) {
|
export function delDept(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/dept/delete?id=' + id,
|
url: '/system/dept/delete?id=' + id,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ export function addPost(data) {
|
|||||||
export function updatePost(data) {
|
export function updatePost(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/post/update',
|
url: '/system/post/update',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ export function updatePost(data) {
|
|||||||
export function delPost(postId) {
|
export function delPost(postId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/post/delete?id=' + postId,
|
url: '/system/post/delete?id=' + postId,
|
||||||
method: 'post'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,22 +2,11 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
|
||||||
<el-form-item label="部门名称" prop="name">
|
<el-form-item label="部门名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="queryParams.name" placeholder="请输入部门名称" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.name"
|
|
||||||
placeholder="请输入部门名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small">
|
<el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small">
|
||||||
<el-option
|
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -28,24 +17,13 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:dept:create']">新增</el-button>
|
||||||
type="primary"
|
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:dept:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table
|
<el-table v-loading="loading" :data="deptList" row-key="id" default-expand-all
|
||||||
v-loading="loading"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
||||||
: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="name" label="部门名称" width="260"></el-table-column>
|
||||||
<el-table-column prop="sort" label="排序" width="200"></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>
|
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column>
|
||||||
@ -56,28 +34,12 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:dept:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['system:dept:create']">新增</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
<el-button v-if="scope.row.parentId !== 0" size="mini" type="text" icon="el-icon-delete"
|
||||||
v-hasPermi="['system:dept:edit']"
|
@click="handleDelete(scope.row)" v-hasPermi="['system:dept:delete']">删除</el-button>
|
||||||
>修改</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>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -119,11 +81,8 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="部门状态" prop="status">
|
<el-form-item label="部门状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio
|
<el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
|
||||||
v-for="dict in statusDictDatas"
|
{{dict.label}}</el-radio>
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
>{{dict.label}}</el-radio>
|
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -2,31 +2,14 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="岗位编码" prop="code">
|
<el-form-item label="岗位编码" prop="code">
|
||||||
<el-input
|
<el-input v-model="queryParams.code" placeholder="请输入岗位编码" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.code"
|
|
||||||
placeholder="请输入岗位编码"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="岗位名称" prop="name">
|
<el-form-item label="岗位名称" prop="name">
|
||||||
<el-input
|
<el-input v-model="queryParams.name" placeholder="请输入岗位名称" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||||
v-model="queryParams.name"
|
|
||||||
placeholder="请输入岗位名称"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
|
<el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
|
||||||
<el-option
|
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||||
v-for="dict in statusDictDatas"
|
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="parseInt(dict.value)"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -37,22 +20,12 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||||
type="primary"
|
v-hasPermi="['system:post:create']">新增</el-button>
|
||||||
icon="el-icon-plus"
|
|
||||||
size="mini"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:post:add']"
|
|
||||||
>新增</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:post:export']">导出</el-button>
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:post:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -70,31 +43,16 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
size="mini"
|
v-hasPermi="['system:post:update']">修改</el-button>
|
||||||
type="text"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
icon="el-icon-edit"
|
v-hasPermi="['system:post:delete']">删除</el-button>
|
||||||
@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>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
v-show="total>0"
|
@pagination="getList"/>
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNo"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改岗位对话框 -->
|
<!-- 添加或修改岗位对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
@ -110,11 +68,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="岗位状态" prop="status">
|
<el-form-item label="岗位状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio
|
<el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">
|
||||||
v-for="dict in statusDictDatas"
|
{{dict.label}}</el-radio>
|
||||||
:key="parseInt(dict.value)"
|
|
||||||
:label="parseInt(dict.value)"
|
|
||||||
>{{dict.label}}</el-radio>
|
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
|
@ -19,6 +19,7 @@ import cn.iocoder.dashboard.modules.system.service.user.SysUserService;
|
|||||||
import cn.iocoder.dashboard.util.collection.SetUtils;
|
import cn.iocoder.dashboard.util.collection.SetUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -34,6 +35,7 @@ import static cn.iocoder.dashboard.util.servlet.ServletUtils.getUserAgent;
|
|||||||
@Api(tags = "认证")
|
@Api(tags = "认证")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/")
|
@RequestMapping("/")
|
||||||
|
@Validated
|
||||||
public class SysAuthController {
|
public class SysAuthController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -45,8 +47,8 @@ public class SysAuthController {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysPermissionService permissionService;
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
@ApiOperation("使用账号密码登录")
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
|
@ApiOperation("使用账号密码登录")
|
||||||
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
|
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
|
||||||
public CommonResult<SysAuthLoginRespVO> login(@RequestBody @Valid SysAuthLoginReqVO reqVO) {
|
public CommonResult<SysAuthLoginRespVO> login(@RequestBody @Valid SysAuthLoginReqVO reqVO) {
|
||||||
String token = authService.login(reqVO, getClientIP(), getUserAgent());
|
String token = authService.login(reqVO, getClientIP(), getUserAgent());
|
||||||
@ -54,8 +56,8 @@ public class SysAuthController {
|
|||||||
return success(SysAuthLoginRespVO.builder().token(token).build());
|
return success(SysAuthLoginRespVO.builder().token(token).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取登陆用户的权限信息")
|
|
||||||
@GetMapping("/get-permission-info")
|
@GetMapping("/get-permission-info")
|
||||||
|
@ApiOperation("获取登陆用户的权限信息")
|
||||||
public CommonResult<SysAuthPermissionInfoRespVO> getPermissionInfo() {
|
public CommonResult<SysAuthPermissionInfoRespVO> getPermissionInfo() {
|
||||||
// 获得用户信息
|
// 获得用户信息
|
||||||
SysUserDO user = userService.getUser(getLoginUserId());
|
SysUserDO user = userService.getUser(getLoginUserId());
|
||||||
@ -65,7 +67,7 @@ public class SysAuthController {
|
|||||||
// 获得角色列表
|
// 获得角色列表
|
||||||
List<SysRoleDO> roleList = roleService.listRolesFromCache(getLoginUserRoleIds());
|
List<SysRoleDO> roleList = roleService.listRolesFromCache(getLoginUserRoleIds());
|
||||||
// 获得菜单列表
|
// 获得菜单列表
|
||||||
List<SysMenuDO> menuList = permissionService.listRoleMenusFromCache(
|
List<SysMenuDO> menuList = permissionService.getRoleMenusFromCache(
|
||||||
getLoginUserRoleIds(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它
|
getLoginUserRoleIds(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它
|
||||||
SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType(), MenuTypeEnum.BUTTON.getType()),
|
SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType(), MenuTypeEnum.BUTTON.getType()),
|
||||||
SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus()));
|
SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus()));
|
||||||
@ -73,11 +75,11 @@ public class SysAuthController {
|
|||||||
return success(SysAuthConvert.INSTANCE.convert(user, roleList, menuList));
|
return success(SysAuthConvert.INSTANCE.convert(user, roleList, menuList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获得登陆用户的菜单列表")
|
|
||||||
@GetMapping("list-menus")
|
@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(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它
|
getLoginUserRoleIds(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它
|
||||||
SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType()), // 只要目录和菜单类型
|
SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType()), // 只要目录和菜单类型
|
||||||
SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus())); // 只要开启的
|
SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus())); // 只要开启的
|
||||||
|
@ -39,9 +39,9 @@ public class SysUserSessionController {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysDeptService deptService;
|
private SysDeptService deptService;
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
@ApiOperation("获得 Session 分页列表")
|
@ApiOperation("获得 Session 分页列表")
|
||||||
@PreAuthorize("@ss.hasPermission('system:user-session:page')")
|
@PreAuthorize("@ss.hasPermission('system:user-session:page')")
|
||||||
@GetMapping("/page")
|
|
||||||
public CommonResult<PageResult<SysUserSessionPageItemRespVO>> getUserSessionPage(@Validated SysUserSessionPageReqVO reqVO) {
|
public CommonResult<PageResult<SysUserSessionPageItemRespVO>> getUserSessionPage(@Validated SysUserSessionPageReqVO reqVO) {
|
||||||
// 获得 Session 分页
|
// 获得 Session 分页
|
||||||
PageResult<SysUserSessionDO> pageResult = userSessionService.getUserSessionPage(reqVO);
|
PageResult<SysUserSessionDO> pageResult = userSessionService.getUserSessionPage(reqVO);
|
||||||
@ -66,12 +66,12 @@ public class SysUserSessionController {
|
|||||||
return success(new PageResult<>(sessionList, pageResult.getTotal()));
|
return success(new PageResult<>(sessionList, pageResult.getTotal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除 Session")
|
|
||||||
@PreAuthorize("@ss.hasPermission('system:user-session:delete')")
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
|
@ApiOperation("删除 Session")
|
||||||
@ApiImplicitParam(name = "id", value = "Session 编号", required = true, dataTypeClass = String.class,
|
@ApiImplicitParam(name = "id", value = "Session 编号", required = true, dataTypeClass = String.class,
|
||||||
example = "fe50b9f6-d177-44b1-8da9-72ea34f63db7")
|
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);
|
userSessionService.deleteUserSession(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,12 @@ import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -21,65 +23,64 @@ import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
|||||||
@Api(tags = "部门")
|
@Api(tags = "部门")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dept")
|
@RequestMapping("/system/dept")
|
||||||
|
@Validated
|
||||||
public class SysDeptController {
|
public class SysDeptController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysDeptService deptService;
|
private SysDeptService deptService;
|
||||||
|
|
||||||
@ApiOperation("获取部门列表")
|
@PostMapping("create")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:dept:list')")
|
@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")
|
@GetMapping("/list")
|
||||||
|
@ApiOperation("获取部门列表")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||||
public CommonResult<List<SysDeptRespVO>> listDepts(SysDeptListReqVO reqVO) {
|
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));
|
list.sort(Comparator.comparing(SysDeptDO::getSort));
|
||||||
return success(SysDeptConvert.INSTANCE.convertList(list));
|
return success(SysDeptConvert.INSTANCE.convertList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取部门精简信息列表", notes = "只包含被开启的部门,主要用于前端的下拉选项")
|
|
||||||
@GetMapping("/list-all-simple")
|
@GetMapping("/list-all-simple")
|
||||||
public CommonResult<List<SysDeptSimpleRespVO>> listSimpleDepts() {
|
@ApiOperation(value = "获取部门精简信息列表", notes = "只包含被开启的部门,主要用于前端的下拉选项")
|
||||||
|
public CommonResult<List<SysDeptSimpleRespVO>> getSimpleDepts() {
|
||||||
// 获得部门列表,只要开启状态的
|
// 获得部门列表,只要开启状态的
|
||||||
SysDeptListReqVO reqVO = new SysDeptListReqVO();
|
SysDeptListReqVO reqVO = new SysDeptListReqVO();
|
||||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
List<SysDeptDO> list = deptService.listDepts(reqVO);
|
List<SysDeptDO> list = deptService.getSimpleDepts(reqVO);
|
||||||
// 排序后,返回给前端
|
// 排序后,返回给前端
|
||||||
list.sort(Comparator.comparing(SysDeptDO::getSort));
|
list.sort(Comparator.comparing(SysDeptDO::getSort));
|
||||||
return success(SysDeptConvert.INSTANCE.convertList02(list));
|
return success(SysDeptConvert.INSTANCE.convertList02(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
@ApiOperation("获得部门信息")
|
@ApiOperation("获得部门信息")
|
||||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||||
// @PreAuthorize("@ss.hasPermi('system:dept:query')")
|
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||||
@GetMapping("/get")
|
|
||||||
public CommonResult<SysDeptRespVO> getDept(@RequestParam("id") Long id) {
|
public CommonResult<SysDeptRespVO> getDept(@RequestParam("id") Long id) {
|
||||||
return success(SysDeptConvert.INSTANCE.convert(deptService.getDept(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
|||||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||||
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
|
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.controller.dept.vo.post.*;
|
||||||
import cn.iocoder.dashboard.modules.system.convert.dept.SysPostConvert;
|
import cn.iocoder.dashboard.modules.system.convert.dept.SysPostConvert;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysPostDO;
|
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.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
|
||||||
@Api(tags = "岗位")
|
@Api(tags = "岗位")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/post")
|
@RequestMapping("/system/post")
|
||||||
|
@Valid
|
||||||
public class SysPostController {
|
public class SysPostController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysPostService postService;
|
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")
|
@PostMapping("/create")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:post:add')")
|
@ApiOperation("创建岗位")
|
||||||
// @Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
@PreAuthorize("@ss.hasPermission('system:post:create')")
|
||||||
public CommonResult<Long> createPost(@Validated @RequestBody SysPostCreateReqVO reqVO) {
|
public CommonResult<Long> createPost(@Valid @RequestBody SysPostCreateReqVO reqVO) {
|
||||||
Long postId = postService.createPost(reqVO);
|
Long postId = postService.createPost(reqVO);
|
||||||
return success(postId);
|
return success(postId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
@ApiOperation("修改岗位")
|
@ApiOperation("修改岗位")
|
||||||
@PostMapping("/update")
|
@PreAuthorize("@ss.hasPermission('system:post:update')")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:post:edit')")
|
public CommonResult<Boolean> updatePost(@Valid @RequestBody SysPostUpdateReqVO reqVO) {
|
||||||
// @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
|
||||||
public CommonResult<Boolean> updatePost(@Validated @RequestBody SysPostUpdateReqVO reqVO) {
|
|
||||||
postService.updatePost(reqVO);
|
postService.updatePost(reqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
@ApiOperation("删除岗位")
|
@ApiOperation("删除岗位")
|
||||||
@PostMapping("/delete")
|
@PreAuthorize("@ss.hasPermission('system:post:delete')")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:post:remove')")
|
|
||||||
// @Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
|
||||||
public CommonResult<Boolean> deletePost(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> deletePost(@RequestParam("id") Long id) {
|
||||||
postService.deletePost(id);
|
postService.deletePost(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/get")
|
||||||
@ApiOperation("获得岗位信息")
|
@ApiOperation("获得岗位信息")
|
||||||
@ApiImplicitParam(name = "id", value = "岗位编号", required = true, example = "1024", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "岗位编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||||
// @PreAuthorize("@ss.hasPermi('system:post:query')")
|
@PreAuthorize("@ss.hasPermission('system:post:query')")
|
||||||
@GetMapping(value = "/get")
|
|
||||||
public CommonResult<SysPostRespVO> getPost(@RequestParam("id") Long id) {
|
public CommonResult<SysPostRespVO> getPost(@RequestParam("id") Long id) {
|
||||||
return success(SysPostConvert.INSTANCE.convert(postService.getPost(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")
|
@GetMapping("/export")
|
||||||
@ApiOperation("岗位管理")
|
@ApiOperation("岗位管理")
|
||||||
// @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
@PreAuthorize("@ss.hasPermission('system:post:export')")
|
||||||
// @PreAuthorize("@ss.hasPermi('system:post:export')")
|
@OperateLog(type = EXPORT)
|
||||||
public void export(HttpServletResponse response, @Validated SysPostExportReqVO reqVO) throws IOException {
|
public void export(HttpServletResponse response, @Validated SysPostExportReqVO reqVO) throws IOException {
|
||||||
List<SysPostDO> posts = postService.listPosts(reqVO);
|
List<SysPostDO> posts = postService.getPosts(reqVO);
|
||||||
List<SysPostExcelVO> excelDataList = SysPostConvert.INSTANCE.convertList03(posts);
|
List<SysPostExcelVO> data = SysPostConvert.INSTANCE.convertList03(posts);
|
||||||
// 输出
|
// 输出
|
||||||
ExcelUtils.write(response, "岗位数据.xls", "岗位列表",
|
ExcelUtils.write(response, "岗位数据.xls", "岗位列表", SysPostExcelVO.class, data);
|
||||||
SysPostExcelVO.class, excelDataList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,53 +24,6 @@ public interface SysDeptService {
|
|||||||
*/
|
*/
|
||||||
void initLocalCache();
|
void initLocalCache();
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得指定编号的部门列表
|
|
||||||
*
|
|
||||||
* @param ids 部门编号数组
|
|
||||||
* @return 部门列表
|
|
||||||
*/
|
|
||||||
List<SysDeptDO> listDepts(Collection<Long> ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得指定编号的部门 Map
|
|
||||||
*
|
|
||||||
* @param ids 部门编号数组
|
|
||||||
* @return 部门 Map
|
|
||||||
*/
|
|
||||||
default Map<Long, SysDeptDO> getDeptMap(Collection<Long> ids) {
|
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
List<SysDeptDO> list = listDepts(ids);
|
|
||||||
return CollectionUtils.convertMap(list, SysDeptDO::getId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 筛选部门列表
|
|
||||||
*
|
|
||||||
* @param reqVO 筛选条件请求 VO
|
|
||||||
* @return 部门列表
|
|
||||||
*/
|
|
||||||
List<SysDeptDO> listDepts(SysDeptListReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得所有子部门,从缓存中
|
|
||||||
*
|
|
||||||
* @param parentId 部门编号
|
|
||||||
* @param recursive 是否递归获取所有
|
|
||||||
* @return 子部门列表
|
|
||||||
*/
|
|
||||||
List<SysDeptDO> listDeptsByParentIdFromCache(Long parentId, boolean recursive);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得部门信息
|
|
||||||
*
|
|
||||||
* @param id 部门编号
|
|
||||||
* @return 部门信息
|
|
||||||
*/
|
|
||||||
SysDeptDO getDept(Long id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建部门
|
* 创建部门
|
||||||
*
|
*
|
||||||
@ -93,4 +46,51 @@ public interface SysDeptService {
|
|||||||
*/
|
*/
|
||||||
void deleteDept(Long id);
|
void deleteDept(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定编号的部门列表
|
||||||
|
*
|
||||||
|
* @param ids 部门编号数组
|
||||||
|
* @return 部门列表
|
||||||
|
*/
|
||||||
|
List<SysDeptDO> getSimpleDepts(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定编号的部门 Map
|
||||||
|
*
|
||||||
|
* @param ids 部门编号数组
|
||||||
|
* @return 部门 Map
|
||||||
|
*/
|
||||||
|
default Map<Long, SysDeptDO> getDeptMap(Collection<Long> ids) {
|
||||||
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<SysDeptDO> list = getSimpleDepts(ids);
|
||||||
|
return CollectionUtils.convertMap(list, SysDeptDO::getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选部门列表
|
||||||
|
*
|
||||||
|
* @param reqVO 筛选条件请求 VO
|
||||||
|
* @return 部门列表
|
||||||
|
*/
|
||||||
|
List<SysDeptDO> getSimpleDepts(SysDeptListReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得部门信息
|
||||||
|
*
|
||||||
|
* @param id 部门编号
|
||||||
|
* @return 部门信息
|
||||||
|
*/
|
||||||
|
SysDeptDO getDept(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得所有子部门,从缓存中
|
||||||
|
*
|
||||||
|
* @param parentId 部门编号
|
||||||
|
* @param recursive 是否递归获取所有
|
||||||
|
* @return 子部门列表
|
||||||
|
*/
|
||||||
|
List<SysDeptDO> getDeptsByParentIdFromCache(Long parentId, boolean recursive);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,39 +18,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface SysPostService {
|
public interface SysPostService {
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得符合条件的岗位列表
|
|
||||||
*
|
|
||||||
* @param ids 岗位编号数组。如果为空,不进行筛选
|
|
||||||
* @param statuses 状态数组。如果为空,不进行筛选
|
|
||||||
* @return 部门列表
|
|
||||||
*/
|
|
||||||
List<SysPostDO> listPosts(@Nullable Collection<Long> ids, @Nullable Collection<Integer> statuses);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得岗位分页列表
|
|
||||||
*
|
|
||||||
* @param reqVO 分页条件
|
|
||||||
* @return 部门分页列表
|
|
||||||
*/
|
|
||||||
PageResult<SysPostDO> pagePosts(SysPostPageReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得岗位列表
|
|
||||||
*
|
|
||||||
* @param reqVO 查询条件
|
|
||||||
* @return 部门列表
|
|
||||||
*/
|
|
||||||
List<SysPostDO> listPosts(SysPostExportReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得岗位信息
|
|
||||||
*
|
|
||||||
* @param id 岗位编号
|
|
||||||
* @return 岗位信息
|
|
||||||
*/
|
|
||||||
SysPostDO getPost(Long id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建岗位
|
* 创建岗位
|
||||||
*
|
*
|
||||||
@ -73,4 +40,37 @@ public interface SysPostService {
|
|||||||
*/
|
*/
|
||||||
void deletePost(Long id);
|
void deletePost(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得符合条件的岗位列表
|
||||||
|
*
|
||||||
|
* @param ids 岗位编号数组。如果为空,不进行筛选
|
||||||
|
* @param statuses 状态数组。如果为空,不进行筛选
|
||||||
|
* @return 部门列表
|
||||||
|
*/
|
||||||
|
List<SysPostDO> getPosts(@Nullable Collection<Long> ids, @Nullable Collection<Integer> statuses);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得岗位分页列表
|
||||||
|
*
|
||||||
|
* @param reqVO 分页条件
|
||||||
|
* @return 部门分页列表
|
||||||
|
*/
|
||||||
|
PageResult<SysPostDO> getPostPage(SysPostPageReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得岗位列表
|
||||||
|
*
|
||||||
|
* @param reqVO 查询条件
|
||||||
|
* @return 部门列表
|
||||||
|
*/
|
||||||
|
List<SysPostDO> getPosts(SysPostExportReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得岗位信息
|
||||||
|
*
|
||||||
|
* @param id 岗位编号
|
||||||
|
* @return 岗位信息
|
||||||
|
*/
|
||||||
|
SysPostDO getPost(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import com.google.common.collect.Multimap;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -32,6 +33,7 @@ import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
|
|||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Validated
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SysDeptServiceImpl implements SysDeptService {
|
public class SysDeptServiceImpl implements SysDeptService {
|
||||||
|
|
||||||
@ -47,6 +49,7 @@ public class SysDeptServiceImpl implements SysDeptService {
|
|||||||
*
|
*
|
||||||
* 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
|
* 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
private volatile Map<Long, SysDeptDO> deptCache;
|
private volatile Map<Long, SysDeptDO> deptCache;
|
||||||
/**
|
/**
|
||||||
* 父部门缓存
|
* 父部门缓存
|
||||||
@ -118,17 +121,55 @@ public class SysDeptServiceImpl implements SysDeptService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
return deptMapper.selectBatchIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysDeptDO> listDepts(SysDeptListReqVO reqVO) {
|
public List<SysDeptDO> getSimpleDepts(SysDeptListReqVO reqVO) {
|
||||||
return deptMapper.selectList(reqVO);
|
return deptMapper.selectList(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysDeptDO> listDeptsByParentIdFromCache(Long parentId, boolean recursive) {
|
public List<SysDeptDO> getDeptsByParentIdFromCache(Long parentId, boolean recursive) {
|
||||||
List<SysDeptDO> result = new ArrayList<>();
|
List<SysDeptDO> result = new ArrayList<>();
|
||||||
// 递归,简单粗暴
|
// 递归,简单粗暴
|
||||||
this.listDeptsByParentIdFromCache(result, parentId,
|
this.listDeptsByParentIdFromCache(result, parentId,
|
||||||
@ -167,44 +208,6 @@ public class SysDeptServiceImpl implements SysDeptService {
|
|||||||
return deptMapper.selectById(id);
|
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) {
|
private void checkCreateOrUpdate(Long id, Long parentId, String name) {
|
||||||
// 校验自己存在
|
// 校验自己存在
|
||||||
checkDeptExists(id);
|
checkDeptExists(id);
|
||||||
@ -232,7 +235,7 @@ public class SysDeptServiceImpl implements SysDeptService {
|
|||||||
throw ServiceExceptionUtil.exception(DEPT_NOT_ENABLE);
|
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))) {
|
if (children.stream().anyMatch(dept1 -> dept1.getId().equals(parentId))) {
|
||||||
throw ServiceExceptionUtil.exception(DEPT_PARENT_IS_CHILD);
|
throw ServiceExceptionUtil.exception(DEPT_PARENT_IS_CHILD);
|
||||||
}
|
}
|
||||||
@ -262,12 +265,6 @@ public class SysDeptServiceImpl implements SysDeptService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 查询部门管理数据
|
|
||||||
// *
|
|
||||||
// * @param dept 部门信息
|
|
||||||
// * @return 部门信息集合
|
|
||||||
// */
|
|
||||||
// @Override
|
// @Override
|
||||||
// @DataScope(deptAlias = "d")
|
// @DataScope(deptAlias = "d")
|
||||||
// public List<SysDept> selectDeptList(SysDept dept)
|
// public List<SysDept> selectDeptList(SysDept dept)
|
||||||
|
@ -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.dal.dataobject.dept.SysPostDO;
|
||||||
import cn.iocoder.dashboard.modules.system.service.dept.SysPostService;
|
import cn.iocoder.dashboard.modules.system.service.dept.SysPostService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -24,31 +25,12 @@ import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
|
|||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Validated
|
||||||
public class SysPostServiceImpl implements SysPostService {
|
public class SysPostServiceImpl implements SysPostService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysPostMapper postMapper;
|
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
|
@Override
|
||||||
public Long createPost(SysPostCreateReqVO reqVO) {
|
public Long createPost(SysPostCreateReqVO reqVO) {
|
||||||
// 校验正确性
|
// 校验正确性
|
||||||
@ -68,6 +50,34 @@ public class SysPostServiceImpl implements SysPostService {
|
|||||||
postMapper.updateById(updateObj);
|
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) {
|
private void checkCreateOrUpdate(Long id, String name, String code) {
|
||||||
// 校验自己存在
|
// 校验自己存在
|
||||||
checkPostExists(id);
|
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) {
|
private void checkPostExists(Long id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -32,7 +32,7 @@ public interface SysPermissionService extends SecurityPermissionFrameworkService
|
|||||||
* @param menusStatuses 菜单状态数组
|
* @param menusStatuses 菜单状态数组
|
||||||
* @return 菜单列表
|
* @return 菜单列表
|
||||||
*/
|
*/
|
||||||
List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
|
List<SysMenuDO> getRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
|
||||||
Collection<Integer> menusStatuses);
|
Collection<Integer> menusStatuses);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,7 +133,7 @@ public class SysPermissionServiceImpl implements SysPermissionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysMenuDO> listRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
|
public List<SysMenuDO> getRoleMenusFromCache(Collection<Long> roleIds, Collection<Integer> menuTypes,
|
||||||
Collection<Integer> menusStatuses) {
|
Collection<Integer> menusStatuses) {
|
||||||
// 任一一个参数为空时,不返回任何菜单
|
// 任一一个参数为空时,不返回任何菜单
|
||||||
if (CollectionUtils.isAnyEmpty(roleIds, menusStatuses, menusStatuses)) {
|
if (CollectionUtils.isAnyEmpty(roleIds, menusStatuses, menusStatuses)) {
|
||||||
|
@ -113,7 +113,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
if (deptId == null) {
|
if (deptId == null) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
Set<Long> deptIds = CollectionUtils.convertSet(deptService.listDeptsByParentIdFromCache(
|
Set<Long> deptIds = CollectionUtils.convertSet(deptService.getDeptsByParentIdFromCache(
|
||||||
deptId, true), SysDeptDO::getId);
|
deptId, true), SysDeptDO::getId);
|
||||||
deptIds.add(deptId); // 包括自身
|
deptIds.add(deptId); // 包括自身
|
||||||
return deptIds;
|
return deptIds;
|
||||||
@ -287,7 +287,7 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
if (CollUtil.isEmpty(postIds)) { // 允许不选择
|
if (CollUtil.isEmpty(postIds)) { // 允许不选择
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<SysPostDO> posts = postService.listPosts(postIds, null);
|
List<SysPostDO> posts = postService.getPosts(postIds, null);
|
||||||
if (CollUtil.isEmpty(posts)) {
|
if (CollUtil.isEmpty(posts)) {
|
||||||
throw ServiceExceptionUtil.exception(POST_NOT_FOUND);
|
throw ServiceExceptionUtil.exception(POST_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class SysDeptServiceTest extends BaseDbUnitTest {
|
|||||||
reqVO.setName("开");
|
reqVO.setName("开");
|
||||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
// 调用
|
// 调用
|
||||||
List<SysDeptDO> sysDeptDOS = deptService.listDepts(reqVO);
|
List<SysDeptDO> sysDeptDOS = deptService.getSimpleDepts(reqVO);
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(1, sysDeptDOS.size());
|
assertEquals(1, sysDeptDOS.size());
|
||||||
assertPojoEquals(dept, sysDeptDOS.get(0));
|
assertPojoEquals(dept, sysDeptDOS.get(0));
|
||||||
|
@ -59,7 +59,7 @@ class SysPostServiceTest extends BaseDbUnitTest {
|
|||||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
PageResult<SysPostDO> pageResult = postService.pagePosts(reqVO);
|
PageResult<SysPostDO> pageResult = postService.getPostPage(reqVO);
|
||||||
|
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(1, pageResult.getTotal());
|
assertEquals(1, pageResult.getTotal());
|
||||||
@ -85,7 +85,7 @@ class SysPostServiceTest extends BaseDbUnitTest {
|
|||||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
List<SysPostDO> list = postService.listPosts(reqVO);
|
List<SysPostDO> list = postService.getPosts(reqVO);
|
||||||
// 断言
|
// 断言
|
||||||
assertEquals(1, list.size());
|
assertEquals(1, list.size());
|
||||||
assertPojoEquals(postDO, list.get(0));
|
assertPojoEquals(postDO, list.get(0));
|
||||||
|
Loading…
Reference in New Issue
Block a user