) conversionService.convert(str, TypeDescriptor.valueOf(String.class), TypeDescriptor.map(map.getClass(), TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
Assert.assertEquals(3, map.size());
}
diff --git a/storage/src/test/java/com/zfoo/storage/excel/ExcelTest.java b/storage/src/test/java/com/zfoo/storage/excel/ExcelTest.java
index 2e7220cd..ee3902a3 100644
--- a/storage/src/test/java/com/zfoo/storage/excel/ExcelTest.java
+++ b/storage/src/test/java/com/zfoo/storage/excel/ExcelTest.java
@@ -13,6 +13,7 @@
package com.zfoo.storage.excel;
+import com.zfoo.storage.util.ExcelToJsonUtils;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
@@ -32,6 +33,13 @@ import java.util.Iterator;
@Ignore
public class ExcelTest {
+ @Test
+ public void excelConvertJson() throws Exception{
+ String inputDir = "E:\\workspace\\zfoo\\storage\\src\\test\\resources\\excel";
+ String outputDir = "E:\\workspace\\zfoo\\storage\\src\\test\\resources\\excel";
+ ExcelToJsonUtils.excelConvertJson(inputDir, outputDir);
+ }
+
@Test
public void createExcelTest() throws IOException {
//第一步创建workbook
diff --git a/storage/src/test/java/com/zfoo/storage/resource/StudentResource.java b/storage/src/test/java/com/zfoo/storage/resource/StudentResource.java
index 88039ac7..172c26e3 100644
--- a/storage/src/test/java/com/zfoo/storage/resource/StudentResource.java
+++ b/storage/src/test/java/com/zfoo/storage/resource/StudentResource.java
@@ -21,7 +21,7 @@ import com.zfoo.storage.model.anno.Resource;
* @author jaysunxiao
* @version 3.0
*/
-//@Resource
+@Resource
public class StudentResource {
@Id
diff --git a/storage/src/test/resources/StudentResource.xlsx b/storage/src/test/resources/StudentResource.xlsx
new file mode 100644
index 00000000..d7378b7a
Binary files /dev/null and b/storage/src/test/resources/StudentResource.xlsx differ
diff --git a/storage/src/test/resources/application.xml b/storage/src/test/resources/application.xml
index 819e37fd..500143be 100644
--- a/storage/src/test/resources/application.xml
+++ b/storage/src/test/resources/application.xml
@@ -49,9 +49,8 @@
-
-
-
+
+
\ No newline at end of file
diff --git a/storage/src/test/resources/excel/TestResource.txt b/storage/src/test/resources/excel/TestResource.txt
index de49bb5d..99b958f6 100644
--- a/storage/src/test/resources/excel/TestResource.txt
+++ b/storage/src/test/resources/excel/TestResource.txt
@@ -1,45 +1,55 @@
{
"name": "Test",
- "columns": [
+ "header": [
{
"name": "Id",
- "type": "int"
+ "type": "int",
+ "index" : 0
},
{
"name": "Type0",
- "type": "long"
+ "type": "long",
+ "index" : 0
},
{
"name": "Type1",
- "type": "string"
+ "type": "string",
+ "index" : 0
},
{
"name": "Type2",
- "type": "list\u003cstring\u003e"
+ "type": "list\u003cstring\u003e",
+ "index" : 0
},
{
"name": "Type3",
- "type": "list\u003cint\u003e"
+ "type": "list\u003cint\u003e",
+ "index" : 0
},
{
"name": "Type4",
- "type": "list\u003clong\u003e"
+ "type": "list\u003clong\u003e",
+ "index" : 0
},
{
"name": "Type5",
- "type": "array\u003cattr,id,name\u003e"
+ "type": "array\u003cattr,id,name\u003e",
+ "index" : 0
},
{
"name": "Type8",
- "type": "map\u003cint,int\u003e"
+ "type": "map\u003cint,int\u003e",
+ "index" : 0
},
{
"name": "Type9",
- "type": "map\u003cint,string\u003e"
+ "type": "map\u003cint,string\u003e",
+ "index" : 0
},
{
"name": "Type10",
- "type": "map\u003cstring,string\u003e"
+ "type": "map\u003cstring,string\u003e",
+ "index" : 0
}
],
"data": [
diff --git a/util/src/main/java/com/zfoo/util/security/AesUtils.java b/util/src/main/java/com/zfoo/util/security/AesUtils.java
index 083c3738..c1e68242 100644
--- a/util/src/main/java/com/zfoo/util/security/AesUtils.java
+++ b/util/src/main/java/com/zfoo/util/security/AesUtils.java
@@ -20,6 +20,7 @@ import io.netty.util.concurrent.FastThreadLocal;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
+import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
@@ -29,7 +30,7 @@ import java.util.Base64;
*
* 默认AES/ECB/PKCS5Padding
*
- * @author jaysunxiao
+ * @author godotg
* @version 3.0
*/
public abstract class AesUtils {
@@ -46,13 +47,6 @@ public abstract class AesUtils {
*/
private static final String ALGORITHM_STR = "AES/ECB/PKCS5Padding";
- private static final FastThreadLocal LOCAL_CIPHER = new FastThreadLocal() {
- @Override
- protected Cipher initialValue() throws NoSuchPaddingException, NoSuchAlgorithmException {
- return Cipher.getInstance(ALGORITHM_STR);
- }
- };
-
static {
try {
KEY = new SecretKeySpec(KEY_STR.getBytes(StringUtils.DEFAULT_CHARSET_NAME), ALGORITHM);
@@ -61,6 +55,24 @@ public abstract class AesUtils {
}
}
+ private static final FastThreadLocal LOCAL_ENCRYPT_CIPHER = new FastThreadLocal() {
+ @Override
+ protected Cipher initialValue() throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException {
+ var cipher = Cipher.getInstance(ALGORITHM_STR);
+ cipher.init(Cipher.ENCRYPT_MODE, KEY);
+ return cipher;
+ }
+ };
+
+ private static final FastThreadLocal LOCAL_DECRYPT_CIPHER = new FastThreadLocal() {
+ @Override
+ protected Cipher initialValue() throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException {
+ var cipher = Cipher.getInstance(ALGORITHM_STR);
+ cipher.init(Cipher.DECRYPT_MODE, KEY);
+ return cipher;
+ }
+ };
+
/**
* 对str进行AES加密
@@ -81,9 +93,7 @@ public abstract class AesUtils {
public static byte[] encrypt(byte[] bytes) {
try {
- var cipher = LOCAL_CIPHER.get();
- cipher.init(Cipher.ENCRYPT_MODE, KEY);
- return cipher.doFinal(bytes);
+ return LOCAL_ENCRYPT_CIPHER.get().doFinal(bytes);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -108,9 +118,7 @@ public abstract class AesUtils {
public static byte[] decrypt(byte[] bytes) {
try {
- var cipher = LOCAL_CIPHER.get();
- cipher.init(Cipher.DECRYPT_MODE, KEY);
- return cipher.doFinal(bytes);
+ return LOCAL_DECRYPT_CIPHER.get().doFinal(bytes);
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/util/src/test/java/com/zfoo/util/security/AesUtilsTest.java b/util/src/test/java/com/zfoo/util/security/AesUtilsTest.java
index 977fdd68..cdaf5a8b 100644
--- a/util/src/test/java/com/zfoo/util/security/AesUtilsTest.java
+++ b/util/src/test/java/com/zfoo/util/security/AesUtilsTest.java
@@ -23,9 +23,11 @@ public class AesUtilsTest {
@Test
public void test() {
- String passWord = "hello world";
- String encodePassWorld = AesUtils.getEncryptString(passWord);
- Assert.assertEquals(passWord, AesUtils.getDecryptString(encodePassWorld));
+ for (int i = 0; i < 10; i++) {
+ var passWord = "hello world";
+ var encodePassWorld = AesUtils.getEncryptString(passWord);
+ Assert.assertEquals(passWord, AesUtils.getDecryptString(encodePassWorld));
+ }
}
}