+{
+ private static final long serialVersionUID = -1185015143654744140L;
+
+ /**
+ * SecureRandom 的单例
+ *
+ */
+ private static class Holder
+ {
+ static final SecureRandom numberGenerator;
+
+ static {
+ try {
+ numberGenerator = getSecureRandom();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /** 此UUID的最高64有效位 */
+ private final long mostSigBits;
+
+ /** 此UUID的最低64有效位 */
+ private final long leastSigBits;
+
+ /**
+ * 私有构造
+ *
+ * @param data 数据
+ */
+ private UUID(byte[] data)
+ {
+ long msb = 0;
+ long lsb = 0;
+ assert data.length == 16 : "data must be 16 bytes in length";
+ for (int i = 0; i < 8; i++)
+ {
+ msb = (msb << 8) | (data[i] & 0xff);
+ }
+ for (int i = 8; i < 16; i++)
+ {
+ lsb = (lsb << 8) | (data[i] & 0xff);
+ }
+ this.mostSigBits = msb;
+ this.leastSigBits = lsb;
+ }
+
+ /**
+ * 使用指定的数据构造新的 UUID。
+ *
+ * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位
+ * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位
+ */
+ public UUID(long mostSigBits, long leastSigBits)
+ {
+ this.mostSigBits = mostSigBits;
+ this.leastSigBits = leastSigBits;
+ }
+
+ /**
+ * 获取类型 4(伪随机生成的)UUID 的静态工厂。
+ *
+ * @return 随机生成的 {@code UUID}
+ */
+ public static UUID fastUUID()
+ {
+ return randomUUID(false);
+ }
+
+ /**
+ * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
+ *
+ * @return 随机生成的 {@code UUID}
+ */
+ public static UUID randomUUID()
+ {
+ return randomUUID(true);
+ }
+
+ /**
+ * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
+ *
+ * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能
+ * @return 随机生成的 {@code UUID}
+ */
+ public static UUID randomUUID(boolean isSecure)
+ {
+ final Random ng = isSecure ? Holder.numberGenerator : getRandom();
+
+ byte[] randomBytes = new byte[16];
+ ng.nextBytes(randomBytes);
+ randomBytes[6] &= 0x0f; /* clear version */
+ randomBytes[6] |= 0x40; /* set to version 4 */
+ randomBytes[8] &= 0x3f; /* clear variant */
+ randomBytes[8] |= 0x80; /* set to IETF variant */
+ return new UUID(randomBytes);
+ }
+
+ /**
+ * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。
+ *
+ * @param name 用于构造 UUID 的字节数组。
+ *
+ * @return 根据指定数组生成的 {@code UUID}
+ */
+ public static UUID nameUUIDFromBytes(byte[] name)
+ {
+ MessageDigest md;
+ try
+ {
+ md = MessageDigest.getInstance("MD5");
+ }
+ catch (NoSuchAlgorithmException nsae)
+ {
+ throw new InternalError("MD5 not supported");
+ }
+ byte[] md5Bytes = md.digest(name);
+ md5Bytes[6] &= 0x0f; /* clear version */
+ md5Bytes[6] |= 0x30; /* set to version 3 */
+ md5Bytes[8] &= 0x3f; /* clear variant */
+ md5Bytes[8] |= 0x80; /* set to IETF variant */
+ return new UUID(md5Bytes);
+ }
+
+ /**
+ * 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。
+ *
+ * @param name 指定 {@code UUID} 字符串
+ * @return 具有指定值的 {@code UUID}
+ * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常
+ *
+ */
+ public static UUID fromString(String name)
+ {
+ String[] components = name.split("-");
+ if (components.length != 5)
+ {
+ throw new IllegalArgumentException("Invalid UUID string: " + name);
+ }
+ for (int i = 0; i < 5; i++)
+ {
+ components[i] = "0x" + components[i];
+ }
+
+ long mostSigBits = Long.decode(components[0]).longValue();
+ mostSigBits <<= 16;
+ mostSigBits |= Long.decode(components[1]).longValue();
+ mostSigBits <<= 16;
+ mostSigBits |= Long.decode(components[2]).longValue();
+
+ long leastSigBits = Long.decode(components[3]).longValue();
+ leastSigBits <<= 48;
+ leastSigBits |= Long.decode(components[4]).longValue();
+
+ return new UUID(mostSigBits, leastSigBits);
+ }
+
+ /**
+ * 返回此 UUID 的 128 位值中的最低有效 64 位。
+ *
+ * @return 此 UUID 的 128 位值中的最低有效 64 位。
+ */
+ public long getLeastSignificantBits()
+ {
+ return leastSigBits;
+ }
+
+ /**
+ * 返回此 UUID 的 128 位值中的最高有效 64 位。
+ *
+ * @return 此 UUID 的 128 位值中最高有效 64 位。
+ */
+ public long getMostSignificantBits()
+ {
+ return mostSigBits;
+ }
+
+ /**
+ * 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。
+ *
+ * 版本号具有以下含意:
+ *
+ * - 1 基于时间的 UUID
+ *
- 2 DCE 安全 UUID
+ *
- 3 基于名称的 UUID
+ *
- 4 随机生成的 UUID
+ *
+ *
+ * @return 此 {@code UUID} 的版本号
+ */
+ public int version()
+ {
+ // Version is bits masked by 0x000000000000F000 in MS long
+ return (int) ((mostSigBits >> 12) & 0x0f);
+ }
+
+ /**
+ * 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。
+ *
+ * 变体号具有以下含意:
+ *
+ * - 0 为 NCS 向后兼容保留
+ *
- 2 IETF RFC 4122(Leach-Salz), 用于此类
+ *
- 6 保留,微软向后兼容
+ *
- 7 保留供以后定义使用
+ *
+ *
+ * @return 此 {@code UUID} 相关联的变体号
+ */
+ public int variant()
+ {
+ // This field is composed of a varying number of bits.
+ // 0 - - Reserved for NCS backward compatibility
+ // 1 0 - The IETF aka Leach-Salz variant (used by this class)
+ // 1 1 0 Reserved, Microsoft backward compatibility
+ // 1 1 1 Reserved for future definition.
+ return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63));
+ }
+
+ /**
+ * 与此 UUID 相关联的时间戳值。
+ *
+ *
+ * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。
+ * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。
+ *
+ *
+ * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
+ *
+ * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。
+ */
+ public long timestamp() throws UnsupportedOperationException
+ {
+ checkTimeBase();
+ return (mostSigBits & 0x0FFFL) << 48//
+ | ((mostSigBits >> 16) & 0x0FFFFL) << 32//
+ | mostSigBits >>> 32;
+ }
+
+ /**
+ * 与此 UUID 相关联的时钟序列值。
+ *
+ *
+ * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。
+ *
+ * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出
+ * UnsupportedOperationException。
+ *
+ * @return 此 {@code UUID} 的时钟序列
+ *
+ * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
+ */
+ public int clockSequence() throws UnsupportedOperationException
+ {
+ checkTimeBase();
+ return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
+ }
+
+ /**
+ * 与此 UUID 相关的节点值。
+ *
+ *
+ * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。
+ *
+ * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
+ *
+ * @return 此 {@code UUID} 的节点值
+ *
+ * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
+ */
+ public long node() throws UnsupportedOperationException
+ {
+ checkTimeBase();
+ return leastSigBits & 0x0000FFFFFFFFFFFFL;
+ }
+
+ /**
+ * 返回此{@code UUID} 的字符串表现形式。
+ *
+ *
+ * UUID 的字符串表示形式由此 BNF 描述:
+ *
+ *
+ * {@code
+ * UUID = ----
+ * time_low = 4*
+ * time_mid = 2*
+ * time_high_and_version = 2*
+ * variant_and_sequence = 2*
+ * node = 6*
+ * hexOctet =
+ * hexDigit = [0-9a-fA-F]
+ * }
+ *
+ *
+ *
+ *
+ * @return 此{@code UUID} 的字符串表现形式
+ * @see #toString(boolean)
+ */
+ @Override
+ public String toString()
+ {
+ return toString(false);
+ }
+
+ /**
+ * 返回此{@code UUID} 的字符串表现形式。
+ *
+ *
+ * UUID 的字符串表示形式由此 BNF 描述:
+ *
+ *
+ * {@code
+ * UUID = ----
+ * time_low = 4*
+ * time_mid = 2*
+ * time_high_and_version = 2*
+ * variant_and_sequence = 2*
+ * node = 6*
+ * hexOctet =
+ * hexDigit = [0-9a-fA-F]
+ * }
+ *
+ *
+ *
+ *
+ * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串
+ * @return 此{@code UUID} 的字符串表现形式
+ */
+ public String toString(boolean isSimple)
+ {
+ final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
+ // time_low
+ builder.append(digits(mostSigBits >> 32, 8));
+ if (!isSimple)
+ {
+ builder.append('-');
+ }
+ // time_mid
+ builder.append(digits(mostSigBits >> 16, 4));
+ if (!isSimple)
+ {
+ builder.append('-');
+ }
+ // time_high_and_version
+ builder.append(digits(mostSigBits, 4));
+ if (!isSimple)
+ {
+ builder.append('-');
+ }
+ // variant_and_sequence
+ builder.append(digits(leastSigBits >> 48, 4));
+ if (!isSimple)
+ {
+ builder.append('-');
+ }
+ // node
+ builder.append(digits(leastSigBits, 12));
+
+ return builder.toString();
+ }
+
+ /**
+ * 返回此 UUID 的哈希码。
+ *
+ * @return UUID 的哈希码值。
+ */
+ @Override
+ public int hashCode()
+ {
+ long hilo = mostSigBits ^ leastSigBits;
+ return ((int) (hilo >> 32)) ^ (int) hilo;
+ }
+
+ /**
+ * 将此对象与指定对象比较。
+ *
+ * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。
+ *
+ * @param obj 要与之比较的对象
+ *
+ * @return 如果对象相同,则返回 {@code true};否则返回 {@code false}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if ((null == obj) || (obj.getClass() != UUID.class))
+ {
+ return false;
+ }
+ UUID id = (UUID) obj;
+ return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
+ }
+
+ // Comparison Operations
+
+ /**
+ * 将此 UUID 与指定的 UUID 比较。
+ *
+ *
+ * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。
+ *
+ * @param val 与此 UUID 比较的 UUID
+ *
+ * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。
+ *
+ */
+ @Override
+ public int compareTo(UUID val)
+ {
+ // The ordering is intentionally set up so that the UUIDs
+ // can simply be numerically compared as two numbers
+ return (this.mostSigBits < val.mostSigBits ? -1 : //
+ (this.mostSigBits > val.mostSigBits ? 1 : //
+ (this.leastSigBits < val.leastSigBits ? -1 : //
+ (this.leastSigBits > val.leastSigBits ? 1 : //
+ 0))));
+ }
+
+ // -------------------------------------------------------------------------------------------------------------------
+ // Private method start
+ /**
+ * 返回指定数字对应的hex值
+ *
+ * @param val 值
+ * @param digits 位
+ * @return 值
+ */
+ private static String digits(long val, int digits)
+ {
+ long hi = 1L << (digits * 4);
+ return Long.toHexString(hi | (val & (hi - 1))).substring(1);
+ }
+
+ /**
+ * 检查是否为time-based版本UUID
+ */
+ private void checkTimeBase()
+ {
+ if (version() != 1)
+ {
+ throw new UnsupportedOperationException("Not a time-based UUID");
+ }
+ }
+
+ /**
+ * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG)
+ *
+ * @return {@link SecureRandom}
+ */
+ public static SecureRandom getSecureRandom() throws Exception {
+ try
+ {
+ return SecureRandom.getInstance("SHA1PRNG");
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ throw new Exception(e);
+ }
+ }
+
+ /**
+ * 获取随机数生成器对象
+ * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。
+ *
+ * @return {@link ThreadLocalRandom}
+ */
+ public static ThreadLocalRandom getRandom()
+ {
+ return ThreadLocalRandom.current();
+ }
+}
diff --git a/sys-api/src/main/java/com/qihang/sys/api/utils/http/HttpHelper.java b/sys-api/src/main/java/com/qihang/sys/api/utils/http/HttpHelper.java
new file mode 100644
index 00000000..bcd746d5
--- /dev/null
+++ b/sys-api/src/main/java/com/qihang/sys/api/utils/http/HttpHelper.java
@@ -0,0 +1,56 @@
+package com.qihang.sys.api.utils.http;
+
+import jakarta.servlet.ServletRequest;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * 通用http工具封装
+ *
+ * @author qihang
+ */
+public class HttpHelper
+{
+ private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class);
+
+ public static String getBodyString(ServletRequest request)
+ {
+ StringBuilder sb = new StringBuilder();
+ BufferedReader reader = null;
+ try (InputStream inputStream = request.getInputStream())
+ {
+ reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
+ String line = "";
+ while ((line = reader.readLine()) != null)
+ {
+ sb.append(line);
+ }
+ }
+ catch (IOException e)
+ {
+ LOGGER.warn("getBodyString出现问题!");
+ }
+ finally
+ {
+ if (reader != null)
+ {
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ LOGGER.error(ExceptionUtils.getMessage(e));
+ }
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/sys-api/src/main/java/com/qihang/sys/api/utils/http/HttpUtils.java b/sys-api/src/main/java/com/qihang/sys/api/utils/http/HttpUtils.java
new file mode 100644
index 00000000..a31935b3
--- /dev/null
+++ b/sys-api/src/main/java/com/qihang/sys/api/utils/http/HttpUtils.java
@@ -0,0 +1,266 @@
+//package com.qihang.oms.api.utils.http;
+//
+//import com.qihang.oms.api.constant.Constants;
+//import com.qihang.oms.api.utils.StringUtils;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//
+//import javax.net.ssl.*;
+//import java.io.*;
+//import java.net.ConnectException;
+//import java.net.SocketTimeoutException;
+//import java.net.URL;
+//import java.net.URLConnection;
+//import java.nio.charset.StandardCharsets;
+//import java.security.cert.X509Certificate;
+//
+///**
+// * 通用http发送方法
+// *
+// * @author qihang
+// */
+//public class HttpUtils
+//{
+// private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
+//
+// /**
+// * 向指定 URL 发送GET方法的请求
+// *
+// * @param url 发送请求的 URL
+// * @return 所代表远程资源的响应结果
+// */
+// public static String sendGet(String url)
+// {
+// return sendGet(url, StringUtils.EMPTY);
+// }
+//
+// /**
+// * 向指定 URL 发送GET方法的请求
+// *
+// * @param url 发送请求的 URL
+// * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
+// * @return 所代表远程资源的响应结果
+// */
+// public static String sendGet(String url, String param)
+// {
+// return sendGet(url, param, Constants.UTF8);
+// }
+//
+// /**
+// * 向指定 URL 发送GET方法的请求
+// *
+// * @param url 发送请求的 URL
+// * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
+// * @param contentType 编码类型
+// * @return 所代表远程资源的响应结果
+// */
+// public static String sendGet(String url, String param, String contentType)
+// {
+// StringBuilder result = new StringBuilder();
+// BufferedReader in = null;
+// try
+// {
+// String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
+// log.info("sendGet - {}", urlNameString);
+// URL realUrl = new URL(urlNameString);
+// URLConnection connection = realUrl.openConnection();
+// connection.setRequestProperty("accept", "*/*");
+// connection.setRequestProperty("connection", "Keep-Alive");
+// connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+// connection.connect();
+// in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
+// String line;
+// while ((line = in.readLine()) != null)
+// {
+// result.append(line);
+// }
+// log.info("recv - {}", result);
+// }
+// catch (ConnectException e)
+// {
+// log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
+// }
+// catch (SocketTimeoutException e)
+// {
+// log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
+// }
+// catch (IOException e)
+// {
+// log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
+// }
+// catch (Exception e)
+// {
+// log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
+// }
+// finally
+// {
+// try
+// {
+// if (in != null)
+// {
+// in.close();
+// }
+// }
+// catch (Exception ex)
+// {
+// log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
+// }
+// }
+// return result.toString();
+// }
+//
+// /**
+// * 向指定 URL 发送POST方法的请求
+// *
+// * @param url 发送请求的 URL
+// * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
+// * @return 所代表远程资源的响应结果
+// */
+// public static String sendPost(String url, String param)
+// {
+// PrintWriter out = null;
+// BufferedReader in = null;
+// StringBuilder result = new StringBuilder();
+// try
+// {
+// log.info("sendPost - {}", url);
+// URL realUrl = new URL(url);
+// URLConnection conn = realUrl.openConnection();
+// conn.setRequestProperty("accept", "*/*");
+// conn.setRequestProperty("connection", "Keep-Alive");
+// conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+// conn.setRequestProperty("Accept-Charset", "utf-8");
+// conn.setRequestProperty("contentType", "utf-8");
+// conn.setDoOutput(true);
+// conn.setDoInput(true);
+// out = new PrintWriter(conn.getOutputStream());
+// out.print(param);
+// out.flush();
+// in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
+// String line;
+// while ((line = in.readLine()) != null)
+// {
+// result.append(line);
+// }
+// log.info("recv - {}", result);
+// }
+// catch (ConnectException e)
+// {
+// log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
+// }
+// catch (SocketTimeoutException e)
+// {
+// log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
+// }
+// catch (IOException e)
+// {
+// log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
+// }
+// catch (Exception e)
+// {
+// log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
+// }
+// finally
+// {
+// try
+// {
+// if (out != null)
+// {
+// out.close();
+// }
+// if (in != null)
+// {
+// in.close();
+// }
+// }
+// catch (IOException ex)
+// {
+// log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
+// }
+// }
+// return result.toString();
+// }
+//
+// public static String sendSSLPost(String url, String param)
+// {
+// StringBuilder result = new StringBuilder();
+// String urlNameString = url + "?" + param;
+// try
+// {
+// log.info("sendSSLPost - {}", urlNameString);
+// SSLContext sc = SSLContext.getInstance("SSL");
+// sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
+// URL console = new URL(urlNameString);
+// HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
+// conn.setRequestProperty("accept", "*/*");
+// conn.setRequestProperty("connection", "Keep-Alive");
+// conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+// conn.setRequestProperty("Accept-Charset", "utf-8");
+// conn.setRequestProperty("contentType", "utf-8");
+// conn.setDoOutput(true);
+// conn.setDoInput(true);
+//
+// conn.setSSLSocketFactory(sc.getSocketFactory());
+// conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
+// conn.connect();
+// InputStream is = conn.getInputStream();
+// BufferedReader br = new BufferedReader(new InputStreamReader(is));
+// String ret = "";
+// while ((ret = br.readLine()) != null)
+// {
+// if (ret != null && !"".equals(ret.trim()))
+// {
+// result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8));
+// }
+// }
+// log.info("recv - {}", result);
+// conn.disconnect();
+// br.close();
+// }
+// catch (ConnectException e)
+// {
+// log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e);
+// }
+// catch (SocketTimeoutException e)
+// {
+// log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e);
+// }
+// catch (IOException e)
+// {
+// log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e);
+// }
+// catch (Exception e)
+// {
+// log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e);
+// }
+// return result.toString();
+// }
+//
+// private static class TrustAnyTrustManager implements X509TrustManager
+// {
+// @Override
+// public void checkClientTrusted(X509Certificate[] chain, String authType)
+// {
+// }
+//
+// @Override
+// public void checkServerTrusted(X509Certificate[] chain, String authType)
+// {
+// }
+//
+// @Override
+// public X509Certificate[] getAcceptedIssuers()
+// {
+// return new X509Certificate[] {};
+// }
+// }
+//
+// private static class TrustAnyHostnameVerifier implements HostnameVerifier
+// {
+// @Override
+// public boolean verify(String hostname, SSLSession session)
+// {
+// return true;
+// }
+// }
+//}
\ No newline at end of file
diff --git a/sys-api/src/main/java/com/qihang/sys/api/utils/ip/AddressUtils.java b/sys-api/src/main/java/com/qihang/sys/api/utils/ip/AddressUtils.java
new file mode 100644
index 00000000..7eceb92b
--- /dev/null
+++ b/sys-api/src/main/java/com/qihang/sys/api/utils/ip/AddressUtils.java
@@ -0,0 +1,54 @@
+//package com.qihang.oms.api.utils.ip;
+//
+//import com.alibaba.fastjson2.JSON;
+//import com.alibaba.fastjson2.JSONObject;
+//import com.qihang.oms.api.constant.Constants;
+//import com.qihang.oms.api.utils.http.HttpUtils;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.util.StringUtils;
+//
+///**
+// * 获取地址类
+// *
+// * @author qihang
+// */
+//public class AddressUtils
+//{
+// private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
+//
+// // IP地址查询
+// public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
+//
+// // 未知地址
+// public static final String UNKNOWN = "XX XX";
+//
+// public static String getRealAddressByIP(String ip)
+// {
+// // 内网不查询
+// if (IpUtils.internalIp(ip))
+// {
+// return "内网IP";
+// }
+//
+// try
+// {
+// String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK);
+// if (StringUtils.isEmpty(rspStr))
+// {
+// log.error("获取地理位置异常 {}", ip);
+// return UNKNOWN;
+// }
+// JSONObject obj = JSON.parseObject(rspStr);
+// String region = obj.getString("pro");
+// String city = obj.getString("city");
+// return String.format("%s %s", region, city);
+// }
+// catch (Exception e)
+// {
+// log.error("获取地理位置异常 {}", ip);
+// }
+//
+// return UNKNOWN;
+// }
+//}
diff --git a/sys-api/src/main/java/com/qihang/sys/api/utils/ip/IpUtils.java b/sys-api/src/main/java/com/qihang/sys/api/utils/ip/IpUtils.java
new file mode 100644
index 00000000..dc6afce1
--- /dev/null
+++ b/sys-api/src/main/java/com/qihang/sys/api/utils/ip/IpUtils.java
@@ -0,0 +1,384 @@
+//package com.qihang.oms.api.utils.ip;
+//
+//
+//import com.qihang.oms.api.utils.ServletUtils;
+//import com.qihang.oms.api.utils.StringUtils;
+//import jakarta.servlet.http.HttpServletRequest;
+//
+//import java.net.InetAddress;
+//import java.net.UnknownHostException;
+//
+///**
+// * 获取IP方法
+// *
+// * @author qihang
+// */
+//public class IpUtils
+//{
+// public final static String REGX_0_255 = "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)";
+// // 匹配 ip
+// public final static String REGX_IP = "((" + REGX_0_255 + "\\.){3}" + REGX_0_255 + ")";
+// public final static String REGX_IP_WILDCARD = "(((\\*\\.){3}\\*)|(" + REGX_0_255 + "(\\.\\*){3})|(" + REGX_0_255 + "\\." + REGX_0_255 + ")(\\.\\*){2}" + "|((" + REGX_0_255 + "\\.){3}\\*))";
+// // 匹配网段
+// public final static String REGX_IP_SEG = "(" + REGX_IP + "\\-" + REGX_IP + ")";
+//
+// /**
+// * 获取客户端IP
+// *
+// * @return IP地址
+// */
+// public static String getIpAddr()
+// {
+// return getIpAddr(ServletUtils.getRequest());
+// }
+//
+// /**
+// * 获取客户端IP
+// *
+// * @param request 请求对象
+// * @return IP地址
+// */
+// public static String getIpAddr(HttpServletRequest request)
+// {
+// if (request == null)
+// {
+// return "unknown";
+// }
+// String ip = request.getHeader("x-forwarded-for");
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
+// {
+// ip = request.getHeader("Proxy-Client-IP");
+// }
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
+// {
+// ip = request.getHeader("X-Forwarded-For");
+// }
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
+// {
+// ip = request.getHeader("WL-Proxy-Client-IP");
+// }
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
+// {
+// ip = request.getHeader("X-Real-IP");
+// }
+//
+// if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
+// {
+// ip = request.getRemoteAddr();
+// }
+//
+// return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : getMultistageReverseProxyIp(ip);
+// }
+//
+// /**
+// * 检查是否为内部IP地址
+// *
+// * @param ip IP地址
+// * @return 结果
+// */
+// public static boolean internalIp(String ip)
+// {
+// byte[] addr = textToNumericFormatV4(ip);
+// return internalIp(addr) || "127.0.0.1".equals(ip);
+// }
+//
+// /**
+// * 检查是否为内部IP地址
+// *
+// * @param addr byte地址
+// * @return 结果
+// */
+// private static boolean internalIp(byte[] addr)
+// {
+// if (StringUtils.isNull(addr) || addr.length < 2)
+// {
+// return true;
+// }
+// final byte b0 = addr[0];
+// final byte b1 = addr[1];
+// // 10.x.x.x/8
+// final byte SECTION_1 = 0x0A;
+// // 172.16.x.x/12
+// final byte SECTION_2 = (byte) 0xAC;
+// final byte SECTION_3 = (byte) 0x10;
+// final byte SECTION_4 = (byte) 0x1F;
+// // 192.168.x.x/16
+// final byte SECTION_5 = (byte) 0xC0;
+// final byte SECTION_6 = (byte) 0xA8;
+// switch (b0)
+// {
+// case SECTION_1:
+// return true;
+// case SECTION_2:
+// if (b1 >= SECTION_3 && b1 <= SECTION_4)
+// {
+// return true;
+// }
+// case SECTION_5:
+// switch (b1)
+// {
+// case SECTION_6:
+// return true;
+// }
+// default:
+// return false;
+// }
+// }
+//
+// /**
+// * 将IPv4地址转换成字节
+// *
+// * @param text IPv4地址
+// * @return byte 字节
+// */
+// public static byte[] textToNumericFormatV4(String text)
+// {
+// if (text.length() == 0)
+// {
+// return null;
+// }
+//
+// byte[] bytes = new byte[4];
+// String[] elements = text.split("\\.", -1);
+// try
+// {
+// long l;
+// int i;
+// switch (elements.length)
+// {
+// case 1:
+// l = Long.parseLong(elements[0]);
+// if ((l < 0L) || (l > 4294967295L))
+// {
+// return null;
+// }
+// bytes[0] = (byte) (int) (l >> 24 & 0xFF);
+// bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
+// bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
+// bytes[3] = (byte) (int) (l & 0xFF);
+// break;
+// case 2:
+// l = Integer.parseInt(elements[0]);
+// if ((l < 0L) || (l > 255L))
+// {
+// return null;
+// }
+// bytes[0] = (byte) (int) (l & 0xFF);
+// l = Integer.parseInt(elements[1]);
+// if ((l < 0L) || (l > 16777215L))
+// {
+// return null;
+// }
+// bytes[1] = (byte) (int) (l >> 16 & 0xFF);
+// bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
+// bytes[3] = (byte) (int) (l & 0xFF);
+// break;
+// case 3:
+// for (i = 0; i < 2; ++i)
+// {
+// l = Integer.parseInt(elements[i]);
+// if ((l < 0L) || (l > 255L))
+// {
+// return null;
+// }
+// bytes[i] = (byte) (int) (l & 0xFF);
+// }
+// l = Integer.parseInt(elements[2]);
+// if ((l < 0L) || (l > 65535L))
+// {
+// return null;
+// }
+// bytes[2] = (byte) (int) (l >> 8 & 0xFF);
+// bytes[3] = (byte) (int) (l & 0xFF);
+// break;
+// case 4:
+// for (i = 0; i < 4; ++i)
+// {
+// l = Integer.parseInt(elements[i]);
+// if ((l < 0L) || (l > 255L))
+// {
+// return null;
+// }
+// bytes[i] = (byte) (int) (l & 0xFF);
+// }
+// break;
+// default:
+// return null;
+// }
+// }
+// catch (NumberFormatException e)
+// {
+// return null;
+// }
+// return bytes;
+// }
+//
+// /**
+// * 获取IP地址
+// *
+// * @return 本地IP地址
+// */
+// public static String getHostIp()
+// {
+// try
+// {
+// return InetAddress.getLocalHost().getHostAddress();
+// }
+// catch (UnknownHostException e)
+// {
+// }
+// return "127.0.0.1";
+// }
+//
+// /**
+// * 获取主机名
+// *
+// * @return 本地主机名
+// */
+// public static String getHostName()
+// {
+// try
+// {
+// return InetAddress.getLocalHost().getHostName();
+// }
+// catch (UnknownHostException e)
+// {
+// }
+// return "未知";
+// }
+//
+// /**
+// * 从多级反向代理中获得第一个非unknown IP地址
+// *
+// * @param ip 获得的IP地址
+// * @return 第一个非unknown IP地址
+// */
+// public static String getMultistageReverseProxyIp(String ip)
+// {
+// // 多级反向代理检测
+// if (ip != null && ip.indexOf(",") > 0)
+// {
+// final String[] ips = ip.trim().split(",");
+// for (String subIp : ips)
+// {
+// if (false == isUnknown(subIp))
+// {
+// ip = subIp;
+// break;
+// }
+// }
+// }
+// return StringUtils.substring(ip, 0, 255);
+// }
+//
+// /**
+// * 检测给定字符串是否为未知,多用于检测HTTP请求相关
+// *
+// * @param checkString 被检测的字符串
+// * @return 是否未知
+// */
+// public static boolean isUnknown(String checkString)
+// {
+// return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
+// }
+//
+// /**
+// * 是否为IP
+// */
+// public static boolean isIP(String ip)
+// {
+// return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP);
+// }
+//
+// /**
+// * 是否为IP,或 *为间隔的通配符地址
+// */
+// public static boolean isIpWildCard(String ip)
+// {
+// return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP_WILDCARD);
+// }
+//
+// /**
+// * 检测参数是否在ip通配符里
+// */
+// public static boolean ipIsInWildCardNoCheck(String ipWildCard, String ip)
+// {
+// String[] s1 = ipWildCard.split("\\.");
+// String[] s2 = ip.split("\\.");
+// boolean isMatchedSeg = true;
+// for (int i = 0; i < s1.length && !s1[i].equals("*"); i++)
+// {
+// if (!s1[i].equals(s2[i]))
+// {
+// isMatchedSeg = false;
+// break;
+// }
+// }
+// return isMatchedSeg;
+// }
+//
+// /**
+// * 是否为特定格式如:“10.10.10.1-10.10.10.99”的ip段字符串
+// */
+// public static boolean isIPSegment(String ipSeg)
+// {
+// return StringUtils.isNotBlank(ipSeg) && ipSeg.matches(REGX_IP_SEG);
+// }
+//
+// /**
+// * 判断ip是否在指定网段中
+// */
+// public static boolean ipIsInNetNoCheck(String iparea, String ip)
+// {
+// int idx = iparea.indexOf('-');
+// String[] sips = iparea.substring(0, idx).split("\\.");
+// String[] sipe = iparea.substring(idx + 1).split("\\.");
+// String[] sipt = ip.split("\\.");
+// long ips = 0L, ipe = 0L, ipt = 0L;
+// for (int i = 0; i < 4; ++i)
+// {
+// ips = ips << 8 | Integer.parseInt(sips[i]);
+// ipe = ipe << 8 | Integer.parseInt(sipe[i]);
+// ipt = ipt << 8 | Integer.parseInt(sipt[i]);
+// }
+// if (ips > ipe)
+// {
+// long t = ips;
+// ips = ipe;
+// ipe = t;
+// }
+// return ips <= ipt && ipt <= ipe;
+// }
+//
+// /**
+// * 校验ip是否符合过滤串规则
+// *
+// * @param filter 过滤IP列表,支持后缀'*'通配,支持网段如:`10.10.10.1-10.10.10.99`
+// * @param ip 校验IP地址
+// * @return boolean 结果
+// */
+// public static boolean isMatchedIp(String filter, String ip)
+// {
+// if (StringUtils.isEmpty(filter) || StringUtils.isEmpty(ip))
+// {
+// return false;
+// }
+// String[] ips = filter.split(";");
+// for (String iStr : ips)
+// {
+// if (isIP(iStr) && iStr.equals(ip))
+// {
+// return true;
+// }
+// else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip))
+// {
+// return true;
+// }
+// else if (isIPSegment(iStr) && ipIsInNetNoCheck(iStr, ip))
+// {
+// return true;
+// }
+// }
+// return false;
+// }
+//}
\ No newline at end of file
diff --git a/oms-api/src/main/resources/application.yaml b/sys-api/src/main/resources/application.yaml
similarity index 87%
rename from oms-api/src/main/resources/application.yaml
rename to sys-api/src/main/resources/application.yaml
index 8d38235b..f9eb9203 100644
--- a/oms-api/src/main/resources/application.yaml
+++ b/sys-api/src/main/resources/application.yaml
@@ -1,6 +1,6 @@
mybatis-plus:
mapper-locations: classpath*:mapper/**/*Mapper.xml
- type-aliases-package: com.qihang.oms.api.domain
+ type-aliases-package: com.qihang.sys.api.domain;com.qihang.security.entity;
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 开启sql日志
#mybatis:
@@ -25,7 +25,7 @@ spring:
import:
- nacos:qihang-oms.yaml?refresh=true
application:
- name: oms-api
+ name: sys-api
server:
port: 8082
diff --git a/oms-api/src/main/resources/logback.xml b/sys-api/src/main/resources/logback.xml
similarity index 100%
rename from oms-api/src/main/resources/logback.xml
rename to sys-api/src/main/resources/logback.xml
diff --git a/oms-api/src/main/resources/mapper/system/SysMenuMapper.xml b/sys-api/src/main/resources/mapper/system/SysMenuMapper.xml
similarity index 99%
rename from oms-api/src/main/resources/mapper/system/SysMenuMapper.xml
rename to sys-api/src/main/resources/mapper/system/SysMenuMapper.xml
index 441e7b67..8b1d2a7b 100644
--- a/oms-api/src/main/resources/mapper/system/SysMenuMapper.xml
+++ b/sys-api/src/main/resources/mapper/system/SysMenuMapper.xml
@@ -2,7 +2,7 @@
-
+