diff --git a/ruoyi-ui/src/api/system/dept.js b/ruoyi-ui/src/api/system/dept.js
index c22f0f4a8..d8c59cf9a 100644
--- a/ruoyi-ui/src/api/system/dept.js
+++ b/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'
})
}
diff --git a/ruoyi-ui/src/api/system/post.js b/ruoyi-ui/src/api/system/post.js
index cb1dfc3e5..3ef4a9906 100644
--- a/ruoyi-ui/src/api/system/post.js
+++ b/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'
})
}
diff --git a/ruoyi-ui/src/views/system/dept/index.vue b/ruoyi-ui/src/views/system/dept/index.vue
index 5485703ac..0fc5a8733 100644
--- a/ruoyi-ui/src/views/system/dept/index.vue
+++ b/ruoyi-ui/src/views/system/dept/index.vue
@@ -2,22 +2,11 @@
-
+
-
+
@@ -28,24 +17,13 @@
- 新增
+ 新增
-
+
@@ -56,28 +34,12 @@
- 修改
- 新增
- 删除
+ 修改
+ 新增
+ 删除
@@ -119,11 +81,8 @@
- {{dict.label}}
+
+ {{dict.label}}
diff --git a/ruoyi-ui/src/views/system/post/index.vue b/ruoyi-ui/src/views/system/post/index.vue
index 9a66f964c..80cab5d49 100644
--- a/ruoyi-ui/src/views/system/post/index.vue
+++ b/ruoyi-ui/src/views/system/post/index.vue
@@ -2,31 +2,14 @@
-
+
-
+
-
+
@@ -37,22 +20,12 @@
- 新增
+ 新增
- 导出
+ 导出
@@ -70,31 +43,16 @@
- 修改
- 删除
+ 修改
+ 删除
-
+
@@ -110,11 +68,8 @@
- {{dict.label}}
+
+ {{dict.label}}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysAuthController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysAuthController.java
index ea7dbfd76..f6ea81e1d 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysAuthController.java
+++ b/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 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 getPermissionInfo() {
// 获得用户信息
SysUserDO user = userService.getUser(getLoginUserId());
@@ -65,7 +67,7 @@ public class SysAuthController {
// 获得角色列表
List roleList = roleService.listRolesFromCache(getLoginUserRoleIds());
// 获得菜单列表
- List menuList = permissionService.listRoleMenusFromCache(
+ List 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> listMenus() {
+ @ApiOperation("获得登陆用户的菜单列表")
+ public CommonResult> getMenus() {
// 获得用户拥有的菜单列表
- List menuList = permissionService.listRoleMenusFromCache(
+ List menuList = permissionService.getRoleMenusFromCache(
getLoginUserRoleIds(), // 注意,基于登陆的角色,因为后续的权限判断也是基于它
SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType()), // 只要目录和菜单类型
SetUtils.asSet(CommonStatusEnum.ENABLE.getStatus())); // 只要开启的
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysUserSessionController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysUserSessionController.java
index 570ebb6be..7ffd6318a 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/auth/SysUserSessionController.java
+++ b/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> getUserSessionPage(@Validated SysUserSessionPageReqVO reqVO) {
// 获得 Session 分页
PageResult 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 delete(@RequestParam("id") String id) {
+ @PreAuthorize("@ss.hasPermission('system:user-session:delete')")
+ public CommonResult deleteUserSession(@RequestParam("id") String id) {
userSessionService.deleteUserSession(id);
return success(true);
}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java
index 77ebdcad3..9651275c1 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java
+++ b/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 createDept(@Valid @RequestBody SysDeptCreateReqVO reqVO) {
+ Long deptId = deptService.createDept(reqVO);
+ return success(deptId);
+ }
+
+ @PutMapping("update")
+ @ApiOperation("更新部门")
+ @PreAuthorize("@ss.hasPermission('system:dept:update')")
+ public CommonResult 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 deleteDept(@RequestParam("id") Long id) {
+ deptService.deleteDept(id);
+ return success(true);
+ }
+
@GetMapping("/list")
+ @ApiOperation("获取部门列表")
+ @PreAuthorize("@ss.hasPermission('system:dept:query')")
public CommonResult> listDepts(SysDeptListReqVO reqVO) {
- List list = deptService.listDepts(reqVO);
+ List 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> listSimpleDepts() {
+ @ApiOperation(value = "获取部门精简信息列表", notes = "只包含被开启的部门,主要用于前端的下拉选项")
+ public CommonResult> getSimpleDepts() {
// 获得部门列表,只要开启状态的
SysDeptListReqVO reqVO = new SysDeptListReqVO();
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
- List list = deptService.listDepts(reqVO);
+ List 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 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 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 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 deleteDept(@RequestParam("id") Long id) {
- deptService.deleteDept(id);
- return success(true);
- }
}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysPostController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysPostController.java
index 65f6c6994..125cd5d61 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysPostController.java
+++ b/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> listSimplePosts() {
- // 获得岗位列表,只要开启状态的
- List 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> 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 createPost(@Validated @RequestBody SysPostCreateReqVO reqVO) {
+ @ApiOperation("创建岗位")
+ @PreAuthorize("@ss.hasPermission('system:post:create')")
+ public CommonResult 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 updatePost(@Validated @RequestBody SysPostUpdateReqVO reqVO) {
+ @PreAuthorize("@ss.hasPermission('system:post:update')")
+ public CommonResult 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 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 getPost(@RequestParam("id") Long id) {
return success(SysPostConvert.INSTANCE.convert(postService.getPost(id)));
}
+ @GetMapping("/list-all-simple")
+ @ApiOperation(value = "获取岗位精简信息列表", notes = "只包含被开启的岗位,主要用于前端的下拉选项")
+ public CommonResult> getSimplePosts() {
+ // 获得岗位列表,只要开启状态的
+ List 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> 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 posts = postService.listPosts(reqVO);
- List excelDataList = SysPostConvert.INSTANCE.convertList03(posts);
+ List posts = postService.getPosts(reqVO);
+ List data = SysPostConvert.INSTANCE.convertList03(posts);
// 输出
- ExcelUtils.write(response, "岗位数据.xls", "岗位列表",
- SysPostExcelVO.class, excelDataList);
+ ExcelUtils.write(response, "岗位数据.xls", "岗位列表", SysPostExcelVO.class, data);
}
}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java
index b41dc7871..b378fd18d 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java
@@ -24,53 +24,6 @@ public interface SysDeptService {
*/
void initLocalCache();
- /**
- * 获得指定编号的部门列表
- *
- * @param ids 部门编号数组
- * @return 部门列表
- */
- List listDepts(Collection ids);
-
- /**
- * 获得指定编号的部门 Map
- *
- * @param ids 部门编号数组
- * @return 部门 Map
- */
- default Map getDeptMap(Collection ids) {
- if (CollUtil.isEmpty(ids)) {
- return Collections.emptyMap();
- }
- List list = listDepts(ids);
- return CollectionUtils.convertMap(list, SysDeptDO::getId);
- }
-
- /**
- * 筛选部门列表
- *
- * @param reqVO 筛选条件请求 VO
- * @return 部门列表
- */
- List listDepts(SysDeptListReqVO reqVO);
-
- /**
- * 获得所有子部门,从缓存中
- *
- * @param parentId 部门编号
- * @param recursive 是否递归获取所有
- * @return 子部门列表
- */
- List listDeptsByParentIdFromCache(Long parentId, boolean recursive);
-
- /**
- * 获得部门信息
- *
- * @param id 部门编号
- * @return 部门信息
- */
- SysDeptDO getDept(Long id);
-
/**
* 创建部门
*
@@ -93,4 +46,51 @@ public interface SysDeptService {
*/
void deleteDept(Long id);
+ /**
+ * 获得指定编号的部门列表
+ *
+ * @param ids 部门编号数组
+ * @return 部门列表
+ */
+ List getSimpleDepts(Collection ids);
+
+ /**
+ * 获得指定编号的部门 Map
+ *
+ * @param ids 部门编号数组
+ * @return 部门 Map
+ */
+ default Map getDeptMap(Collection ids) {
+ if (CollUtil.isEmpty(ids)) {
+ return Collections.emptyMap();
+ }
+ List list = getSimpleDepts(ids);
+ return CollectionUtils.convertMap(list, SysDeptDO::getId);
+ }
+
+ /**
+ * 筛选部门列表
+ *
+ * @param reqVO 筛选条件请求 VO
+ * @return 部门列表
+ */
+ List getSimpleDepts(SysDeptListReqVO reqVO);
+
+ /**
+ * 获得部门信息
+ *
+ * @param id 部门编号
+ * @return 部门信息
+ */
+ SysDeptDO getDept(Long id);
+
+ /**
+ * 获得所有子部门,从缓存中
+ *
+ * @param parentId 部门编号
+ * @param recursive 是否递归获取所有
+ * @return 子部门列表
+ */
+ List getDeptsByParentIdFromCache(Long parentId, boolean recursive);
+
}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java
index 76992e681..b4cca1ab1 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java
+++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java
@@ -18,39 +18,6 @@ import java.util.List;
*/
public interface SysPostService {
- /**
- * 获得符合条件的岗位列表
- *
- * @param ids 岗位编号数组。如果为空,不进行筛选
- * @param statuses 状态数组。如果为空,不进行筛选
- * @return 部门列表
- */
- List listPosts(@Nullable Collection ids, @Nullable Collection statuses);
-
- /**
- * 获得岗位分页列表
- *
- * @param reqVO 分页条件
- * @return 部门分页列表
- */
- PageResult pagePosts(SysPostPageReqVO reqVO);
-
- /**
- * 获得岗位列表
- *
- * @param reqVO 查询条件
- * @return 部门列表
- */
- List listPosts(SysPostExportReqVO reqVO);
-
- /**
- * 获得岗位信息
- *
- * @param id 岗位编号
- * @return 岗位信息
- */
- SysPostDO getPost(Long id);
-
/**
* 创建岗位
*
@@ -73,4 +40,37 @@ public interface SysPostService {
*/
void deletePost(Long id);
+ /**
+ * 获得符合条件的岗位列表
+ *
+ * @param ids 岗位编号数组。如果为空,不进行筛选
+ * @param statuses 状态数组。如果为空,不进行筛选
+ * @return 部门列表
+ */
+ List getPosts(@Nullable Collection ids, @Nullable Collection statuses);
+
+ /**
+ * 获得岗位分页列表
+ *
+ * @param reqVO 分页条件
+ * @return 部门分页列表
+ */
+ PageResult getPostPage(SysPostPageReqVO reqVO);
+
+ /**
+ * 获得岗位列表
+ *
+ * @param reqVO 查询条件
+ * @return 部门列表
+ */
+ List getPosts(SysPostExportReqVO reqVO);
+
+ /**
+ * 获得岗位信息
+ *
+ * @param id 岗位编号
+ * @return 岗位信息
+ */
+ SysPostDO getPost(Long id);
+
}
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java
index 1f3682bc6..65777ef06 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java
+++ b/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 deptCache;
/**
* 父部门缓存
@@ -118,17 +121,55 @@ public class SysDeptServiceImpl implements SysDeptService {
}
@Override
- public List listDepts(Collection 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 getSimpleDepts(Collection ids) {
return deptMapper.selectBatchIds(ids);
}
@Override
- public List listDepts(SysDeptListReqVO reqVO) {
+ public List getSimpleDepts(SysDeptListReqVO reqVO) {
return deptMapper.selectList(reqVO);
}
@Override
- public List listDeptsByParentIdFromCache(Long parentId, boolean recursive) {
+ public List getDeptsByParentIdFromCache(Long parentId, boolean recursive) {
List 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 children = this.listDeptsByParentIdFromCache(id, true);
+ List 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 selectDeptList(SysDept dept)
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysPostServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysPostServiceImpl.java
index 0036fb8d7..36bb95cb2 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysPostServiceImpl.java
+++ b/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 listPosts(Collection ids, Collection statuses) {
- return postMapper.selectList(ids, statuses);
- }
-
- @Override
- public PageResult pagePosts(SysPostPageReqVO reqVO) {
- return postMapper.selectPage(reqVO);
- }
-
- @Override
- public List 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 getPosts(Collection ids, Collection statuses) {
+ return postMapper.selectList(ids, statuses);
+ }
+
+ @Override
+ public PageResult getPostPage(SysPostPageReqVO reqVO) {
+ return postMapper.selectPage(reqVO);
+ }
+
+ @Override
+ public List 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;
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysPermissionService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysPermissionService.java
index cfbf205d1..5390d3294 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysPermissionService.java
+++ b/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 listRoleMenusFromCache(Collection roleIds, Collection menuTypes,
- Collection menusStatuses);
+ List getRoleMenusFromCache(Collection roleIds, Collection menuTypes,
+ Collection menusStatuses);
/**
* 获得用户拥有的角色编号集合
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysPermissionServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysPermissionServiceImpl.java
index ceb1d6d83..5ac32419b 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysPermissionServiceImpl.java
+++ b/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 listRoleMenusFromCache(Collection roleIds, Collection menuTypes,
- Collection menusStatuses) {
+ public List getRoleMenusFromCache(Collection roleIds, Collection menuTypes,
+ Collection menusStatuses) {
// 任一一个参数为空时,不返回任何菜单
if (CollectionUtils.isAnyEmpty(roleIds, menusStatuses, menusStatuses)) {
return Collections.emptyList();
diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java
index acffcb7d1..2e792d24c 100644
--- a/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java
+++ b/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 deptIds = CollectionUtils.convertSet(deptService.listDeptsByParentIdFromCache(
+ Set 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 posts = postService.listPosts(postIds, null);
+ List posts = postService.getPosts(postIds, null);
if (CollUtil.isEmpty(posts)) {
throw ServiceExceptionUtil.exception(POST_NOT_FOUND);
}
diff --git a/src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptServiceTest.java b/src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptServiceTest.java
index ca0165c0f..727d08f78 100644
--- a/src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptServiceTest.java
+++ b/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 sysDeptDOS = deptService.listDepts(reqVO);
+ List sysDeptDOS = deptService.getSimpleDepts(reqVO);
// 断言
assertEquals(1, sysDeptDOS.size());
assertPojoEquals(dept, sysDeptDOS.get(0));
diff --git a/src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostServiceTest.java b/src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostServiceTest.java
index bf3478989..be8b3225d 100644
--- a/src/test/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostServiceTest.java
+++ b/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 pageResult = postService.pagePosts(reqVO);
+ PageResult pageResult = postService.getPostPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
@@ -85,7 +85,7 @@ class SysPostServiceTest extends BaseDbUnitTest {
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
// 调用
- List list = postService.listPosts(reqVO);
+ List list = postService.getPosts(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(postDO, list.get(0));