From 04f5e7e68a53df3347a8a50d6567be1809f86c6f Mon Sep 17 00:00:00 2001 From: hiparker Date: Wed, 19 May 2021 17:53:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../opsli/common/utils/ListDistinctUtil.java | 9 +- .../opsli/common/utils/OutputStreamUtil.java | 9 +- .../org/opsli/common/utils/PackageUtil.java | 2 + .../java/org/opsli/common/utils/Props.java | 84 ++++++++++++------- .../opsli/common/utils/RateLimiterUtil.java | 29 +++---- .../org/opsli/common/utils/WrapperUtil.java | 11 +-- .../java/org/opsli/common/utils/ZipUtils.java | 12 +-- .../aspect/ApiCryptoAsymmetricAop.java | 3 +- .../java/org/opsli/core/persistence/Page.java | 2 +- 9 files changed, 92 insertions(+), 69 deletions(-) diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/ListDistinctUtil.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/ListDistinctUtil.java index c01ecdd..d2d8708 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/ListDistinctUtil.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/ListDistinctUtil.java @@ -11,11 +11,10 @@ import java.util.TreeSet; import java.util.stream.Collectors; /** - * @BelongsProject: think-bboss-parent - * @BelongsPackage: com.think.bboss.common.utils - * @Author: Parker - * @CreateTime: 2021-01-05 14:26 - * @Description: List 去重 + * List 去重 + * + * @author Parker + * @date 2021-01-05 14:26 */ @Slf4j public final class ListDistinctUtil { diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/OutputStreamUtil.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/OutputStreamUtil.java index c820483..a7d1511 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/OutputStreamUtil.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/OutputStreamUtil.java @@ -12,11 +12,10 @@ import java.io.PrintWriter; import java.nio.charset.StandardCharsets; /** - * @BelongsProject: think-bboss-parent - * @BelongsPackage: com.think.bboss.common.utils - * @Author: Parker - * @CreateTime: 2021-01-05 14:26 - * @Description: OutputStream 处理 + * OutputStream 处理 + * + * @author Parker + * @date 2021-01-05 14:26 */ @Slf4j public final class OutputStreamUtil { diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/PackageUtil.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/PackageUtil.java index fccddd7..b0c52c3 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/PackageUtil.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/PackageUtil.java @@ -24,7 +24,9 @@ import java.util.jar.JarInputStream; /** * 名称空间实用工具 + * * @author Parker + * @date 2020-09-19 23:21 */ public final class PackageUtil { /** diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/Props.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/Props.java index 134e406..b583649 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/Props.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/Props.java @@ -44,10 +44,10 @@ import java.util.concurrent.ConcurrentHashMap; * 1.8.3 * * - *使用方法 - *eg: - * opsli: - * config: + * 使用方法 + * eg: + * opsli: + * config: * key: value * list: * - 张三 @@ -58,15 +58,18 @@ import java.util.concurrent.ConcurrentHashMap; * - name: 李四map * age: 121 * - *支持获取指定层级之后的数据,如"opsli.config" : new ConfigBean().prefix("opsli.config").getObj() + * 支持获取指定层级之后的数据,如"opsli.config" : new ConfigBean().prefix("opsli.config").getObj() * - *支持获取list中指定数据,如"opsli.config.list.1" : new ConfigBean().prefix("opsli.config.list.1").getObj() + * 支持获取list中指定数据,如"opsli.config.list.1" : new ConfigBean().prefix("opsli.config.list.1").getObj() * - *支持获取list中指定数据之后的数据,如"opsli.config.map.1.name" :new ConfigBean().prefix("opsli.config.list.1").getString() + * 支持获取list中指定数据之后的数据,如"opsli.config.map.1.name" :new ConfigBean().prefix("opsli.config.list.1").getString() * * * 针对 hutool 工具类 Props不是很有好, 重新写了自定义Yaml工具类 + * + * * @author Parker + * @date 2021-01-05 14:26 */ @Slf4j public class Props { @@ -117,7 +120,7 @@ public class Props { /** * 获得 Obj对象 - * @return + * @return Object */ public Object getObj(String key){ return this.getObj(key, null); @@ -125,7 +128,7 @@ public class Props { /** * 获得 Obj对象 - * @return + * @return Object */ public Object getObj(String key, Object def){ if(key == null || "".equals(key) ){ @@ -146,7 +149,7 @@ public class Props { /** * 获得 字符串类型对象 - * @return + * @return String */ public String getStr(String key){ return this.getStr(key, null); @@ -154,7 +157,9 @@ public class Props { /** * 获得 字符串类型对象 - * @return + * @param key 主键 + * @param def 默认 + * @return String */ public String getStr(String key, String def){ if(key == null || "".equals(key) ){ @@ -171,7 +176,8 @@ public class Props { /** * 获得 Int 类型对象 - * @return + * @param key 主键 + * @return Integer */ public Integer getInt(String key){ return this.getInt(key, null); @@ -179,7 +185,9 @@ public class Props { /** * 获得 Int 类型对象 - * @return + * @param key 主键 + * @param def 默认 + * @return Integer */ public Integer getInt(String key, Integer def){ if(key == null || "".equals(key) ){ @@ -196,7 +204,8 @@ public class Props { /** * 获得 Long 类型对象 - * @return + * @param key 主键 + * @return Long */ public Long getLong(String key){ return this.getLong(key, null); @@ -204,7 +213,9 @@ public class Props { /** * 获得 Long 类型对象 - * @return + * @param key 主键 + * @param def 默认 + * @return Long */ public Long getLong(String key, Long def){ if(key == null || "".equals(key) ){ @@ -222,7 +233,8 @@ public class Props { /** * 获得 Double 类型对象 - * @return + * @param key 主键 + * @return Double */ public Double getDouble(String key){ return this.getDouble(key, null); @@ -230,7 +242,9 @@ public class Props { /** * 获得 Double 类型对象 - * @return + * @param key 主键 + * @param def 默认 + * @return Double */ public Double getDouble(String key, Double def){ if(key == null || "".equals(key) ){ @@ -249,7 +263,8 @@ public class Props { /** * 获得 Float 类型对象 - * @return + * @param key 主键 + * @return Float */ public Float getFloat(String key){ return this.getFloat(key, null); @@ -257,7 +272,9 @@ public class Props { /** * 获得 Float 类型对象 - * @return + * @param key 主键 + * @param def 默认 + * @return Float */ public Float getFloat(String key, Float def){ if(key == null || "".equals(key) ){ @@ -275,7 +292,8 @@ public class Props { /** * 获得 Char 类型对象 - * @return + * @param key 主键 + * @return Character */ public Character getChar(String key){ return this.getChar(key, null); @@ -283,7 +301,9 @@ public class Props { /** * 获得 Char 类型对象 - * @return + * @param key 主键 + * @param def 默认 + * @return Character */ public Character getChar(String key, Character def){ if(key == null || "".equals(key) ){ @@ -300,7 +320,8 @@ public class Props { /** * 获得 布尔类型对象 - * @return + * @param key 主键 + * @return Boolean */ public Boolean getBool(String key){ return this.getBool(key, null); @@ -308,7 +329,9 @@ public class Props { /** * 获得 布尔类型对象 - * @return + * @param key 主键 + * @param def 默认 + * @return Boolean */ public Boolean getBool(String key, Boolean def){ if(key == null || "".equals(key) ){ @@ -324,16 +347,19 @@ public class Props { } /** - * 获得 布尔类型对象 - * @return + * 获得 List对象 + * @param key 主键 + * @return List */ public List getList(String key){ return this.getList(key, null); } /** - * 获得 布尔类型对象 - * @return + * 获得 List对象 + * @param key 主键 + * @param def 默认 + * @return List */ public List getList(String key, List def){ if(key == null || "".equals(key) ){ @@ -354,8 +380,8 @@ public class Props { /** * 获得对象 - * @param keys - * @return + * @param keys 主键数组 + * @return Object */ private Object getObject(String[] keys){ // 循环查找 diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/RateLimiterUtil.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/RateLimiterUtil.java index 6d4cdc5..65f5a47 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/RateLimiterUtil.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/RateLimiterUtil.java @@ -15,11 +15,10 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; /** - * @BelongsProject: think-bboss-parent - * @BelongsPackage: com.think.bboss.common.utils - * @Author: Parker - * @CreateTime: 2021-01-05 16:06 - * @Description: 单机限流 + * 单机限流 + * + * @author Parker + * @date 2021-01-05 16:06 */ @Slf4j public final class RateLimiterUtil { @@ -44,7 +43,7 @@ public final class RateLimiterUtil { /** * 删除IP - * @param ip + * @param ip IP */ public static void removeIp(String ip) { LFU_CACHE.invalidate(ip); @@ -52,8 +51,8 @@ public final class RateLimiterUtil { /** * 方法进入 - * @param request - * @return + * @param request request + * @return boolean */ public static boolean enter(HttpServletRequest request) { // 获得IP @@ -65,8 +64,8 @@ public final class RateLimiterUtil { /** * 方法进入 - * @param request - * @return + * @param request request + * @return boolean */ public static boolean enter(HttpServletRequest request, Double dfQps) { // 获得IP @@ -79,7 +78,7 @@ public final class RateLimiterUtil { /** * 方法进入 * @param clientIpAddress IP - * @return + * @return boolean */ public static boolean enter(String clientIpAddress, String resource) { return RateLimiterUtil.enter(clientIpAddress, resource, null); @@ -89,8 +88,9 @@ public final class RateLimiterUtil { * 方法进入 * @param clientIpAddress IP * @param dfQps 手动指派QPS - * @return + * @return boolean */ + @SuppressWarnings("UnstableApiUsage") public static boolean enter(String clientIpAddress, String resource, Double dfQps) { // 计时器 long t1 = System.currentTimeMillis(); @@ -151,6 +151,7 @@ public final class RateLimiterUtil { * 限流器 */ @Data + @SuppressWarnings("UnstableApiUsage") public static class RateLimiterInner { /** qps */ @@ -166,9 +167,9 @@ public final class RateLimiterUtil { public static void main(String[] args) { + int count = 500; RateLimiterUtil.removeIp("127.0.0.1"); - for (int i = 0; i < 500; i++) { - int j = i; + for (int i = 0; i < count; i++) { AsyncProcessQueueReFuse.execute(()->{ boolean enter = RateLimiterUtil.enter("127.0.0.1","/api/v1", 2d); System.out.println(enter); diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/WrapperUtil.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/WrapperUtil.java index baa34ff..ca1ba75 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/WrapperUtil.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/WrapperUtil.java @@ -26,14 +26,11 @@ import java.util.List; import java.util.stream.Collectors; /** - * @BelongsProject: opsli-boot - * @BelongsPackage: org.opsli.common.utils - * @Author: Parker - * @CreateTime: 2020-09-19 00:08 - * @Description: 转化对象工具类 - * + * 转化对象工具类 * 用于 Wrapper 对象 转化为本地对象,或者本地对象转化为Wrapper对象 * + * @author Parker + * @date 2020-09-19 00:08 */ @Slf4j public final class WrapperUtil { @@ -96,7 +93,7 @@ public final class WrapperUtil { * @param source 源数据 * @param target 目标 * @param isClone 是否克隆 - * @param + * @param M * @return List */ public static List transformInstance(Collection source, Class target, boolean isClone){ diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/ZipUtils.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/ZipUtils.java index 3a846bc..3e5d6d5 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/ZipUtils.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/ZipUtils.java @@ -25,10 +25,10 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; /** + * 文件流转压缩包工具类 + * * @author Parker * @date 2020-01-07 - *

- * 文件流转压缩包工具类 */ public class ZipUtils { /** @@ -90,10 +90,10 @@ public class ZipUtils { public static void main(String[] args) throws Exception { List> list = new ArrayList<>(); - OutputStream outputStream = new FileOutputStream(new File("/Users/system/Documents/脚本/opsli/test.zip")); - Map m1 = new HashMap(){{put("path","/f1/f2/f3/");put("name","1.txt");put("data","abcdefg");}}; - Map m2 = new HashMap(){{put("path","/f1/f2/f3/f4/");put("name","2.txt");put("data","abcdefg");}}; - Map m3 = new HashMap(){{put("path","");put("name","3.txt");put("data","abcdefg");}}; + OutputStream outputStream = new FileOutputStream("/Users/system/Documents/脚本/opsli/test.zip"); + Map m1 = new HashMap(10){{put("path","/f1/f2/f3/");put("name","1.txt");put("data","abcdefg");}}; + Map m2 = new HashMap(10){{put("path","/f1/f2/f3/f4/");put("name","2.txt");put("data","abcdefg");}}; + Map m3 = new HashMap(10){{put("path","");put("name","3.txt");put("data","abcdefg");}}; list.add(m1); list.add(m2); diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ApiCryptoAsymmetricAop.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ApiCryptoAsymmetricAop.java index 15de4fe..f06b930 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ApiCryptoAsymmetricAop.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ApiCryptoAsymmetricAop.java @@ -64,7 +64,6 @@ public class ApiCryptoAsymmetricAop { * 切如 post 请求 * @param point point */ - @SuppressWarnings("unchecked") @Around("encryptAndDecrypt()") public Object encryptAndDecryptHandle(ProceedingJoinPoint point) throws Throwable { // 获得请求参数 @@ -158,6 +157,7 @@ public class ApiCryptoAsymmetricAop { * @param cryptoModel 非对称加解密模型 * @return Object */ + @SuppressWarnings("unchecked") private Object resultEncrypt(Object returnValue, CryptoAsymmetricService asymmetric, CryptoAsymmetric cryptoModel) { if(returnValue != null){ try { @@ -168,7 +168,6 @@ public class ApiCryptoAsymmetricAop { ret.setData( asymmetric.encrypt(cryptoModel, ret.getData()) ); - returnValue = ret; }else { returnValue = asymmetric.encrypt(cryptoModel, returnValue); } diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/Page.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/Page.java index e6310cb..afa6141 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/Page.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/Page.java @@ -153,7 +153,7 @@ public class Page extends PageSeriali private Long total; /** 行 */ - private List rows; + private List rows; }