From 59fc0206163cae0bab8778b138ba46d7e9fe216c Mon Sep 17 00:00:00 2001 From: yinyilong <195332105@qq.com> Date: Tue, 13 Aug 2024 15:35:13 +0800 Subject: [PATCH] =?UTF-8?q?bugfix-=E5=A2=9E=E5=8A=A0RoleExportExcelVO?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E6=8D=AE=E8=8C=83=E5=9B=B4=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BB=8E=E5=AD=97=E5=85=B8=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?=E5=8F=96=E5=80=BC=EF=BC=9BRoleSaveReqVO=E4=B8=ADcode=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=90=8D=E6=94=B9=E4=B8=BA=E8=A7=92=E8=89=B2=E6=A0=87?= =?UTF-8?q?=E8=AF=86=EF=BC=8C=E4=BF=9D=E6=8C=81=E6=8F=90=E7=A4=BA=E6=96=87?= =?UTF-8?q?=E6=A1=88=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/enums/DictTypeConstants.java | 1 + .../system/enums/ErrorCodeConstants.java | 4 +-- .../admin/permission/RoleController.java | 4 +-- .../permission/vo/role/RoleExportExcelVO.java | 32 +++++++++++++++++++ .../admin/permission/vo/role/RoleRespVO.java | 13 -------- .../permission/vo/role/RoleSaveReqVO.java | 2 +- 6 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleExportExcelVO.java diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java index d7967fe28..e91aea886 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java @@ -13,6 +13,7 @@ public interface DictTypeConstants { // ========== SYSTEM 模块 ========== String USER_SEX = "system_user_sex"; // 用户性别 + String DATA_SCOPE = "system_data_scope"; // 数据范围 String LOGIN_TYPE = "system_login_type"; // 登录日志的类型 String LOGIN_RESULT = "system_login_result"; // 登录结果 diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index e360a426b..5a44a9869 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -27,10 +27,10 @@ public interface ErrorCodeConstants { // ========== 角色模块 1-002-002-000 ========== ErrorCode ROLE_NOT_EXISTS = new ErrorCode(1_002_002_000, "角色不存在"); ErrorCode ROLE_NAME_DUPLICATE = new ErrorCode(1_002_002_001, "已经存在名为【{}】的角色"); - ErrorCode ROLE_CODE_DUPLICATE = new ErrorCode(1_002_002_002, "已经存在编码为【{}】的角色"); + ErrorCode ROLE_CODE_DUPLICATE = new ErrorCode(1_002_002_002, "已经存在标识为【{}】的角色"); ErrorCode ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE = new ErrorCode(1_002_002_003, "不能操作类型为系统内置的角色"); ErrorCode ROLE_IS_DISABLE = new ErrorCode(1_002_002_004, "名字为【{}】的角色已被禁用"); - ErrorCode ROLE_ADMIN_CODE_ERROR = new ErrorCode(1_002_002_005, "编码【{}】不能使用"); + ErrorCode ROLE_ADMIN_CODE_ERROR = new ErrorCode(1_002_002_005, "标识【{}】不能使用"); // ========== 用户模块 1-002-003-000 ========== ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1_002_003_000, "用户账号已经存在"); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java index cf2268752..c1923e196 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java @@ -93,8 +93,8 @@ public class RoleController { exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = roleService.getRolePage(exportReqVO).getList(); // 输出 - ExcelUtils.write(response, "角色数据.xls", "数据", RoleRespVO.class, - BeanUtils.toBean(list, RoleRespVO.class)); + ExcelUtils.write(response, "角色数据.xls", "数据", RoleExportExcelVO.class, + BeanUtils.toBean(list, RoleExportExcelVO.class)); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleExportExcelVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleExportExcelVO.java new file mode 100644 index 000000000..46bccd416 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleExportExcelVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.system.controller.admin.permission.vo.role; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +@Data +public class RoleExportExcelVO { + + @ExcelProperty("角色序号") + private Long id; + + @ExcelProperty("角色名称") + private String name; + + @ExcelProperty("角色标志") + private String code; + + @ExcelProperty("角色排序") + private Integer sort; + + @ExcelProperty(value = "角色状态", converter = DictConvert.class) + @DictFormat(DictTypeConstants.COMMON_STATUS) + private Integer status; + + @ExcelProperty(value = "数据范围", converter = DictConvert.class) + @DictFormat(DictTypeConstants.DATA_SCOPE) + private Integer dataScope; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleRespVO.java index 4c36ab377..8adf501d3 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleRespVO.java @@ -1,10 +1,5 @@ package cn.iocoder.yudao.module.system.controller.admin.permission.vo.role; -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import lombok.Data; @@ -14,29 +9,22 @@ import java.util.Set; @Schema(description = "管理后台 - 角色信息 Response VO") @Data -@ExcelIgnoreUnannotated public class RoleRespVO { @Schema(description = "角色编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("角色序号") private Long id; @Schema(description = "角色名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "管理员") - @ExcelProperty("角色名称") private String name; @Schema(description = "角色标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "admin") @NotBlank(message = "角色标志不能为空") - @ExcelProperty("角色标志") private String code; @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("角色排序") private Integer sort; @Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty(value = "角色状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) private Integer status; @Schema(description = "角色类型,参见 RoleTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @@ -46,7 +34,6 @@ public class RoleRespVO { private String remark; @Schema(description = "数据范围,参见 DataScopeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("数据范围") private Integer dataScope; @Schema(description = "数据范围(指定部门数组)", example = "1") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleSaveReqVO.java index 5c02a92da..2d273f360 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleSaveReqVO.java @@ -24,7 +24,7 @@ public class RoleSaveReqVO { @NotBlank(message = "角色标志不能为空") @Size(max = 100, message = "角色标志长度不能超过 100 个字符") - @Schema(description = "角色编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "ADMIN") + @Schema(description = "角色标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "ADMIN") @DiffLogField(name = "角色标志") private String code;