From 4c3e2bd8155752807868fa906f8eb80eceea6c1b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 9 Jan 2021 00:32:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=20RoleDO=20=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=92=8C=E4=BC=98=E5=8C=96=202.=20=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=20Role=20=E6=A8=A1=E5=9D=97=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3=E7=9A=84=20VO=20=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system/SysRoleController.java | 182 ------------------ .../core/controller/BaseController.java | 42 +--- .../ruoyi/common/core/page/PageDomain.java | 33 ---- .../ruoyi/common/core/page/TableDataInfo.java | 27 --- .../ruoyi/common/core/page/TableSupport.java | 32 --- .../security/core/enums/DataScopeEnum.java | 28 +++ .../permission/SysMenuController.java | 8 +- .../permission/SysRoleController.java | 142 ++++++++++++++ .../vo/{ => menu}/SysMenuBaseVO.java | 2 +- .../vo/{ => menu}/SysMenuCreateReqVO.java | 2 +- .../vo/{ => menu}/SysMenuListReqVO.java | 2 +- .../vo/{ => menu}/SysMenuRespVO.java | 2 +- .../vo/{ => menu}/SysMenuUpdateReqVO.java | 2 +- .../permission/vo/role/SysMenuPageReqVO.java | 13 ++ .../permission/vo/role/SysRoleBaseVO.java | 33 ++++ .../vo/role/SysRoleCreateReqVO.java | 12 ++ .../vo/role/SysRoleExcelRespVO.java | 30 +++ .../permission/vo/role/SysRoleRespVO.java | 37 ++++ .../vo/role/SysRoleUpdateReqVO.java | 19 ++ .../system/convert/auth/SysAuthConvert.java | 2 +- .../convert/permission/SysMenuConvert.java | 6 +- .../mysql/dao/permission/SysMenuMapper.java | 2 +- .../dataobject/permission/SysRoleDO.java | 84 +++----- .../{RoleKeyEnum.java => RoleCodeEnum.java} | 2 +- .../system/enums/permission/RoleTypeEnum.java | 21 ++ .../service/permission/SysMenuService.java | 8 +- .../permission/impl/SysMenuServiceImpl.java | 8 +- .../permission/impl/SysRoleServiceImpl.java | 10 +- 28 files changed, 399 insertions(+), 392 deletions(-) delete mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java create mode 100644 src/main/java/cn/iocoder/dashboard/framework/security/core/enums/DataScopeEnum.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysRoleController.java rename src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/{ => menu}/SysMenuBaseVO.java (99%) rename src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/{ => menu}/SysMenuCreateReqVO.java (95%) rename src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/{ => menu}/SysMenuListReqVO.java (97%) rename src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/{ => menu}/SysMenuRespVO.java (98%) rename src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/{ => menu}/SysMenuUpdateReqVO.java (97%) create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysMenuPageReqVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleBaseVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleCreateReqVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleExcelRespVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleUpdateReqVO.java rename src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/{RoleKeyEnum.java => RoleCodeEnum.java} (91%) create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleTypeEnum.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java deleted file mode 100644 index a7cce4490..000000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.entity.SysRole; -import com.ruoyi.common.core.domain.model.LoginUser; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.ServletUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.web.service.SysPermissionService; -import com.ruoyi.framework.web.service.TokenService; -import com.ruoyi.system.service.ISysRoleService; -import com.ruoyi.system.service.ISysUserService; - -/** - * 角色信息 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/system/role") -public class SysRoleController extends BaseController -{ - @Autowired - private ISysRoleService roleService; - - @Autowired - private TokenService tokenService; - - @Autowired - private SysPermissionService permissionService; - - @Autowired - private ISysUserService userService; - - @PreAuthorize("@ss.hasPermi('system:role:list')") - @GetMapping("/list") - public TableDataInfo list(SysRole role) - { - startPage(); - List list = roleService.selectRoleList(role); - return getDataTable(list); - } - - @Log(title = "角色管理", businessType = BusinessType.EXPORT) - @PreAuthorize("@ss.hasPermi('system:role:export')") - @GetMapping("/export") - public AjaxResult export(SysRole role) - { - List list = roleService.selectRoleList(role); - ExcelUtil util = new ExcelUtil(SysRole.class); - return util.exportExcel(list, "角色数据"); - } - - /** - * 根据角色编号获取详细信息 - */ - @PreAuthorize("@ss.hasPermi('system:role:query')") - @GetMapping(value = "/{roleId}") - public AjaxResult getInfo(@PathVariable Long roleId) - { - return AjaxResult.success(roleService.selectRoleById(roleId)); - } - - /** - * 新增角色 - */ - @PreAuthorize("@ss.hasPermi('system:role:add')") - @Log(title = "角色管理", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@Validated @RequestBody SysRole role) - { - if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) - { - return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); - } - else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) - { - return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); - } - role.setCreateBy(SecurityUtils.getUsername()); - return toAjax(roleService.insertRole(role)); - - } - - /** - * 修改保存角色 - */ - @PreAuthorize("@ss.hasPermi('system:role:edit')") - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@Validated @RequestBody SysRole role) - { - roleService.checkRoleAllowed(role); - if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) - { - return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); - } - else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) - { - return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); - } - role.setUpdateBy(SecurityUtils.getUsername()); - - if (roleService.updateRole(role) > 0) - { - // 更新缓存用户权限 - LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); - if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) - { - loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); - loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); - tokenService.setLoginUser(loginUser); - } - return AjaxResult.success(); - } - return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); - } - - /** - * 修改保存数据权限 - */ - @PreAuthorize("@ss.hasPermi('system:role:edit')") - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @PutMapping("/dataScope") - public AjaxResult dataScope(@RequestBody SysRole role) - { - roleService.checkRoleAllowed(role); - return toAjax(roleService.authDataScope(role)); - } - - /** - * 状态修改 - */ - @PreAuthorize("@ss.hasPermi('system:role:edit')") - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysRole role) - { - roleService.checkRoleAllowed(role); - role.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(roleService.updateRoleStatus(role)); - } - - /** - * 删除角色 - */ - @PreAuthorize("@ss.hasPermi('system:role:remove')") - @Log(title = "角色管理", businessType = BusinessType.DELETE) - @DeleteMapping("/{roleIds}") - public AjaxResult remove(@PathVariable Long[] roleIds) - { - return toAjax(roleService.deleteRoleByIds(roleIds)); - } - - /** - * 获取角色选择框列表 - */ - @PreAuthorize("@ss.hasPermi('system:role:query')") - @GetMapping("/optionselect") - public AjaxResult optionselect() - { - return AjaxResult.success(roleService.selectRoleAll()); - } -} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index 6e0f2ace0..e316627f4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -3,6 +3,7 @@ package com.ruoyi.common.core.controller; import java.beans.PropertyEditorSupport; import java.util.Date; import java.util.List; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.WebDataBinder; @@ -23,54 +24,21 @@ import com.ruoyi.common.utils.sql.SqlUtil; * * @author ruoyi */ -public class BaseController -{ +public class BaseController { protected final Logger logger = LoggerFactory.getLogger(BaseController.class); /** * 将前台传递过来的日期格式的字符串,自动转化为Date类型 */ @InitBinder - public void initBinder(WebDataBinder binder) - { + public void initBinder(WebDataBinder binder) { // Date 类型转换 - binder.registerCustomEditor(Date.class, new PropertyEditorSupport() - { + binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { @Override - public void setAsText(String text) - { + public void setAsText(String text) { setValue(DateUtils.parseDate(text)); } }); } - /** - * 设置请求分页数据 - */ - protected void startPage() - { - PageDomain pageDomain = TableSupport.buildPageRequest(); - Integer pageNum = pageDomain.getPageNum(); - Integer pageSize = pageDomain.getPageSize(); - if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) - { - String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); - PageHelper.startPage(pageNum, pageSize, orderBy); - } - } - - /** - * 响应请求分页数据 - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected TableDataInfo getDataTable(List list) - { - TableDataInfo rspData = new TableDataInfo(); - rspData.setCode(HttpStatus.SUCCESS); - rspData.setMsg("查询成功"); - rspData.setRows(list); - rspData.setTotal(new PageInfo(list).getTotal()); - return rspData; - } - } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java deleted file mode 100644 index fcd50b145..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.ruoyi.common.core.page; - -import com.ruoyi.common.utils.StringUtils; - -/** - * 分页数据 - * - * @author ruoyi - */ -public class PageDomain -{ - /** 当前记录起始索引 */ - private Integer pageNum; - - /** 每页显示记录数 */ - private Integer pageSize; - - /** 排序列 */ - private String orderByColumn; - - /** 排序的方向desc或者asc */ - private String isAsc = "asc"; - - public String getOrderBy() - { - if (StringUtils.isEmpty(orderByColumn)) - { - return ""; - } - return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; - } - -} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java deleted file mode 100644 index 901188e0a..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.ruoyi.common.core.page; - -import java.io.Serializable; -import java.util.List; - -/** - * 表格分页数据对象 - * - * @author ruoyi - */ -public class TableDataInfo implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** 总记录数 */ - private long total; - - /** 列表数据 */ - private List rows; - - /** 消息状态码 */ - private int code; - - /** 消息内容 */ - private String msg; - -} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java deleted file mode 100644 index 94438540c..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.ruoyi.common.core.page; - -import com.ruoyi.common.utils.ServletUtils; - -/** - * 表格数据处理 - * - * @author ruoyi - */ -public class TableSupport -{ - /** - * 当前记录起始索引 - */ - public static final String PAGE_NUM = "pageNum"; - - /** - * 每页显示记录数 - */ - public static final String PAGE_SIZE = "pageSize"; - - /** - * 排序列 - */ - public static final String ORDER_BY_COLUMN = "orderByColumn"; - - /** - * 排序的方向 "desc" 或者 "asc". - */ - public static final String IS_ASC = "isAsc"; - -} diff --git a/src/main/java/cn/iocoder/dashboard/framework/security/core/enums/DataScopeEnum.java b/src/main/java/cn/iocoder/dashboard/framework/security/core/enums/DataScopeEnum.java new file mode 100644 index 000000000..f97692f4a --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/framework/security/core/enums/DataScopeEnum.java @@ -0,0 +1,28 @@ +package cn.iocoder.dashboard.framework.security.core.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 数据范围枚举类 + * + * 用于实现数据级别的权限 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum DataScopeEnum { + + ALL(1), // 全部数据权限 + CUSTOM(2), // 自定数据权限 + DEPT(3), // 部门数据权限 + DEPT_AND_CHILD(4), // 部门及以下数据权限 + SELF(5); // 仅本人数据权限 + + /** + * 范围 + */ + private final Integer score; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysMenuController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysMenuController.java index 63071345d..7a5a471c9 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysMenuController.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysMenuController.java @@ -1,10 +1,10 @@ package cn.iocoder.dashboard.modules.system.controller.permission; import cn.iocoder.dashboard.common.pojo.CommonResult; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuCreateReqVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuUpdateReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuListReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuRespVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuUpdateReqVO; import cn.iocoder.dashboard.modules.system.convert.permission.SysMenuConvert; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; import cn.iocoder.dashboard.modules.system.service.permission.SysMenuService; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysRoleController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysRoleController.java new file mode 100644 index 000000000..e96fec357 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/SysRoleController.java @@ -0,0 +1,142 @@ +package cn.iocoder.dashboard.modules.system.controller.permission; + +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Api(tags = "角色 API") +@RestController +@RequestMapping("/system/role") +public class SysRoleController { + +// @PreAuthorize("@ss.hasPermi('system:role:list')") +// @GetMapping("/list") +// public TableDataInfo list(SysRole role) +// { +// startPage(); +// List list = roleService.selectRoleList(role); +// return getDataTable(list); +// } +// +// @Log(title = "角色管理", businessType = BusinessType.EXPORT) +// @PreAuthorize("@ss.hasPermi('system:role:export')") +// @GetMapping("/export") +// public AjaxResult export(SysRole role) +// { +// List list = roleService.selectRoleList(role); +// ExcelUtil util = new ExcelUtil(SysRole.class); +// return util.exportExcel(list, "角色数据"); +// } +// +// /** +// * 根据角色编号获取详细信息 +// */ +// @PreAuthorize("@ss.hasPermi('system:role:query')") +// @GetMapping(value = "/{roleId}") +// public AjaxResult getInfo(@PathVariable Long roleId) +// { +// return AjaxResult.success(roleService.selectRoleById(roleId)); +// } +// +// /** +// * 新增角色 +// */ +// @PreAuthorize("@ss.hasPermi('system:role:add')") +// @Log(title = "角色管理", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@Validated @RequestBody SysRole role) +// { +// if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) +// { +// return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); +// } +// else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) +// { +// return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); +// } +// role.setCreateBy(SecurityUtils.getUsername()); +// return toAjax(roleService.insertRole(role)); +// +// } +// +// /** +// * 修改保存角色 +// */ +// @PreAuthorize("@ss.hasPermi('system:role:edit')") +// @Log(title = "角色管理", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult edit(@Validated @RequestBody SysRole role) +// { +// roleService.checkRoleAllowed(role); +// if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) +// { +// return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); +// } +// else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) +// { +// return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); +// } +// role.setUpdateBy(SecurityUtils.getUsername()); +// +// if (roleService.updateRole(role) > 0) +// { +// // 更新缓存用户权限 +// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); +// if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) +// { +// loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); +// loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); +// tokenService.setLoginUser(loginUser); +// } +// return AjaxResult.success(); +// } +// return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); +// } +// +// /** +// * 修改保存数据权限 +// */ +// @PreAuthorize("@ss.hasPermi('system:role:edit')") +// @Log(title = "角色管理", businessType = BusinessType.UPDATE) +// @PutMapping("/dataScope") +// public AjaxResult dataScope(@RequestBody SysRole role) +// { +// roleService.checkRoleAllowed(role); +// return toAjax(roleService.authDataScope(role)); +// } +// +// /** +// * 状态修改 +// */ +// @PreAuthorize("@ss.hasPermi('system:role:edit')") +// @Log(title = "角色管理", businessType = BusinessType.UPDATE) +// @PutMapping("/changeStatus") +// public AjaxResult changeStatus(@RequestBody SysRole role) +// { +// roleService.checkRoleAllowed(role); +// role.setUpdateBy(SecurityUtils.getUsername()); +// return toAjax(roleService.updateRoleStatus(role)); +// } +// +// /** +// * 删除角色 +// */ +// @PreAuthorize("@ss.hasPermi('system:role:remove')") +// @Log(title = "角色管理", businessType = BusinessType.DELETE) +// @DeleteMapping("/{roleIds}") +// public AjaxResult remove(@PathVariable Long[] roleIds) +// { +// return toAjax(roleService.deleteRoleByIds(roleIds)); +// } +// +// /** +// * 获取角色选择框列表 +// */ +// @PreAuthorize("@ss.hasPermi('system:role:query')") +// @GetMapping("/optionselect") +// public AjaxResult optionselect() +// { +// return AjaxResult.success(roleService.selectRoleAll()); +// } + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuBaseVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuBaseVO.java similarity index 99% rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuBaseVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuBaseVO.java index 4ca4e1086..3db857f9f 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuBaseVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.system.controller.permission.vo; +package cn.iocoder.dashboard.modules.system.controller.permission.vo.menu; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuCreateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuCreateReqVO.java similarity index 95% rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuCreateReqVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuCreateReqVO.java index 6c281b2ca..8fba89a93 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuCreateReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuCreateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.system.controller.permission.vo; +package cn.iocoder.dashboard.modules.system.controller.permission.vo.menu; import io.swagger.annotations.ApiModel; import lombok.*; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuListReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuListReqVO.java similarity index 97% rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuListReqVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuListReqVO.java index 5d2e85425..3990a9cd9 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuListReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuListReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.system.controller.permission.vo; +package cn.iocoder.dashboard.modules.system.controller.permission.vo.menu; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuRespVO.java similarity index 98% rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuRespVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuRespVO.java index 59cd6e52b..ff8c2f0b8 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.system.controller.permission.vo; +package cn.iocoder.dashboard.modules.system.controller.permission.vo.menu; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuUpdateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuUpdateReqVO.java similarity index 97% rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuUpdateReqVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuUpdateReqVO.java index b000d85cb..44f181ea3 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/SysMenuUpdateReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/menu/SysMenuUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.system.controller.permission.vo; +package cn.iocoder.dashboard.modules.system.controller.permission.vo.menu; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysMenuPageReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysMenuPageReqVO.java new file mode 100644 index 000000000..10837c38b --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysMenuPageReqVO.java @@ -0,0 +1,13 @@ +package cn.iocoder.dashboard.modules.system.controller.permission.vo.role; + +import cn.iocoder.dashboard.common.pojo.PageParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@ApiModel("角色分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysMenuPageReqVO extends PageParam { + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleBaseVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleBaseVO.java new file mode 100644 index 000000000..8f325065b --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleBaseVO.java @@ -0,0 +1,33 @@ +package cn.iocoder.dashboard.modules.system.controller.permission.vo.role; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 角色 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class SysRoleBaseVO { + + @ApiModelProperty(value = "角色名称", required = true, example = "管理员") + @NotBlank(message = "角色名称不能为空") + @Size(max = 30, message = "角色名称长度不能超过30个字符") + private String name; + + @NotBlank(message = "角色标志不能为空") + @Size(max = 100, message = "角色标志长度不能超过100个字符") + @ApiModelProperty(value = "角色编码", required = true, example = "ADMIN") + private String code; + + @ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024") + @NotBlank(message = "显示顺序不能为空") + private String sort; + + @ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "见 RoleTypeEnum 枚举") + private Integer type; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleCreateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleCreateReqVO.java new file mode 100644 index 000000000..870dcce4c --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleCreateReqVO.java @@ -0,0 +1,12 @@ +package cn.iocoder.dashboard.modules.system.controller.permission.vo.role; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@ApiModel("角色创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysRoleCreateReqVO extends SysRoleBaseVO { + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleExcelRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleExcelRespVO.java new file mode 100644 index 000000000..3913b3788 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleExcelRespVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.dashboard.modules.system.controller.permission.vo.role; + +import cn.iocoder.dashboard.framework.excel.Excel; +import lombok.Data; + +/** + * 角色 Excel 导出响应 VO + */ +@Data +public class SysRoleExcelRespVO { + + @Excel(name = "角色序号", cellType = Excel.ColumnType.NUMERIC) + private Long id; + + @Excel(name = "角色名称") + private String name; + + @Excel(name = "角色标志") + private String code; + + @Excel(name = "角色排序") + private Integer sort; + + @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限") + private Integer dataScope; + + @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") + private String status; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java new file mode 100644 index 000000000..4ae4fae88 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleRespVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.dashboard.modules.system.controller.permission.vo.role; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@ApiModel("角色信息 Response VO") +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SysRoleRespVO extends SysRoleBaseVO { + + @ApiModelProperty(value = "角色编号", required = true, example = "1") + private Integer id; + + @ApiModelProperty(value = "数据范围", required = true, example = "1", notes = "参见 DataScopeEnum 枚举类") + private Integer dataScope; + + @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") + private Integer status; + + @ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "参见 RoleTypeEnum 枚举类") + private Integer type; + + @ApiModelProperty(value = "备注", example = "我是一个角色") + private String remark; + + @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") + private Date createTime; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleUpdateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleUpdateReqVO.java new file mode 100644 index 000000000..d35f930ab --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/permission/vo/role/SysRoleUpdateReqVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.dashboard.modules.system.controller.permission.vo.role; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; + +@ApiModel("角色更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +public class SysRoleUpdateReqVO extends SysRoleBaseVO { + + @ApiModelProperty(value = "角色编号", required = true, example = "1024") + @NotNull(message = "角色编号不能为空") + private Long id; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java index 83dba4815..6de7458c2 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java @@ -26,7 +26,7 @@ public interface SysAuthConvert { default SysAuthPermissionInfoRespVO convert(SysUserDO user, List roleList, List menuList) { return SysAuthPermissionInfoRespVO.builder() .user(SysAuthPermissionInfoRespVO.UserVO.builder().nickname(user.getNickname()).avatar(user.getAvatar()).build()) - .roles(CollectionUtils.convertSet(roleList, SysRoleDO::getRoleKey)) + .roles(CollectionUtils.convertSet(roleList, SysRoleDO::getCode)) .permissions(CollectionUtils.convertSet(menuList, SysMenuDO::getPermission)) .build(); } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/permission/SysMenuConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/permission/SysMenuConvert.java index a377f537b..30c0fa765 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/permission/SysMenuConvert.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/permission/SysMenuConvert.java @@ -1,8 +1,8 @@ package cn.iocoder.dashboard.modules.system.convert.permission; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuCreateReqVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuUpdateReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuRespVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuUpdateReqVO; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/permission/SysMenuMapper.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/permission/SysMenuMapper.java index 916b2c395..03db0e69e 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/permission/SysMenuMapper.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/permission/SysMenuMapper.java @@ -1,7 +1,7 @@ package cn.iocoder.dashboard.modules.system.dal.mysql.dao.permission; import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuListReqVO; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/permission/SysRoleDO.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/permission/SysRoleDO.java index 1f6000c7e..c65c1d74a 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/permission/SysRoleDO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/permission/SysRoleDO.java @@ -1,16 +1,15 @@ package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission; -import cn.iocoder.dashboard.framework.excel.Excel; +import cn.iocoder.dashboard.common.enums.CommonStatusEnum; import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableField; +import cn.iocoder.dashboard.framework.security.core.enums.DataScopeEnum; +import cn.iocoder.dashboard.modules.system.enums.permission.RoleCodeEnum; +import cn.iocoder.dashboard.modules.system.enums.permission.RoleTypeEnum; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; - /** * 角色 DO * @@ -19,44 +18,49 @@ import javax.validation.constraints.Size; @TableName("sys_role") @Data @EqualsAndHashCode(callSuper = true) -// TODO 芋艿:数据库的字段默认值 public class SysRoleDO extends BaseDO { /** * 角色ID */ @TableId - @Excel(name = "角色序号", cellType = Excel.ColumnType.NUMERIC) - private Long roleId; - + private Long id; /** * 角色名称 */ - @Excel(name = "角色名称") - @NotBlank(message = "角色名称不能为空") - @Size(max = 30, message = "角色名称长度不能超过30个字符") - private String roleName; - + private String name; /** - * 角色权限 + * 角色标识 + * + * 枚举 {@link RoleCodeEnum} */ - @Excel(name = "角色权限") - @NotBlank(message = "权限字符不能为空") - @Size(max = 100, message = "权限字符长度不能超过100个字符") - private String roleKey; - + private String code; /** * 角色排序 */ - @Excel(name = "角色排序") - @NotBlank(message = "显示顺序不能为空") - private Integer roleSort; - + private Integer sort; /** - * 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限) + * 数据范围 + * + * 枚举类 {@link DataScopeEnum} */ - @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限") - private String dataScope; + private Integer dataScope; + /** + * 角色状态 + * + * 枚举 {@link CommonStatusEnum} + */ + private String status; + /** + * 角色类型 + * + * 枚举 {@link RoleTypeEnum} + */ + private Integer type; + /** + * 备注 + */ + private String remark; /** * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) @@ -68,30 +72,4 @@ public class SysRoleDO extends BaseDO { */ private boolean deptCheckStrictly; - /** - * 角色状态(0正常 1停用) - */ - @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") - private String status; - - // TODO FROM 芋艿:下面的字段,需要忽略 - - /** - * 用户是否存在此角色标识 默认不存在 - */ - @TableField(exist = false) - private boolean flag = false; - - /** - * 菜单组 - */ - @TableField(exist = false) - private Long[] menuIds; - - /** - * 部门组(数据权限) - */ - @TableField(exist = false) - private Long[] deptIds; - } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleKeyEnum.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleCodeEnum.java similarity index 91% rename from src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleKeyEnum.java rename to src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleCodeEnum.java index 77415a94c..9af951610 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleKeyEnum.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleCodeEnum.java @@ -8,7 +8,7 @@ import lombok.Getter; */ @Getter @AllArgsConstructor -public enum RoleKeyEnum { +public enum RoleCodeEnum { ADMIN("admin"), // 超级管理员 ; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleTypeEnum.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleTypeEnum.java new file mode 100644 index 000000000..9c65483e5 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/permission/RoleTypeEnum.java @@ -0,0 +1,21 @@ +package cn.iocoder.dashboard.modules.system.enums.permission; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum RoleTypeEnum { + + /** + * 内置角色 + */ + SYSTEM(1), + /** + * 自定义角色 + */ + CUSTOM(2); + + private final Integer type; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysMenuService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysMenuService.java index c103af45a..296979063 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysMenuService.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/SysMenuService.java @@ -1,9 +1,9 @@ package cn.iocoder.dashboard.modules.system.service.permission; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuCreateReqVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuUpdateReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuListReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuRespVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuUpdateReqVO; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; import java.util.Collection; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysMenuServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysMenuServiceImpl.java index cbe5dc3b2..4f05a20d2 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysMenuServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysMenuServiceImpl.java @@ -1,10 +1,10 @@ package cn.iocoder.dashboard.modules.system.service.permission.impl; import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuCreateReqVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuListReqVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuRespVO; -import cn.iocoder.dashboard.modules.system.controller.permission.vo.SysMenuUpdateReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuListReqVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuRespVO; +import cn.iocoder.dashboard.modules.system.controller.permission.vo.menu.SysMenuUpdateReqVO; import cn.iocoder.dashboard.modules.system.convert.permission.SysMenuConvert; import cn.iocoder.dashboard.modules.system.dal.mysql.dao.permission.SysMenuMapper; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysMenuDO; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysRoleServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysRoleServiceImpl.java index 578c7227b..be4db1059 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysRoleServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/permission/impl/SysRoleServiceImpl.java @@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.system.service.permission.impl; import cn.hutool.core.collection.CollectionUtil; import cn.iocoder.dashboard.modules.system.dal.mysql.dao.permission.SysRoleMapper; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO; -import cn.iocoder.dashboard.modules.system.enums.permission.RoleKeyEnum; +import cn.iocoder.dashboard.modules.system.enums.permission.RoleCodeEnum; import cn.iocoder.dashboard.modules.system.service.permission.SysRoleService; import com.google.common.collect.ImmutableMap; import lombok.extern.slf4j.Slf4j; @@ -29,7 +29,7 @@ public class SysRoleServiceImpl implements SysRoleService { /** * 角色缓存 - * key:角色编号 {@link SysRoleDO#getRoleId()} + * key:角色编号 {@link SysRoleDO#getId()} * * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向 */ @@ -45,7 +45,7 @@ public class SysRoleServiceImpl implements SysRoleService { List roleDOList = roleMapper.selectList(null); // 写入缓存 ImmutableMap.Builder builder = ImmutableMap.builder(); - roleDOList.forEach(sysRoleDO -> builder.put(sysRoleDO.getRoleId(), sysRoleDO)); + roleDOList.forEach(sysRoleDO -> builder.put(sysRoleDO.getId(), sysRoleDO)); roleCache = builder.build(); log.info("[init][初始化 Role 数量为 {}]", roleDOList.size()); } @@ -55,7 +55,7 @@ public class SysRoleServiceImpl implements SysRoleService { if (CollectionUtil.isEmpty(roleIds)) { return Collections.emptyList(); } - return roleCache.values().stream().filter(roleDO -> roleIds.contains(roleDO.getRoleId())) + return roleCache.values().stream().filter(roleDO -> roleIds.contains(roleDO.getId())) .collect(Collectors.toList()); } @@ -64,7 +64,7 @@ public class SysRoleServiceImpl implements SysRoleService { if (CollectionUtil.isEmpty(roleList)) { return false; } - return roleList.stream().anyMatch(roleDO -> RoleKeyEnum.ADMIN.getKey().equals(roleDO.getRoleKey())); + return roleList.stream().anyMatch(roleDO -> RoleCodeEnum.ADMIN.getKey().equals(roleDO.getCode())); } }