mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
项目结构调整 x 9 : 分拆字典类型的枚举分拆
This commit is contained in:
@ -16,16 +16,6 @@
|
||||
<description>基础框架,各种组件的拓展</description>
|
||||
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
|
||||
|
||||
<properties>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<resource.delimiter>@</resource.delimiter>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring 核心 -->
|
||||
<dependency>
|
||||
|
@ -1,7 +1,5 @@
|
||||
package cn.iocoder.dashboard.framework.excel.core.annotations;
|
||||
|
||||
import cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
@ -14,6 +12,11 @@ import java.lang.annotation.*;
|
||||
@Inherited
|
||||
public @interface DictFormat {
|
||||
|
||||
SysDictTypeEnum value();
|
||||
/**
|
||||
* 例如说,SysDictTypeConstants、InfDictTypeConstants
|
||||
*
|
||||
* @return 字典类型
|
||||
*/
|
||||
String value();
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.iocoder.dashboard.framework.dict.core.dto.DictDataRespDTO;
|
||||
import cn.iocoder.dashboard.framework.dict.core.util.DictUtils;
|
||||
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum;
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.CellData;
|
||||
@ -35,9 +34,9 @@ public class DictConvert implements Converter<Object> {
|
||||
public Object convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
// 使用字典解析
|
||||
SysDictTypeEnum type = getType(contentProperty);
|
||||
String type = getType(contentProperty);
|
||||
String label = cellData.getStringValue();
|
||||
DictDataRespDTO dictData = DictUtils.parseDictDataFromCache(type.getValue(), label);
|
||||
DictDataRespDTO dictData = DictUtils.parseDictDataFromCache(type, label);
|
||||
if (dictData == null) {
|
||||
log.error("[convertToJavaData][type({}) 解析不掉 label({})]", type, label);
|
||||
return null;
|
||||
@ -56,9 +55,9 @@ public class DictConvert implements Converter<Object> {
|
||||
}
|
||||
|
||||
// 使用字典格式化
|
||||
SysDictTypeEnum type = getType(contentProperty);
|
||||
String type = getType(contentProperty);
|
||||
String value = String.valueOf(object);
|
||||
DictDataRespDTO dictData = DictUtils.getDictDataFromCache(type.getValue(), value);
|
||||
DictDataRespDTO dictData = DictUtils.getDictDataFromCache(type, value);
|
||||
if (dictData == null) {
|
||||
log.error("[convertToExcelData][type({}) 转换不了 label({})]", type, value);
|
||||
return new CellData<>("");
|
||||
@ -67,7 +66,7 @@ public class DictConvert implements Converter<Object> {
|
||||
return new CellData<>(dictData.getLabel());
|
||||
}
|
||||
|
||||
private static SysDictTypeEnum getType(ExcelContentProperty contentProperty) {
|
||||
private static String getType(ExcelContentProperty contentProperty) {
|
||||
return contentProperty.getField().getAnnotation(DictFormat.class).value();
|
||||
}
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.enums.dict;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 字典类型的类型枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum SysDictTypeEnum {
|
||||
|
||||
USER_TYPE("user_type"), // 用户类型
|
||||
|
||||
SYS_USER_SEX("sys_user_sex"), // 用户性别
|
||||
SYS_COMMON_STATUS("sys_common_status"), // 系统状态
|
||||
SYS_OPERATE_TYPE("sys_operate_type"), // 操作类型
|
||||
SYS_LOGIN_RESULT("sys_login_result"), // 登陆结果
|
||||
SYS_CONFIG_TYPE("sys_config_type"), // 参数配置类型
|
||||
SYS_BOOLEAN_STRING("sys_boolean_string"), // Boolean 是否类型
|
||||
SYS_SMS_CHANNEL_CODE("sys_sms_channel_code"), // 短信渠道编码
|
||||
SYS_SMS_TEMPLATE_TYPE("sys_sms_template_type"), // 短信模板类型
|
||||
SYS_SMS_SEND_STATUS("sys_sms_send_status"), // 短信发送状态
|
||||
SYS_SMS_RECEIVE_STATUS("sys_sms_receive_status"), // 短信接收状态
|
||||
SYS_ERROR_CODE_TYPE("inf_error_code_type"), // 错误码的类型枚举
|
||||
|
||||
INF_REDIS_TIMEOUT_TYPE("inf_redis_timeout_type"), // Redis 超时类型
|
||||
INF_JOB_STATUS("inf_job_status"), // 定时任务状态的枚举
|
||||
INF_JOB_LOG_STATUS("inf_job_log_status"), // 定时任务日志状态的枚举
|
||||
INF_API_ERROR_LOG_PROCESS_STATUS("inf_api_error_log_process_status"), // API 错误日志的处理状态的枚举
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private final String value;
|
||||
|
||||
}
|
Reference in New Issue
Block a user