From ef2bd5e6a4faa3660d34f1b41079f889c57c545b Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期五, 25 八月 2023 12:28:04 +0800
Subject: [PATCH] update springboot 3.1.2 => 3.1.3 update springboot-admin 3.1.3 => 3.1.5 update springdoc 2.1.0 => 2.2.0
---
ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/convert/ExcelEnumConvert.java | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/convert/ExcelEnumConvert.java b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/convert/ExcelEnumConvert.java
index 3b52695..b948ea7 100644
--- a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/convert/ExcelEnumConvert.java
+++ b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/convert/ExcelEnumConvert.java
@@ -37,14 +37,26 @@
@Override
public Object convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
- Object codeValue = cellData.getData();
+ cellData.checkEmpty();
+ // Excel涓~鍏ョ殑鏄灇涓句腑鎸囧畾鐨勬弿杩�
+ Object textValue = switch (cellData.getType()) {
+ case STRING, DIRECT_STRING, RICH_TEXT_STRING -> cellData.getStringValue();
+ case NUMBER -> cellData.getNumberValue();
+ case BOOLEAN -> cellData.getBooleanValue();
+ default -> throw new IllegalArgumentException("鍗曞厓鏍肩被鍨嬪紓甯�!");
+ };
// 濡傛灉鏄┖鍊�
- if (ObjectUtil.isNull(codeValue)) {
+ if (ObjectUtil.isNull(textValue)) {
return null;
}
- Map<Object, String> enumValueMap = beforeConvert(contentProperty);
- String textValue = enumValueMap.get(codeValue);
- return Convert.convert(contentProperty.getField().getType(), textValue);
+ Map<Object, String> enumCodeToTextMap = beforeConvert(contentProperty);
+ // 浠嶫ava杈撳嚭鑷矱xcel鏄痗ode杞瑃ext
+ // 鍥犳浠嶦xcel杞琂ava搴旇灏唗ext涓巆ode瀵硅皟
+ Map<Object, Object> enumTextToCodeMap = new HashMap<>();
+ enumCodeToTextMap.forEach((key, value) -> enumTextToCodeMap.put(value, key));
+ // 搴旇浠巘ext -> code涓煡鎵�
+ Object codeValue = enumTextToCodeMap.get(textValue);
+ return Convert.convert(contentProperty.getField().getType(), codeValue);
}
@Override
--
Gitblit v1.9.3