From fdf9f341fd084181042eca127beb692a0650a225 Mon Sep 17 00:00:00 2001 From: tanghc Date: Fri, 26 Jul 2019 17:36:09 +0800 Subject: [PATCH] 1.13.3 --- .../api/service/IPBlacklistApi.java | 10 ++++++-- .../sop/adminserver/api/service/LogApi.java | 5 ++-- .../adminserver/api/service/ServiceApi.java | 2 +- .../service/result/LogMonitorInstanceVO.java | 2 +- .../adminserver/bean/ZookeeperContext.java | 3 ++- .../sop/adminserver/common/AdminErrors.java | 3 ++- .../gitee/sop/adminserver/common/IdGen.java | 6 ++--- .../gitee/sop/adminserver/common/RSATool.java | 9 ++++++- .../gitee/sop/adminserver/entity/IsvInfo.java | 2 +- .../interceptor/LoginInterceptor.java | 5 +++- .../sop/adminserver/mapper/IsvInfoMapper.java | 5 ++++ .../gatewaycommon/bean/BeanInitializer.java | 3 +++ .../gatewaycommon/bean/ConfigLimitDto.java | 3 +++ .../sop/gatewaycommon/bean/ErrorEntity.java | 11 ++++++-- .../sop/gatewaycommon/bean/RouteConfig.java | 2 +- .../sop/gatewaycommon/bean/RouteStatus.java | 19 +++++++++++--- .../sop/gatewaycommon/bean/TargetRoute.java | 16 ++++++++++++ .../route/ReadBodyRoutePredicateFactory.java | 4 +-- .../manager/IPBlacklistManager.java | 16 ++++++++++++ .../manager/RoutePermissionManager.java | 8 ++++++ .../gatewaycommon/param/BaseParamBuilder.java | 10 ++++++++ .../result/BaseExecutorAdapter.java | 9 ++++++- .../sop/gatewaycommon/secret/IsvManager.java | 17 +++++++++++++ .../sop/gatewaycommon/util/RequestUtil.java | 2 +- .../zuul/filter/PreLimitFilter.java | 25 ++++++++++++------- .../sop/registryapi/bean/ServiceInstance.java | 3 +++ .../registryapi/service/RegistryService.java | 3 +++ .../service/impl/RegistryServiceNacos.java | 4 +-- .../BaseServiceConfiguration.java | 6 ++++- .../EasyopenDocSupportController.java | 4 +++ .../SopHandlerMethodArgumentResolver.java | 6 +++++ .../servercommon/swagger/SwaggerSupport.java | 7 ++++++ .../sop/gateway/controller/RestServlet.java | 4 +++ .../gateway/manager/DbIPBlacklistManager.java | 3 +++ .../sop/gateway/manager/DbIsvManager.java | 2 ++ .../gateway/manager/DbLimitConfigManager.java | 2 ++ .../gateway/manager/DbRouteConfigManager.java | 2 ++ .../sop/gateway/mapper/IsvInfoMapper.java | 4 +++ .../com/gitee/sop/sdk/client/OpenHttp.java | 21 +++++++++++----- .../com/gitee/sop/sdk/common/RequestForm.java | 4 +++ .../gitee/sop/sdk/common/RequestMethod.java | 4 +++ .../com/gitee/sop/sdk/common/SdkConfig.java | 1 + .../gitee/sop/sdk/common/SopSdkConstants.java | 3 +++ .../gitee/sop/sdk/exception/SdkException.java | 3 +++ .../gitee/sop/sdk/request/BaseRequest.java | 8 +++++- .../gitee/sop/sdk/response/BaseResponse.java | 2 +- .../com/gitee/sop/sdk/util/BaseNCodec.java | 1 + .../java/com/gitee/sop/sdk/util/FileUtil.java | 4 +++ .../java/com/gitee/sop/sdk/util/HexUtil.java | 6 ++++- .../java/com/gitee/sop/sdk/util/MD5Util.java | 4 +++ 50 files changed, 262 insertions(+), 46 deletions(-) diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/IPBlacklistApi.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/IPBlacklistApi.java index 749afebf..284140cc 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/IPBlacklistApi.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/IPBlacklistApi.java @@ -14,7 +14,6 @@ import com.gitee.sop.adminserver.api.service.param.ConfigIpBlackForm; import com.gitee.sop.adminserver.api.service.param.ConfigIpBlacklistPageParam; import com.gitee.sop.adminserver.api.service.result.ConfigIpBlacklistVO; import com.gitee.sop.adminserver.bean.ChannelMsg; -import com.gitee.sop.adminserver.bean.ConfigLimitDto; import com.gitee.sop.adminserver.bean.ZookeeperContext; import com.gitee.sop.adminserver.common.BizException; import com.gitee.sop.adminserver.entity.ConfigIpBlacklist; @@ -93,6 +92,13 @@ public class IPBlacklistApi { } enum BlacklistMsgType { - ADD, DELETE + /** + * 黑名单消息类型:添加 + */ + ADD, + /** + * 黑名单消息类型:删除 + */ + DELETE } } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/LogApi.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/LogApi.java index e8f8060c..9b16cf4e 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/LogApi.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/LogApi.java @@ -40,6 +40,7 @@ public class LogApi { public static final String LOG_MONITOR_INSTANCE = "log.monitor.instance"; public static final String CODE_SUCCESS = "10000"; + private static final String CODE_KEY = "code"; @Autowired ConfigCommonMapper configCommonMapper; @@ -135,7 +136,7 @@ public class LogApi { try { String json = this.requestLogServer(ipPort, "listErrors"); JSONObject jsonObject = JSON.parseObject(json); - if (!CODE_SUCCESS.equals(jsonObject.getString("code"))) { + if (!CODE_SUCCESS.equals(jsonObject.getString(CODE_KEY))) { log.error("请求结果:{}", json); throw new BizException("添加失败"); } @@ -147,7 +148,7 @@ public class LogApi { private String requestLogServer(String ipPort, String path) throws Exception { DefaultMd5Verifier md5Verifier = new DefaultMd5Verifier(); - Map params = new HashMap<>(); + Map params = new HashMap<>(16); params.put("time", System.currentTimeMillis()); String sign = md5Verifier.buildSign(params, secret); params.put("sign", sign); diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java index 05f6c147..a80393e5 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java @@ -115,7 +115,7 @@ public class ServiceApi { List listService(ServiceSearchParam param) { List serviceInfos; try { - serviceInfos = registryService.listAllService(1, 99999/* 获取所有实例 */); + serviceInfos = registryService.listAllService(1, 99999); } catch (Exception e) { log.error("获取服务实例失败", e); return Collections.emptyList(); diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/LogMonitorInstanceVO.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/LogMonitorInstanceVO.java index ab20e814..b40aa008 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/LogMonitorInstanceVO.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/LogMonitorInstanceVO.java @@ -9,7 +9,7 @@ import lombok.Data; public class LogMonitorInstanceVO { private String id; private int treeId; - // 表主键 + /** 表主键 */ private long rawId; private String name; private String version; diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ZookeeperContext.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ZookeeperContext.java index 039fa126..50547a75 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ZookeeperContext.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ZookeeperContext.java @@ -22,6 +22,7 @@ import org.springframework.util.Assert; import java.io.Closeable; import java.util.Collections; import java.util.List; +import java.util.concurrent.Executors; import static com.gitee.sop.adminserver.bean.SopAdminConstants.SOP_MSG_CHANNEL_PATH; @@ -307,7 +308,7 @@ public class ZookeeperContext { String data = new String(nodeData); if (StringUtils.isNotBlank(data) && !initData.equals(data)) { listenCallback.onError(data); - new Thread(new ZKClose(cache, client)).start(); + Executors.newSingleThreadExecutor().execute(() -> new ZKClose(cache, client)); } } }); diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/AdminErrors.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/AdminErrors.java index f1ae3af6..569f25d1 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/AdminErrors.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/AdminErrors.java @@ -9,7 +9,8 @@ import com.gitee.easyopen.message.ErrorMeta; public class AdminErrors { private AdminErrors(){} - static String isvModule = "isv.error_"; // error_zh_CN2.properties内容前缀 + /** error_zh_CN2.properties内容前缀 */ + static String isvModule = "isv.error_"; public static final ErrorMeta NO_LOGIN = new ErrorMeta(isvModule, "-100", "用户未登录"); diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/IdGen.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/IdGen.java index 27947c88..dd246cfa 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/IdGen.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/IdGen.java @@ -124,9 +124,9 @@ public class IdGen { lastTimestamp = timestamp; //移位并通过或运算拼到一起组成64位的ID - return ((timestamp - twepoch) << timestampLeftShift) // - | (datacenterId << datacenterIdShift) // - | (workerId << workerIdShift) // + return ((timestamp - twepoch) << timestampLeftShift) + | (datacenterId << datacenterIdShift) + | (workerId << workerIdShift) | sequence; } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/RSATool.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/RSATool.java index b19890f3..606fafa1 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/RSATool.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/RSATool.java @@ -309,7 +309,14 @@ public class RSATool { } public enum KeyLength { - LENGTH_1024(1024), LENGTH_2048(2048); + /** + * 秘钥长度:1024 + */ + LENGTH_1024(1024), + /** + * 秘钥长度:2048 + */ + LENGTH_2048(2048); private int length; KeyLength(int length) { diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/IsvInfo.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/IsvInfo.java index 1a95e68b..40413dd7 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/IsvInfo.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/IsvInfo.java @@ -28,7 +28,7 @@ public class IsvInfo { /** appKey, 数据库字段:app_key */ private String appKey; - // 不再使用,转移到isv_keys表 + /** 不再使用,转移到isv_keys表 */ private String secret = ""; /** 公钥,不再使用,转移到isv_keys表 数据库字段:pub_key */ diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/interceptor/LoginInterceptor.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/interceptor/LoginInterceptor.java index 657878ec..b67d3a33 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/interceptor/LoginInterceptor.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/interceptor/LoginInterceptor.java @@ -15,6 +15,8 @@ import javax.servlet.http.HttpServletResponse; */ public class LoginInterceptor extends ApiInterceptorAdapter { + public static final String PREFIX = "nologin."; + @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object serviceObj, Object argu) throws Exception { @@ -28,7 +30,8 @@ public class LoginInterceptor extends ApiInterceptorAdapter { @Override public boolean match(ApiMeta apiMeta) { String name = apiMeta.getName(); - if (name.startsWith("nologin.")) { // 以‘nologin.’开头的接口不拦截 + // 以‘nologin.’开头的接口不拦截 + if (name.startsWith(PREFIX)) { return false; } else { return true; diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/mapper/IsvInfoMapper.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/mapper/IsvInfoMapper.java index ab8d28ae..f7990f8d 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/mapper/IsvInfoMapper.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/mapper/IsvInfoMapper.java @@ -13,6 +13,11 @@ import org.apache.ibatis.annotations.Select; */ public interface IsvInfoMapper extends CrudMapper { + /** + * 获取isv详细信息 + * @param appKey appKey + * @return 返回详细信息,没有返回null + */ @Select("SELECT " + " t.app_key appKey " + " ,t.status " + diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BeanInitializer.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BeanInitializer.java index 2161c9d8..cbb0f71a 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BeanInitializer.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BeanInitializer.java @@ -4,5 +4,8 @@ package com.gitee.sop.gatewaycommon.bean; * @author tanghc */ public interface BeanInitializer { + /** + * 执行加载操作 + */ void load(); } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ConfigLimitDto.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ConfigLimitDto.java index 1d1b339f..8b514b2f 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ConfigLimitDto.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ConfigLimitDto.java @@ -13,6 +13,9 @@ import java.util.Date; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; +/** + * @author thc + */ @Data public class ConfigLimitDto { diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ErrorEntity.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ErrorEntity.java index df6b4640..976b37ea 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ErrorEntity.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ErrorEntity.java @@ -6,6 +6,9 @@ import lombok.ToString; import java.util.Objects; +/** + * @author thc + */ @Getter @Setter @ToString @@ -19,8 +22,12 @@ public class ErrorEntity { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } ErrorEntity that = (ErrorEntity) o; return id.equals(that.id); } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteConfig.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteConfig.java index 8c1abe2d..08e99ed2 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteConfig.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteConfig.java @@ -8,7 +8,7 @@ import lombok.Data; @Data public class RouteConfig { - public static final byte STATUS_ENABLE = 1; + private static final byte STATUS_ENABLE = RouteStatus.ENABLE.getStatus(); /** * 路由id diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java index bc72bbc5..e8a00308 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java @@ -1,22 +1,33 @@ package com.gitee.sop.gatewaycommon.bean; /** + * 路由状态 + * * @author tanghc */ public enum RouteStatus { + /** + * 路由状态,0:待审核 + */ AUDIT(0, "待审核"), + /** + * 路由状态,1:已启用 + */ ENABLE(1, "已启用"), + /** + * 路由状态,2:已禁用 + */ DISABLE(2, "已禁用"), ; - private int status; + private byte status; private String description; - RouteStatus(int status, String description) { - this.status = status; + RouteStatus(Integer status, String description) { + this.status = status.byteValue(); this.description = description; } - public int getStatus() { + public byte getStatus() { return status; } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java index cf7b23c4..8f6def1c 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java @@ -4,9 +4,25 @@ package com.gitee.sop.gatewaycommon.bean; * @author tanghc */ public interface TargetRoute { + + /** + * 返回服务信息 + * + * @return 返回服务信息 + */ R getServiceRouteInfo(); + /** + * 返回微服务路由对象 + * + * @return 返回微服务路由对象 + */ E getRouteDefinition(); + /** + * 返回网关路由对象 + * + * @return 返回网关路由对象 + */ T getTargetRouteDefinition(); } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java index 8dfd7f05..588f4ffb 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java @@ -44,7 +44,7 @@ public class ReadBodyRoutePredicateFactory extends AbstractRoutePredicateFactory private static final String TEST_ATTRIBUTE = "read_body_predicate_test_attribute"; private static final String CACHE_REQUEST_BODY_OBJECT_KEY = "cachedRequestBodyObject"; - private static final List> messageReaders = HandlerStrategies.withDefaults().messageReaders(); + private static final List> HTTP_MESSAGE_READERS = HandlerStrategies.withDefaults().messageReaders(); public ReadBodyRoutePredicateFactory() { @@ -108,7 +108,7 @@ public class ReadBodyRoutePredicateFactory extends AbstractRoutePredicateFactory return cachedFlux; } }; - return ServerRequest.create(exchange.mutate().request(mutatedRequest).build(), messageReaders) + return ServerRequest.create(exchange.mutate().request(mutatedRequest).build(), HTTP_MESSAGE_READERS) .bodyToMono(inClass) .doOnNext(objectValue -> { exchange.getAttributes().put(CACHE_REQUEST_BODY_OBJECT_KEY, objectValue); diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/IPBlacklistManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/IPBlacklistManager.java index 64861390..36920c62 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/IPBlacklistManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/IPBlacklistManager.java @@ -7,10 +7,26 @@ import com.gitee.sop.gatewaycommon.bean.BeanInitializer; */ public interface IPBlacklistManager extends BeanInitializer { + /** + * 添加IP + * + * @param ip ip + */ void add(String ip); + /** + * 移除黑名单IP + * + * @param ip ip + */ void remove(String ip); + /** + * ip是否在黑名单中 + * + * @param ip ip + * @return true:在黑名单中 + */ boolean contains(String ip); } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RoutePermissionManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RoutePermissionManager.java index 8e572b28..df9a63f9 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RoutePermissionManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RoutePermissionManager.java @@ -6,7 +6,15 @@ import com.gitee.sop.gatewaycommon.bean.IsvRoutePermission; * @author tanghc */ public interface RoutePermissionManager { + /** + * 加载路由授权 + */ void load(); + /** + * 更新路由授权信息 + * + * @param isvRoutePermission 授权信息 + */ void update(IsvRoutePermission isvRoutePermission); } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/BaseParamBuilder.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/BaseParamBuilder.java index 7aafcc19..36aa6458 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/BaseParamBuilder.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/BaseParamBuilder.java @@ -17,8 +17,18 @@ import java.util.Optional; @Slf4j public abstract class BaseParamBuilder implements ParamBuilder { + /** + * 构建请求参数 + * @param ctx 请求request + * @return 返回请求参数 + */ public abstract Map buildRequestParams(T ctx); + /** + * 返回客户端ip + * @param ctx 请求request + * @return 返回ip + */ public abstract String getIP(T ctx); @Override diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java index c2340712..4307e7c6 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java @@ -275,6 +275,13 @@ public abstract class BaseExecutorAdapter implements ResultExecutor } enum ErrorType { - UNKNOWN, BIZ + /** + * 未知错误 + */ + UNKNOWN, + /** + * 业务错误 + */ + BIZ } } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/IsvManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/IsvManager.java index 178ef916..33102133 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/IsvManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/IsvManager.java @@ -5,14 +5,31 @@ import com.gitee.sop.gatewaycommon.bean.Isv; /** * Isv管理 + * * @author tanghc */ public interface IsvManager extends BeanInitializer { + /** + * 更新isv + * + * @param t isv + */ void update(T t); + /** + * 删除isv + * + * @param appKey isv对应的appKey + */ void remove(String appKey); + /** + * 获取isv + * + * @param appKey isv对应的key + * @return 返回isv + */ T getIsv(String appKey); } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java index d48e3b9b..836b6786 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java @@ -105,7 +105,7 @@ public class RequestUtil { DiskFileItemFactory factory = new DiskFileItemFactory(); //2、创建一个文件上传解析器 ServletFileUpload upload = new ServletFileUpload(factory); - Map params = new HashMap<>(); + Map params = new HashMap<>(16); try { List fileItems = upload.parseRequest(request); for (FileItem fileItem : fileItems) { diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreLimitFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreLimitFilter.java index ddf0d314..8649ad2a 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreLimitFilter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreLimitFilter.java @@ -21,6 +21,7 @@ import java.util.List; /** * 限流拦截器 + * * @author tanghc */ public class PreLimitFilter extends BaseZuulFilter { @@ -36,8 +37,7 @@ public class PreLimitFilter extends BaseZuulFilter { } @Override - protected Object doRun(RequestContext requestContext) throws ZuulException - { + protected Object doRun(RequestContext requestContext) throws ZuulException { ApiConfig apiConfig = ApiConfig.getInstance(); // 限流功能未开启,直接返回 if (!apiConfig.isOpenLimit()) { @@ -75,14 +75,21 @@ public class PreLimitFilter extends BaseZuulFilter { // 最多7种情况 String[] limitKeys = new String[]{ - routeId, // 根据路由ID限流 - appKey, // 根据appKey限流 - routeId + appKey, // 根据路由ID + appKey限流 + // 根据路由ID限流 + routeId, + // 根据appKey限流 + appKey, + // 根据路由ID + appKey限流 + routeId + appKey, - ip, // 根据ip限流 - ip + routeId, // 根据ip+路由id限流 - ip + appKey, // 根据ip+appKey限流 - ip + routeId + appKey, // 根据ip+路由id+appKey限流 + // 根据ip限流 + ip, + // 根据ip+路由id限流 + ip + routeId, + // 根据ip+appKey限流 + ip + appKey, + // 根据ip+路由id+appKey限流 + ip + routeId + appKey, }; List limitConfigList = new ArrayList<>(); diff --git a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInstance.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInstance.java index 9017dbaa..c039ef6d 100644 --- a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInstance.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInstance.java @@ -2,6 +2,9 @@ package com.gitee.sop.registryapi.bean; import lombok.Data; +/** + * @author thc + */ @Data public class ServiceInstance { /** diff --git a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/RegistryService.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/RegistryService.java index 974e724e..45526adb 100644 --- a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/RegistryService.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/RegistryService.java @@ -15,6 +15,7 @@ public interface RegistryService { * @param pageNo 当前页码 * @param pageSize 分页大小 * @return 返回服务列表 + * @throws Exception 获取失败抛出异常 */ List listAllService(int pageNo, int pageSize) throws Exception; @@ -22,6 +23,7 @@ public interface RegistryService { * 服务上线 * * @param serviceInstance + * @throws Exception 服务上线失败抛出异常 */ void onlineInstance(ServiceInstance serviceInstance) throws Exception; @@ -29,6 +31,7 @@ public interface RegistryService { * 服务下线 * * @param serviceInstance + * @throws Exception 服务下线失败抛出异常 */ void offlineInstance(ServiceInstance serviceInstance) throws Exception; diff --git a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceNacos.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceNacos.java index 4d72b98b..0a6cbcd8 100644 --- a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceNacos.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceNacos.java @@ -73,7 +73,7 @@ public class RegistryServiceNacos implements RegistryService { @Override public void onlineInstance(ServiceInstance serviceInstance) throws Exception { - Map params = new HashMap<>(); + Map params = new HashMap<>(8); // 上线,把权重设置成1 params.put("weight", "1"); this.updateInstance(serviceInstance, params); @@ -81,7 +81,7 @@ public class RegistryServiceNacos implements RegistryService { @Override public void offlineInstance(ServiceInstance serviceInstance) throws Exception { - Map params = new HashMap<>(); + Map params = new HashMap<>(8); // 下线,把权重设置成0 params.put("weight", "0"); this.updateInstance(serviceInstance, params); diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java index ba210c8a..2dbd418e 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java @@ -73,7 +73,11 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport doAfter(); } - // springboot启动完成后执行 + /** + * springboot启动完成后执行 + * @param args 启动参数 + * @throws Exception 出错异常 + */ @Override public void run(ApplicationArguments args) throws Exception { log.info("-----服务器启动完毕-----"); diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenDocSupportController.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenDocSupportController.java index 69d5f804..7aa4d8ea 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenDocSupportController.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenDocSupportController.java @@ -19,6 +19,10 @@ public abstract class EasyopenDocSupportController { private SwaggerValidator swaggerValidator; + /** + * 获取文档标题 + * @return 返回文档标题 + */ public abstract String getDocTitle(); public EasyopenDocSupportController() { diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/SopHandlerMethodArgumentResolver.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/SopHandlerMethodArgumentResolver.java index 535bf70f..50b589a7 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/SopHandlerMethodArgumentResolver.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/SopHandlerMethodArgumentResolver.java @@ -7,5 +7,11 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl * @author tanghc */ public interface SopHandlerMethodArgumentResolver extends HandlerMethodArgumentResolver { + + /** + * 设置requestMappingHandlerAdapter + * + * @param requestMappingHandlerAdapter requestMappingHandlerAdapter + */ void setRequestMappingHandlerAdapter(RequestMappingHandlerAdapter requestMappingHandlerAdapter); } diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/SwaggerSupport.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/SwaggerSupport.java index c207eb8d..bb385e57 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/SwaggerSupport.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/SwaggerSupport.java @@ -10,8 +10,15 @@ import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; +/** + * @author thc + */ public abstract class SwaggerSupport { + /** + * 获取文档标题 + * @return 返回文档标题 + */ protected abstract String getDocTitle(); @Bean diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/controller/RestServlet.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/controller/RestServlet.java index 14becac5..756020bb 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/controller/RestServlet.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/controller/RestServlet.java @@ -12,6 +12,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +/** + * 传统web开发入口 + * @author thc + */ @WebServlet(urlPatterns = "/rest/*") public class RestServlet extends HttpServlet { diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIPBlacklistManager.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIPBlacklistManager.java index 540c898c..30788c85 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIPBlacklistManager.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIPBlacklistManager.java @@ -15,6 +15,7 @@ import java.util.List; /** * 限流配置管理 + * * @author tanghc */ @Slf4j @@ -52,6 +53,8 @@ public class DbIPBlacklistManager extends DefaultIPBlacklistManager { log.info("移除IP黑名单,ip:{}", ip); remove(ip); break; + default: + log.error("IP黑名单,错误的消息指令,nodeData:{}", nodeData); } }); } diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIsvManager.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIsvManager.java index 89a32508..3a58efae 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIsvManager.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIsvManager.java @@ -56,6 +56,8 @@ public class DbIsvManager extends CacheIsvManager { log.info("删除ISV,isvDefinition:{}", isvDefinition); remove(isvDefinition.getAppKey()); break; + default: + log.error("ISV信息,错误的消息指令,nodeData:{}", nodeData); } }); diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbLimitConfigManager.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbLimitConfigManager.java index cbb661f5..3df9f051 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbLimitConfigManager.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbLimitConfigManager.java @@ -60,6 +60,8 @@ public class DbLimitConfigManager extends DefaultLimitConfigManager { log.info("更新限流配置信息,configLimitDto:{}", configLimitDto); update(configLimitDto); break; + default: + log.error("限流配置信息,错误的消息指令,nodeData:{}", nodeData); } }); } diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRouteConfigManager.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRouteConfigManager.java index 2a8dee88..004eed57 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRouteConfigManager.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRouteConfigManager.java @@ -84,6 +84,8 @@ public class DbRouteConfigManager extends DefaultRouteConfigManager { log.info("更新路由配置信息,routeConfigDto:{}", routeConfig); update(routeConfig); break; + default: + log.error("路由配置信息,错误的消息指令,nodeData:{}", nodeData); } }); } diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/IsvInfoMapper.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/IsvInfoMapper.java index eb308772..a0f78b90 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/IsvInfoMapper.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/IsvInfoMapper.java @@ -13,6 +13,10 @@ import java.util.List; */ public interface IsvInfoMapper extends CrudMapper { + /** + * 获取所有的isv信息 + * @return 所有的isv信息 + */ @Select("SELECT " + " t.app_key appKey " + " ,t.status " + diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/client/OpenHttp.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/client/OpenHttp.java index 76250bc0..aed2ee6a 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/client/OpenHttp.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/client/OpenHttp.java @@ -44,14 +44,17 @@ public class OpenHttp { protected void initHttpClient(OpenConfig openConfig) { httpClient = new OkHttpClient.Builder() - .connectTimeout(openConfig.getConnectTimeoutSeconds(), TimeUnit.SECONDS) // 设置链接超时时间,默认10秒 + // 设置链接超时时间 + .connectTimeout(openConfig.getConnectTimeoutSeconds(), TimeUnit.SECONDS) .readTimeout(openConfig.getReadTimeoutSeconds(), TimeUnit.SECONDS) .writeTimeout(openConfig.getWriteTimeoutSeconds(), TimeUnit.SECONDS) .cookieJar(new CookieJar() { + @Override public void saveFromResponse(HttpUrl httpUrl, List list) { cookieStore.put(httpUrl.host(), list); } + @Override public List loadForRequest(HttpUrl httpUrl) { List cookies = cookieStore.get(httpUrl.host()); return cookies != null ? cookies : new ArrayList(); @@ -79,8 +82,9 @@ public class OpenHttp { /** * 请求json数据,contentType=application/json - * @param url 请求路径 - * @param json json数据 + * + * @param url 请求路径 + * @param json json数据 * @param header header * @return 返回响应结果 * @throws IOException @@ -188,9 +192,14 @@ public class OpenHttp { bodyBuilder.setType(MultipartBody.FORM); for (UploadFile uploadFile : files) { - bodyBuilder.addFormDataPart(uploadFile.getName(), // 请求的名字 - uploadFile.getFileName(), // 文件的文字,服务器端用来解析的 - RequestBody.create(null, uploadFile.getFileData()) // 创建RequestBody,把上传的文件放入 + + bodyBuilder.addFormDataPart( + // 请求的名字 + uploadFile.getName(), + // 文件的文字,服务器端用来解析的 + uploadFile.getFileName(), + // 创建RequestBody,把上传的文件放入 + RequestBody.create(null, uploadFile.getFileData()) ); } diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/RequestForm.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/RequestForm.java index 852e1f18..0bd71713 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/RequestForm.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/RequestForm.java @@ -6,6 +6,10 @@ import lombok.Setter; import java.util.List; import java.util.Map; +/** + * 请求form + * @author thc + */ @Getter @Setter public class RequestForm { diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/RequestMethod.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/RequestMethod.java index 7089ab98..ada6a822 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/RequestMethod.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/RequestMethod.java @@ -1,5 +1,9 @@ package com.gitee.sop.sdk.common; +/** + * 请求方法枚举 + * @author thc + */ public enum RequestMethod { GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/SdkConfig.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/SdkConfig.java index 253d1df4..18598a81 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/SdkConfig.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/SdkConfig.java @@ -2,6 +2,7 @@ package com.gitee.sop.sdk.common; /** * @deprecated 已废弃,使用com.gitee.sop.sdk.common.OpenConfig + * @author thc */ @Deprecated public class SdkConfig { diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/SopSdkConstants.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/SopSdkConstants.java index 91f87618..16cbf156 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/SopSdkConstants.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/common/SopSdkConstants.java @@ -1,5 +1,8 @@ package com.gitee.sop.sdk.common; +/** + * @author thc + */ public class SopSdkConstants { public static String DATA_SUFFIX = "_response"; diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/exception/SdkException.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/exception/SdkException.java index 01761ced..dd18f4ca 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/exception/SdkException.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/exception/SdkException.java @@ -1,5 +1,8 @@ package com.gitee.sop.sdk.exception; +/** + * @author thc + */ public class SdkException extends RuntimeException { private static final long serialVersionUID = -1108392076700488161L; diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/request/BaseRequest.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/request/BaseRequest.java index 7b975036..5b5089de 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/request/BaseRequest.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/request/BaseRequest.java @@ -31,6 +31,8 @@ import java.util.Map; * biz_content String 是 请求参数的集合,最大长度不限,除公共参数外所有请求参数都必须放在这个参数中传递,具体参照各产品快速接入文档 * * @param 对应的Response对象 + * + * @author thc */ public abstract class BaseRequest { @@ -47,6 +49,10 @@ public abstract class BaseRequest { private Class responseClass = (Class) ClassUtil.getSuperClassGenricType(this.getClass(), 0);; + /** + * 定义接口名称 + * @return 接口名称 + */ protected abstract String method(); public BaseRequest() { @@ -80,7 +86,7 @@ public abstract class BaseRequest { public RequestForm createRequestForm(OpenConfig openConfig) { // 公共请求参数 - Map params = new HashMap(); + Map params = new HashMap(16); params.put(openConfig.getMethodName(), this.method); params.put(openConfig.getFormatName(), openConfig.getFormatType()); params.put(openConfig.getCharsetName(), openConfig.getCharset()); diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/response/BaseResponse.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/response/BaseResponse.java index 2a62c393..080d2ed3 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/response/BaseResponse.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/response/BaseResponse.java @@ -16,7 +16,7 @@ import lombok.Setter; * }, * "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE" * } - * + * @author thc */ @Setter @Getter diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/BaseNCodec.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/BaseNCodec.java index 20305435..95198594 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/BaseNCodec.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/BaseNCodec.java @@ -77,6 +77,7 @@ public abstract class BaseNCodec { * @return a String useful for debugging. */ @SuppressWarnings("boxing") // OK to ignore boxing here + @Override public String toString() { return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " + "modulus=%s, pos=%s, readPos=%s]", this.getClass().getSimpleName(), Arrays.toString(buffer), diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/FileUtil.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/FileUtil.java index 1b35f876..c2db17ec 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/FileUtil.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/FileUtil.java @@ -7,6 +7,10 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +/** + * 文件工具类 + * @author thc + */ public class FileUtil { /** diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/HexUtil.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/HexUtil.java index c764ab5f..9d42eddc 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/HexUtil.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/HexUtil.java @@ -1,5 +1,9 @@ package com.gitee.sop.sdk.util; +/** + * hex工具类 + * @author thc + */ public class HexUtil { private static final String ZERO = "0"; private static final String CHARS = "0123456789ABCDEF"; @@ -30,7 +34,7 @@ public class HexUtil { * @return byte[] */ public static byte[] hex2bytes(String hexString) { - if (hexString == null || hexString.equals("")) { + if (hexString == null || "".equalsIgnoreCase(hexString)) { return null; } hexString = hexString.toUpperCase(); diff --git a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/MD5Util.java b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/MD5Util.java index 985ba58a..3b17b22b 100644 --- a/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/MD5Util.java +++ b/sop-sdk/sdk-java/src/main/java/com/gitee/sop/sdk/util/MD5Util.java @@ -2,6 +2,10 @@ package com.gitee.sop.sdk.util; import java.security.MessageDigest; +/** + * MD5工具类 + * @author thc + */ public class MD5Util { private static final String MD5 = "MD5";