|
@@ -2,16 +2,17 @@ package cn.iocoder.yudao.module.system.controller.admin.permission;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.*;
|
|
|
-import cn.iocoder.yudao.module.system.convert.permission.RoleConvert;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
|
|
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
-import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -39,15 +40,15 @@ public class RoleController {
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建角色")
|
|
|
@PreAuthorize("@ss.hasPermission('system:role:create')")
|
|
|
- public CommonResult<Long> createRole(@Valid @RequestBody RoleCreateReqVO reqVO) {
|
|
|
- return success(roleService.createRole(reqVO, null));
|
|
|
+ public CommonResult<Long> createRole(@Valid @RequestBody RoleSaveReqVO createReqVO) {
|
|
|
+ return success(roleService.createRole(createReqVO, null));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "修改角色")
|
|
|
@PreAuthorize("@ss.hasPermission('system:role:update')")
|
|
|
- public CommonResult<Boolean> updateRole(@Valid @RequestBody RoleUpdateReqVO reqVO) {
|
|
|
- roleService.updateRole(reqVO);
|
|
|
+ public CommonResult<Boolean> updateRole(@Valid @RequestBody RoleSaveReqVO updateReqVO) {
|
|
|
+ roleService.updateRole(updateReqVO);
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
@@ -73,34 +74,35 @@ public class RoleController {
|
|
|
@PreAuthorize("@ss.hasPermission('system:role:query')")
|
|
|
public CommonResult<RoleRespVO> getRole(@RequestParam("id") Long id) {
|
|
|
RoleDO role = roleService.getRole(id);
|
|
|
- return success(RoleConvert.INSTANCE.convert(role));
|
|
|
+ return success(BeanUtils.toBean(role, RoleRespVO.class));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
@Operation(summary = "获得角色分页")
|
|
|
@PreAuthorize("@ss.hasPermission('system:role:query')")
|
|
|
- public CommonResult<PageResult<RoleDO>> getRolePage(RolePageReqVO reqVO) {
|
|
|
- return success(roleService.getRolePage(reqVO));
|
|
|
+ public CommonResult<PageResult<RoleRespVO>> getRolePage(RolePageReqVO pageReqVO) {
|
|
|
+ PageResult<RoleDO> pageResult = roleService.getRolePage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, RoleRespVO.class));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/list-all-simple")
|
|
|
@Operation(summary = "获取角色精简信息列表", description = "只包含被开启的角色,主要用于前端的下拉选项")
|
|
|
public CommonResult<List<RoleSimpleRespVO>> getSimpleRoleList() {
|
|
|
- // 获得角色列表,只要开启状态的
|
|
|
List<RoleDO> list = roleService.getRoleListByStatus(singleton(CommonStatusEnum.ENABLE.getStatus()));
|
|
|
- // 排序后,返回给前端
|
|
|
list.sort(Comparator.comparing(RoleDO::getSort));
|
|
|
- return success(RoleConvert.INSTANCE.convertList02(list));
|
|
|
+ return success(BeanUtils.toBean(list, RoleSimpleRespVO.class));
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/export")
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出角色 Excel")
|
|
|
@OperateLog(type = EXPORT)
|
|
|
@PreAuthorize("@ss.hasPermission('system:role:export')")
|
|
|
- public void export(HttpServletResponse response, @Validated RoleExportReqVO reqVO) throws IOException {
|
|
|
- List<RoleDO> list = roleService.getRoleList(reqVO);
|
|
|
- List<RoleExcelVO> data = RoleConvert.INSTANCE.convertList03(list);
|
|
|
+ public void export(HttpServletResponse response, @Validated RolePageReqVO exportReqVO) throws IOException {
|
|
|
+ exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<RoleDO> list = roleService.getRolePage(exportReqVO).getList();
|
|
|
// 输出
|
|
|
- ExcelUtils.write(response, "角色数据.xls", "角色列表", RoleExcelVO.class, data);
|
|
|
+ ExcelUtils.write(response, "角色数据.xls", "数据", RoleRespVO.class,
|
|
|
+ BeanUtils.toBean(list, RoleRespVO.class));
|
|
|
}
|
|
|
|
|
|
}
|