From 2787212362c5a23bf5dd94b1bb9cae4ec3fe4caa Mon Sep 17 00:00:00 2001 From: MichelleChung <1242874891@qq.com> Date: 星期五, 03 二月 2023 09:47:41 +0800 Subject: [PATCH] !284 更新常量 GenConstants,优化 Map 返回结构 * update 优化返回结构, 将 Map 改为指定 Vo 对象 ; * update GenConstants 扩展数据库数据类型, 更新 BO, VO, ENTITY 字段, 并移动到 generator 模块 ; --- ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysRoleController.java | 37 +++++++++++++++++++------------------ 1 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysRoleController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysRoleController.java index 8bf88ab..7a0868f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysRoleController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/system/SysRoleController.java @@ -5,7 +5,7 @@ import com.ruoyi.common.core.constant.UserConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.model.LoginUser; -import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.web.core.BaseController; import com.ruoyi.common.excel.utils.ExcelUtil; import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; @@ -13,9 +13,11 @@ import com.ruoyi.common.mybatis.core.page.TableDataInfo; import com.ruoyi.common.satoken.utils.LoginHelper; import com.ruoyi.system.domain.SysDept; -import com.ruoyi.system.domain.SysRole; import com.ruoyi.system.domain.SysUser; import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.domain.bo.SysRoleBo; +import com.ruoyi.system.domain.vo.DeptTreeSelectVo; +import com.ruoyi.system.domain.vo.SysRoleVo; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; @@ -26,7 +28,6 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Map; /** * 瑙掕壊淇℃伅 @@ -49,7 +50,7 @@ */ @SaCheckPermission("system:role:list") @GetMapping("/list") - public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) { + public TableDataInfo<SysRoleVo> list(SysRoleBo role, PageQuery pageQuery) { return roleService.selectPageRoleList(role, pageQuery); } @@ -59,9 +60,9 @@ @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.EXPORT) @SaCheckPermission("system:role:export") @PostMapping("/export") - public void export(SysRole role, HttpServletResponse response) { - List<SysRole> list = roleService.selectRoleList(role); - ExcelUtil.exportExcel(list, "瑙掕壊鏁版嵁", SysRole.class, response); + public void export(SysRoleBo role, HttpServletResponse response) { + List<SysRoleVo> list = roleService.selectRoleList(role); + ExcelUtil.exportExcel(list, "瑙掕壊鏁版嵁", SysRoleVo.class, response); } /** @@ -71,7 +72,7 @@ */ @SaCheckPermission("system:role:query") @GetMapping(value = "/{roleId}") - public R<SysRole> getInfo(@PathVariable Long roleId) { + public R<SysRoleVo> getInfo(@PathVariable Long roleId) { roleService.checkRoleDataScope(roleId); return R.ok(roleService.selectRoleById(roleId)); } @@ -82,7 +83,7 @@ @SaCheckPermission("system:role:add") @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.INSERT) @PostMapping - public R<Void> add(@Validated @RequestBody SysRole role) { + public R<Void> add(@Validated @RequestBody SysRoleBo role) { if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { return R.fail("鏂板瑙掕壊'" + role.getRoleName() + "'澶辫触锛岃鑹插悕绉板凡瀛樺湪"); } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { @@ -98,7 +99,7 @@ @SaCheckPermission("system:role:edit") @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE) @PutMapping - public R<Void> edit(@Validated @RequestBody SysRole role) { + public R<Void> edit(@Validated @RequestBody SysRoleBo role) { roleService.checkRoleAllowed(role); roleService.checkRoleDataScope(role.getRoleId()); if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { @@ -126,7 +127,7 @@ @SaCheckPermission("system:role:edit") @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE) @PutMapping("/dataScope") - public R<Void> dataScope(@RequestBody SysRole role) { + public R<Void> dataScope(@RequestBody SysRoleBo role) { roleService.checkRoleAllowed(role); roleService.checkRoleDataScope(role.getRoleId()); return toAjax(roleService.authDataScope(role)); @@ -138,7 +139,7 @@ @SaCheckPermission("system:role:edit") @Log(title = "瑙掕壊绠$悊", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") - public R<Void> changeStatus(@RequestBody SysRole role) { + public R<Void> changeStatus(@RequestBody SysRoleBo role) { roleService.checkRoleAllowed(role); roleService.checkRoleDataScope(role.getRoleId()); return toAjax(roleService.updateRoleStatus(role)); @@ -161,7 +162,7 @@ */ @SaCheckPermission("system:role:query") @GetMapping("/optionselect") - public R<List<SysRole>> optionselect() { + public R<List<SysRoleVo>> optionselect() { return R.ok(roleService.selectRoleAll()); } @@ -227,10 +228,10 @@ */ @SaCheckPermission("system:role:list") @GetMapping(value = "/deptTree/{roleId}") - public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) { - return R.ok(Map.of( - "checkedKeys", deptService.selectDeptListByRoleId(roleId), - "depts", deptService.selectDeptTreeList(new SysDept()) - )); + public R<DeptTreeSelectVo> roleDeptTreeselect(@PathVariable("roleId") Long roleId) { + DeptTreeSelectVo selectVo = new DeptTreeSelectVo(); + selectVo.setCheckedKeys(deptService.selectDeptListByRoleId(roleId)); + selectVo.setDepts(deptService.selectDeptTreeList(new SysDept())); + return R.ok(selectVo); } } -- Gitblit v1.9.3