values, HSSFWorkbook wb) {
+
+ // 第一步,创建一个HSSFWorkbook,对应一个Excel文件
+ if (wb == null) {
+ wb = new HSSFWorkbook();
+ }
+
+ // 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet
+ HSSFSheet sheet = wb.createSheet(sheetName);
+
+ // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
+ HSSFRow row = sheet.createRow(0);
+
+ // 第四步,创建单元格,并设置值表头 设置表头居中
+ HSSFCellStyle style = wb.createCellStyle();
+ // 创建一个居中格式
+ style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+
+ //声明列对象
+ HSSFCell cell;
+
+ //创建标题
+ for (int i = 0; i < title.length; i++) {
+ cell = row.createCell(i);
+ cell.setCellValue(title[i]);
+ cell.setCellStyle(style);
+ }
+
+ //创建内容
+ for (int i = 0; i < values.size(); i++) {
+ row = sheet.createRow(i + 1);
+ for (int j = 0; j < values.get(i).length; j++) {
+ //将内容按顺序赋给对应的列对象
+ row.createCell(j).setCellValue(values.get(i)[j]);
+ }
+ }
+ return wb;
+ }
+}
diff --git a/src/main/java/com/rehome/jpahefengweather/utils/IPaging.java b/src/main/java/com/rehome/jpahefengweather/utils/IPaging.java
new file mode 100644
index 0000000..b8e8aa9
--- /dev/null
+++ b/src/main/java/com/rehome/jpahefengweather/utils/IPaging.java
@@ -0,0 +1,38 @@
+package com.rehome.jpahefengweather.utils;
+
+/**
+ * 分页接口
+ *
+ * @ApiModelProperty("分页信息")
+ * private Paging paging = new Paging();
+ *
+ * @Override
+ * public Paging getPaging() {
+ * return paging;
+ * }
+ *
+ * @Override
+ * public void setPaging(Paging paging) {
+ * this.paging = paging;
+ * }
+ *
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2022-01-12 10:22
+ */
+public interface IPaging {
+ /**
+ * 获取分页信息
+ * @author LiuHuiYu
+ * Created DateTime 2022-01-20 15:29
+ * @return cc.rehome.zhanjiang.data_center_model.domain.Paging
+ */
+ Paging getPaging();
+ /**
+ * 设置分页信息
+ * @author LiuHuiYu
+ * Created DateTime 2022-01-20 15:29
+ * @param paging 分页信息
+ */
+ void setPaging(Paging paging);
+}
diff --git a/src/main/java/com/rehome/jpahefengweather/utils/ISerializationJson.java b/src/main/java/com/rehome/jpahefengweather/utils/ISerializationJson.java
new file mode 100644
index 0000000..59c28f0
--- /dev/null
+++ b/src/main/java/com/rehome/jpahefengweather/utils/ISerializationJson.java
@@ -0,0 +1,18 @@
+package com.rehome.jpahefengweather.utils;
+
+import java.io.Serializable;
+
+/**
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2022-01-08 9:45
+ */
+public interface ISerializationJson extends Serializable {
+ /**
+ * 将当前类序列化成json字符串
+ * @author LiuHuiYu
+ * Created DateTime 2022-01-20 15:30
+ * @return java.lang.String
+ */
+ String toJson();
+}
diff --git a/src/main/java/com/rehome/jpahefengweather/utils/JwtUtils.java b/src/main/java/com/rehome/jpahefengweather/utils/JwtUtils.java
new file mode 100644
index 0000000..e241ca5
--- /dev/null
+++ b/src/main/java/com/rehome/jpahefengweather/utils/JwtUtils.java
@@ -0,0 +1,66 @@
+package com.rehome.jpahefengweather.utils;
+
+import net.i2p.crypto.eddsa.EdDSAEngine;
+import net.i2p.crypto.eddsa.EdDSAPrivateKey;
+import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable;
+import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec;
+import okhttp3.Interceptor;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.springframework.lang.NonNull;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.PrivateKey;
+import java.security.Signature;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.Base64;
+
+public class JwtUtils {
+ public static String getJwt(){
+ try {
+ // Private key
+ String privateKeyString = "MC4CAQAwBQYDK2VwBCIEIOtI2Yuhkyor4Zfny9OUMbzMmZCEJ7hqIpuoDhk0zYcy";
+ privateKeyString = privateKeyString.trim().replace("-----BEGIN PRIVATE KEY-----", "").replace("-----END PRIVATE KEY-----", "").trim();
+ byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyString);
+ PKCS8EncodedKeySpec encoded = new PKCS8EncodedKeySpec(privateKeyBytes);
+ PrivateKey privateKey = new EdDSAPrivateKey(encoded);
+
+ // Header
+ String headerJson = "{\"alg\": \"EdDSA\", \"kid\": \"C4B98RHV2D\"}";
+
+ // Payload
+ long iat = ZonedDateTime.now(ZoneOffset.UTC).toEpochSecond() - 30;
+ long exp = iat + 900;
+ String payloadJson = "{\"sub\": \"278AVHGU9W\", \"iat\": " + iat + ", \"exp\": " + exp + "}";
+
+ // Base64url header+payload
+ String headerEncoded = Base64.getUrlEncoder().encodeToString(headerJson.getBytes(StandardCharsets.UTF_8));
+ String payloadEncoded = Base64.getUrlEncoder().encodeToString(payloadJson.getBytes(StandardCharsets.UTF_8));
+ String data = headerEncoded + "." + payloadEncoded;
+
+ EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519);
+
+ // Sign
+ final Signature s = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm()));
+ s.initSign(privateKey);
+ s.update(data.getBytes(StandardCharsets.UTF_8));
+ byte[] signature = s.sign();
+
+ String signatureString = Base64.getUrlEncoder().encodeToString(signature);
+
+ System.out.println("Signature: \n" + signatureString);
+
+ // Print Token
+ String jwt = data + "." + signatureString;
+ System.out.println("JWT: \n" + jwt);
+ return jwt;
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/com/rehome/jpahefengweather/utils/LhyAssert.java b/src/main/java/com/rehome/jpahefengweather/utils/LhyAssert.java
new file mode 100644
index 0000000..fa9e4e2
--- /dev/null
+++ b/src/main/java/com/rehome/jpahefengweather/utils/LhyAssert.java
@@ -0,0 +1,142 @@
+package com.rehome.jpahefengweather.utils;
+
+
+import java.util.function.Function;
+
+/**
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2020-09-10 8:41
+ */
+public class LhyAssert {
+ static Function exceptionProxy;
+
+ private static RuntimeException throwEx(String message) {
+ if (exceptionProxy == null) {
+ return new RuntimeException(message);
+ }
+ else {
+ return exceptionProxy.apply(message);
+ }
+ }
+
+ /**
+ * 接受到异常信息后的异常抛出处理
+ *
+ * @param proxy 接受到异常信息后的代理。
+ * @author LiuHuiYu
+ * Created DateTime 2021-12-10 14:43
+ */
+ public static void exceptionProxy(Function proxy) {
+ exceptionProxy = proxy;
+ }
+ //region assertTrue
+
+ public static void assertTrue(boolean value, RuntimeException exception) {
+ if (!value) {
+ throw exception;
+ }
+ }
+
+ public static void assertTrue(boolean value, String message) {
+ assertTrue(value, throwEx(message));
+ }
+ //endregion
+
+ //region assertFalse
+
+ public static void assertFalse(boolean value, String message) {
+ assertTrue(!value, message);
+ }
+
+ public static void assertFalse(boolean value, RuntimeException exception) {
+ assertTrue(!value, exception);
+ }
+ //endregion
+
+ //region assertNotNull
+ public static void assertNotNull(Object object, RuntimeException exception) {
+ assertTrue(object != null, exception);
+ }
+
+ /**
+ * 对象为空则抛出异常
+ *
+ * @param object 对象
+ */
+ public static void assertNotNull(Object object, String message) {
+ assertTrue(object != null, message);
+ }
+
+
+ //endregion
+
+ //region assertNull
+
+ /**
+ * 对象不为空则抛出异常
+ *
+ * @param object 对象
+ */
+ public static void assertNull(Object object, RuntimeException exception) {
+ assertTrue(object == null, exception);
+ }
+
+ /**
+ * 对象不为空则抛出异常
+ *
+ * @param object 对象
+ */
+ public static void assertNull(Object object, String message) {
+ assertTrue(object == null, message);
+ }
+ //endregion
+
+ //region 枚举模式拦截
+
+ /**
+ * 对象不为空则抛出异常
+ *
+ * @param value 对象
+ * @param resultEnum 错误枚举
+ */
+ public static void assertTrue(boolean value, ResultEnum resultEnum) {
+ if (!value) {
+ throw new LhyException(resultEnum);
+ }
+ }
+
+ /**
+ * 对象为空则抛出异常
+ *
+ * @param object 对象
+ * @param resultEnum 错误枚举
+ */
+ public static void assertNotNull(Object object, ResultEnum resultEnum) {
+ assertTrue(object != null, resultEnum);
+ }
+
+ /**
+ * 对象不为空则抛出异常
+ *
+ * @param object 对象
+ * @param resultEnum 错误枚举
+ */
+ public static void assertNull(Object object, ResultEnum resultEnum) {
+ assertTrue(object == null, resultEnum);
+ }
+ //endregion
+
+
+ public static void assertLen(String value, int min, int max, String message) {
+ assertNotNull(value, message + "未设定");
+ assertTrue(
+ (min <= 0 || value.length() >= min) &&
+ (max < 0 || value.length() <= max), message + "(长度范围[" + min + "-" + max + "])");
+ }
+
+ public static void assertLen(String value, int min, int max, RuntimeException exception) {
+ assertNotNull(value, exception);
+ assertTrue(value.length() >= min && value.length() <= max, exception);
+ }
+}
diff --git a/src/main/java/com/rehome/jpahefengweather/utils/LhyException.java b/src/main/java/com/rehome/jpahefengweather/utils/LhyException.java
new file mode 100644
index 0000000..f29819e
--- /dev/null
+++ b/src/main/java/com/rehome/jpahefengweather/utils/LhyException.java
@@ -0,0 +1,53 @@
+package com.rehome.jpahefengweather.utils;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * 自定义报错类
+ *
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2020-06-23 13:27
+ */
+public class LhyException extends RuntimeException {
+ private Integer errId;
+/*
+ public ArchivesManagementException(Integer code, String message) {
+ super(message);
+ this.code = code;
+ }
+*/
+
+ public LhyException(@NotNull ResultEnum resultEnum) {
+ super(resultEnum.getMessage());
+ this.errId = resultEnum.getCode();
+ }
+
+ public LhyException(@NotNull ResultEnum resultEnum, String message) {
+ super(resultEnum.getMessage() + ":" + message);
+ this.errId = resultEnum.getCode();
+ }
+
+ public LhyException(String message, @NotNull ResultEnum resultEnum) {
+ super(message + resultEnum.getMessage());
+ this.errId = resultEnum.getCode();
+ }
+
+ public LhyException(String message, @NotNull ResultEnum resultEnum, String message1) {
+ super(message + resultEnum.getMessage() + message1);
+ this.errId = resultEnum.getCode();
+ }
+
+ public LhyException(String message) {
+ super(message);
+ this.errId = 0;
+ }
+
+ public Integer getErrId() {
+ return errId;
+ }
+
+ public void setErrId(Integer errId) {
+ this.errId = errId;
+ }
+}
diff --git a/src/main/java/com/rehome/jpahefengweather/utils/MapToT.java b/src/main/java/com/rehome/jpahefengweather/utils/MapToT.java
new file mode 100644
index 0000000..554e4ac
--- /dev/null
+++ b/src/main/java/com/rehome/jpahefengweather/utils/MapToT.java
@@ -0,0 +1,18 @@
+package com.rehome.jpahefengweather.utils;
+
+import java.util.Map;
+
+/**
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2021-03-23 16:49
+ */
+@FunctionalInterface
+public interface MapToT {
+ /**
+ * Object 转换成 类型 T
+ * @param map Map
+ * @return T
+ */
+ T mapToT(Map map);
+}
diff --git a/src/main/java/com/rehome/jpahefengweather/utils/MapUtil.java b/src/main/java/com/rehome/jpahefengweather/utils/MapUtil.java
new file mode 100644
index 0000000..2061048
--- /dev/null
+++ b/src/main/java/com/rehome/jpahefengweather/utils/MapUtil.java
@@ -0,0 +1,637 @@
+package com.rehome.jpahefengweather.utils;
+
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
+import org.apache.commons.beanutils.BeanUtils;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+/**
+ * @author LiuHuiYu
+ * @version v1.0.0.0
+ * Created DateTime 2021-01-20 14:53
+ */
+public class MapUtil {
+
+ boolean throwException = false;
+
+ public boolean isThrowException() {
+ return throwException;
+ }
+
+ public void setThrowException(boolean throwException) {
+ this.throwException = throwException;
+ }
+
+ //region 静态方法
+
+ /**
+ * Map对象转换成Map对象
+ *
+ * @param obj Map对象
+ * @return Map对象
+ */
+ public static Map mapObjectToStringKeyMap(Object obj) {
+ if (obj == null) {
+ return null;
+ }
+ else if (obj instanceof Map, ?>) {
+ Map, ?> map = (Map, ?>) obj;
+ Map resMap = new HashMap<>(map.size());
+ map.forEach((k, v) -> resMap.put(k.toString(), v));
+ return resMap;
+ }
+ else {
+ return new HashMap<>(0);
+ }
+ }
+
+ private Object getMapObjectValue(Map map, String key) {
+ return getMapObjectValue(map, key, null);
+ }
+
+ private Object getMapObjectValue(Map map, String key, Object defValue) {
+ return map.getOrDefault(key, defValue);
+ }
+
+ public static String getMapStringValue(Map map, String key) {
+ return getMapStringValue(map, key, "");
+ }
+
+ /**
+ * 获取字符串(如果key 不存在返回 “”)
+ *
+ * @param map map
+ * @param key key
+ * @return 字符串
+ */
+ public static String getMapStringValue(Map map, String key, String defValue) {
+ if (map.containsKey(key)) {
+ Object obj = map.get(key);
+ return obj == null ? defValue : obj.toString();
+ }
+ else {
+ return defValue;
+ }
+ }
+
+ public static Integer getMapIntegerValue(Map map, String key) {
+ return getMapIntegerValue(map, key, 0);
+ }
+
+ public static Integer getMapIntegerValue(Map map, String key, Integer defValue) {
+ Object obj = map.getOrDefault(key, defValue);
+ if (obj == null) {
+ return defValue;
+ }
+ else if (obj instanceof Number) {
+ return ((Number) obj).intValue();
+ }
+ else {
+ String value = obj.toString();
+ try {
+ return Integer.parseInt(value);
+ }
+ catch (NumberFormatException ex) {
+ return defValue;
+ }
+ }
+ }
+
+ public static Float getMapFloatValue(Map map, String key) {
+ return getMapFloatValue(map, key, 0F);
+ }
+
+ public static Float getMapFloatValue(Map map, String key, Float defValue) {
+ Object obj = map.getOrDefault(key, defValue);
+ if (obj == null) {
+ return defValue;
+ }
+ else if (obj instanceof Number) {
+ return ((Number) obj).floatValue();
+ }
+ else {
+ String value = obj.toString();
+ try {
+ return Float.parseFloat(value);
+ }
+ catch (NumberFormatException ex) {
+ return defValue;
+ }
+ }
+ }
+
+ public static Long getMapLongValue(Map map, String key) {
+ return getMapLongValue(map, key, 0L);
+ }
+
+ public static Long getMapLongValue(Map map, String key, Long defValue) {
+ Object obj = map.getOrDefault(key, defValue);
+ if (obj == null) {
+ return defValue;
+ }
+ else if (obj instanceof Number) {
+ return ((Number) obj).longValue();
+ }
+ else {
+ String value = obj.toString();
+ try {
+ return Long.parseLong(value);
+ }
+ catch (NumberFormatException ex) {
+ return defValue;
+ }
+ }
+ }
+
+ public static Boolean getMapBooleanValue(Map map, String key) {
+ return getMapBooleanValue(map, key, false);
+ }
+
+ public static Boolean getMapBooleanValue(Map map, String key, boolean defValue) {
+ Object obj = map.getOrDefault(key, defValue);
+ if (obj == null) {
+ return defValue;
+ }
+ else if (obj instanceof Boolean) {
+ return (Boolean) obj;
+ }
+ try {
+ return Boolean.parseBoolean(obj.toString());
+ }
+ catch (Exception ex) {
+ return defValue;
+ }
+ }
+
+ /**
+ * 将 map 中的 可转化为 int 的数字转化为 int
+ *
+ * @param resultMap map
+ * @return 修正后的map
+ */
+ public static Map mapNumberToInt(Map, ?> resultMap) {
+ Map res = new HashMap<>(resultMap.size());
+ for (Object keyObj : resultMap.keySet()) {
+ String key = keyObj.toString();
+ if (resultMap.get(key) instanceof Double) {
+ Double value = (Double) resultMap.get(key);
+ if (value.intValue() == value) {
+ res.put(key, ((Double) resultMap.get(key)).intValue());
+ }
+ else {
+ res.put(key, resultMap.get(key));
+ }
+ }
+ else if (resultMap.get(key) instanceof List>) {
+ res.put(key, listNumberToInt((List>) resultMap.get(key)));
+ }
+ else if (resultMap.get(key) instanceof Map, ?>) {
+ res.put(key, mapNumberToInt((Map, ?>) resultMap.get(key)));
+ }
+ else {
+ res.put(key, resultMap.get(key));
+ }
+ }
+ return res;
+ }
+
+ /**
+ * 将 list 中的 可转化为 int 的数字转化为 int
+ *
+ * @param list list
+ * @return 修正后的list
+ */
+ public static List