From 66cd8c6ea47be03a991e95d65ad6f7eb10e6a00e Mon Sep 17 00:00:00 2001 From: memorylkf <312904636@qq.com> Date: Thu, 5 Feb 2026 15:49:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20[=E5=AF=BC=E5=87=BA]=20=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=94=AF=E6=8C=81=E4=B8=AD=E8=8B=B1=E6=96=87=E8=A1=A8?= =?UTF-8?q?=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hxhq/system/api/domain/SysRole.java | 19 +++++++++++++++---- .../java/com/hxhq/common/core/annotation/Excel.java | 5 +++++ .../com/hxhq/common/core/utils/poi/ExcelUtil.java | 10 +++++++--- .../java/com/hxhq/business/domain/RoleChange.java | 10 +++++----- .../com/hxhq/system/controller/SysRoleController.java | 4 ++++ .../com/hxhq/system/controller/SysUserController.java | 4 +++- .../main/java/com/hxhq/system/dto/UserExportDto.java | 12 ++++++------ 7 files changed, 45 insertions(+), 19 deletions(-) diff --git a/hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/domain/SysRole.java b/hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/domain/SysRole.java index d0847b8..7e05d0d 100644 --- a/hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/domain/SysRole.java +++ b/hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/domain/SysRole.java @@ -25,12 +25,12 @@ public class SysRole extends BaseEntity private Long roleId; /** 角色名称 */ - @Excel(name = "角色名称",sort = 1) + @Excel(name = "角色名称",nameEn = "Role Name",sort = 1) @Compare(name = "角色名称",nameEn = "Role Name") private String roleName; /** 角色权限 */ - @Excel(name = "角色编码",sort = 2) + @Excel(name = "角色编码",nameEn = "Role ID",sort = 2) @Compare(name = "角色编码",nameEn = "Role ID") private String roleKey; @@ -47,9 +47,12 @@ public class SysRole extends BaseEntity private boolean deptCheckStrictly; /** 角色状态(0正常 1停用) */ - @Excel(name = "状态", readConverterExp = "0=启用,1=禁用",sort = 4) private String status; + /** 角色显示名称 */ + @Excel(name = "状态",nameEn = "Status",sort = 4) + private String statusText; + /** 删除标志(0代表存在 2代表删除) */ private String delFlag; @@ -66,7 +69,7 @@ public class SysRole extends BaseEntity private Set permissions; /** 备注 */ - @Excel(name = "备注",sort = 3) + @Excel(name = "备注",nameEn = "Role Description",sort = 3) @Compare(name = "备注",nameEn = "Role Description") private String remark; @@ -175,6 +178,14 @@ public class SysRole extends BaseEntity this.status = status; } + public String getStatusText() { + return statusText; + } + + public void setStatusText(String statusText) { + this.statusText = statusText; + } + public String getDelFlag() { return delFlag; diff --git a/hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/annotation/Excel.java b/hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/annotation/Excel.java index e805085..21aa240 100644 --- a/hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/annotation/Excel.java +++ b/hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/annotation/Excel.java @@ -29,6 +29,11 @@ public @interface Excel public String name() default ""; /** + * 导出到Excel中的名字. + */ + public String nameEn() default ""; + + /** * 日期格式, 如: yyyy-MM-dd */ public String dateFormat() default ""; diff --git a/hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/utils/poi/ExcelUtil.java b/hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/utils/poi/ExcelUtil.java index 7e39741..339886d 100644 --- a/hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/utils/poi/ExcelUtil.java +++ b/hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/utils/poi/ExcelUtil.java @@ -19,11 +19,13 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.hxhq.common.core.annotation.Excel; import com.hxhq.common.core.exception.UtilException; import com.hxhq.common.core.utils.DateUtils; +import com.hxhq.common.core.utils.ServletUtils; import com.hxhq.common.core.utils.StringUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RegExUtils; @@ -62,6 +64,8 @@ import com.hxhq.common.core.text.Convert; import com.hxhq.common.core.utils.file.FileTypeUtils; import com.hxhq.common.core.utils.file.ImageUtils; import com.hxhq.common.core.utils.reflect.ReflectUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; /** * Excel相关处理 @@ -255,7 +259,7 @@ public class ExcelUtil if (Collection.class.isAssignableFrom(field.getType())) { Cell cell = subRow.createCell(column); - cell.setCellValue(attr.name()); + cell.setCellValue(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?attr.name():attr.nameEn()); cell.setCellStyle(cellStyle); int subFieldSize = subFieldsMap != null ? subFieldsMap.get(field.getName()).size() : 0; if (subFieldSize > 1) @@ -268,7 +272,7 @@ public class ExcelUtil else { Cell cell = subRow.createCell(column++); - cell.setCellValue(attr.name()); + cell.setCellValue(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?attr.name():attr.nameEn()); cell.setCellStyle(cellStyle); } } @@ -840,7 +844,7 @@ public class ExcelUtil // 创建列 Cell cell = row.createCell(column); // 写入列信息 - cell.setCellValue(attr.name()); + cell.setCellValue(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?attr.name():attr.nameEn()); setDataValidation(attr, row, column); cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor()))); if (isSubList()) diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/RoleChange.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/RoleChange.java index fa2a2ff..6abc910 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/RoleChange.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/RoleChange.java @@ -26,7 +26,7 @@ public class RoleChange extends MpBaseEntity private Long userId; /** 操作类型 */ - @Excel(name = "操作类型",sort = 2) + @Excel(name = "操作类型",nameEn = "Meaning of Signature",sort = 2) private String jcmc; /** 操作类型-英文 */ @@ -36,23 +36,23 @@ public class RoleChange extends MpBaseEntity private Long qmrId; /** 操作人名称 */ - @Excel(name = "签名人",sort = 1) + @Excel(name = "签名人",nameEn = "Signed By",sort = 1) private String qmrMc; /** 操作人名称-英文 */ private String qmrMcEn; /** 变更前角色 */ - @Excel(name = "变更前角色",sort = 4) + @Excel(name = "变更前角色",nameEn = "Role Before Change",sort = 4) private String bgq; /** 变更后角色 */ - @Excel(name = "变更后角色",sort = 5) + @Excel(name = "变更后角色",nameEn = "Role After Change",sort = 5) private String bgh; /** 创建时间 */ @TableField(exist = false) - @Excel(name = "签名时间",sort = 3) + @Excel(name = "签名时间", nameEn = "Date",sort = 3) private String createTimeText; diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysRoleController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysRoleController.java index b20c476..b7bb82e 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysRoleController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysRoleController.java @@ -11,6 +11,7 @@ import com.hxhq.business.form.common.SignForm; import com.hxhq.business.service.IRoleChangeService; import com.hxhq.business.service.ISystemLogService; import com.hxhq.common.core.exception.ServiceException; +import com.hxhq.common.core.utils.ServletUtils; import com.hxhq.common.core.utils.StringUtils; import com.hxhq.system.domain.SysUserRole; import com.hxhq.system.form.RoleUserSaveForm; @@ -79,6 +80,9 @@ public class SysRoleController extends BaseController public void export(HttpServletResponse response, SysRole role) { List list = roleService.selectRoleList(role); + for(SysRole l : list){ + l.setStatusText("0".endsWith(l.getStatus())?(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?"启用":"Enabled"):(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?"禁用":"Disabled")); + } ExcelUtil util = new ExcelUtil(SysRole.class); util.exportExcel(response, list, "角色数据"); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java index aa11f45..2f0aaa9 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java @@ -13,6 +13,7 @@ import com.hxhq.business.dto.select.DeptUserTreeDto; import com.hxhq.business.enums.dept.DeptTypeEnum; import com.hxhq.business.enums.study.StudyTypeEnum; import com.hxhq.business.service.IStudyService; +import com.hxhq.common.core.utils.ServletUtils; import com.hxhq.system.dto.UserExportDto; import com.hxhq.system.form.UserSaveForm; import com.hxhq.system.service.ISysConfigService; @@ -119,7 +120,8 @@ public class SysUserController extends BaseController exportDto.setEmail(u.getEmail()); exportDto.setDeptName(u.getDept()==null?"":u.getDept().getDeptName()); exportDto.setRoleName(getRoleName(u.getRoles())); - exportDto.setStatus(u.getStatus()); + + exportDto.setStatus("0".endsWith(u.getStatus())?(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?"启用":"Enabled"):(ServletUtils.getRequest().getHeader("lang").equals("zh_CN")?"禁用":"Disabled")); userList.add(exportDto); } ExcelUtil util = new ExcelUtil(UserExportDto.class); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/dto/UserExportDto.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/dto/UserExportDto.java index 93e961a..ea5f3bd 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/dto/UserExportDto.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/dto/UserExportDto.java @@ -9,32 +9,32 @@ public class UserExportDto { /** * 账号 */ - @Excel(name = "账号") + @Excel(name = "账号",nameEn = "User") private String userName; /** * 姓名 */ - @Excel(name = "姓名") + @Excel(name = "姓名",nameEn = "Name") private String nickName; /** * 手机 */ - @Excel(name = "邮箱") + @Excel(name = "邮箱",nameEn = "Email") private String email; /** * 所属部门/学科 */ - @Excel(name = "所属部门/学科") + @Excel(name = "所属部门/学科",nameEn = "Department") private String deptName; /** * 所属角色 */ - @Excel(name = "所属角色") + @Excel(name = "所属角色",nameEn = "Owned RoleOwned Role") private String roleName; /** * 状态 */ - @Excel(name = "状态", readConverterExp = "0=启用,1=禁用") + @Excel(name = "状态",nameEn = "Status") private String status; public String getUserName() {