Merge branch 'master' into eureka

eureka
tanghc 5 years ago
commit edbc817053
  1. 4
      changelog.md
  2. 2
      sop-admin/sop-admin-server/pom.xml
  3. 58
      sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/common/MyApiSessionManager.java
  4. 3
      sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/config/WebConfig.java
  5. 2
      sop-admin/sop-admin-server/src/main/resources/public/index.html
  6. 1
      sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-73b2dcec.05b5ee28.js
  7. 1
      sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-73b2dcec.24dc2be7.js
  8. 2
      sop-admin/sop-admin-vue/src/views/isv/keys.vue
  9. 2
      sop-auth/pom.xml
  10. 2
      sop-common/pom.xml
  11. 4
      sop-common/sop-gateway-common/pom.xml
  12. 4
      sop-common/sop-service-common/pom.xml
  13. 18
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingHandlerMapping.java
  14. 11
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java
  15. 21
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/util/OpenUtil.java
  16. 2
      sop-example/sop-book/sop-book-web/pom.xml
  17. 2
      sop-example/sop-easyopen/pom.xml
  18. 2
      sop-example/sop-springmvc/pom.xml
  19. 2
      sop-example/sop-story/sop-story-web/pom.xml
  20. 12
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java
  21. 32
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController2.java
  22. 2
      sop-gateway/pom.xml
  23. 7
      sop-test/src/main/java/com/gitee/sop/test/Client.java
  24. 19
      sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java
  25. 2
      sop-website/pom.xml

@ -1,5 +1,9 @@
# changelog
## 2.5.8
- 优化参数绑定
## 2.5.7
- 优化restful接口调用

@ -42,7 +42,7 @@
<dependency>
<groupId>net.oschina.durcframework</groupId>
<artifactId>easyopen-spring-boot-starter</artifactId>
<version>1.16.2</version>
<version>1.16.5</version>
</dependency>
<dependency>

@ -1,58 +0,0 @@
package com.gitee.sop.adminserver.common;
import com.gitee.easyopen.exception.ApiException;
import com.gitee.easyopen.session.ApiSessionManager;
import com.google.common.cache.LoadingCache;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
/**
* @author tanghc
*/
@Slf4j
public class MyApiSessionManager extends ApiSessionManager {
private volatile LoadingCache<String, HttpSession> cache;
@Override
public HttpSession getSession(String sessionId) {
if (sessionId == null) {
return this.createSession(sessionId);
}
try {
return getCache().get(sessionId);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ApiException("create session error");
}
}
/**
* 创建一个session
*
* @param sessionId 传null将返回一个新session
* @return 返回session
*/
@Override
protected HttpSession createSession(String sessionId) {
ServletContext servletContext = getServletContext();
HttpSession session = this.newSession(sessionId, servletContext);
session.setMaxInactiveInterval(getSessionTimeout());
getCache().put(session.getId(), session);
return session;
}
public LoadingCache<String, HttpSession> getCache() {
if (cache == null) {
synchronized (ApiSessionManager.class) {
if (cache == null) {
cache = buildCache();
}
}
}
return cache;
}
}

@ -8,7 +8,6 @@ import com.gitee.easyopen.ApiParamParser;
import com.gitee.easyopen.ParamNames;
import com.gitee.easyopen.interceptor.ApiInterceptor;
import com.gitee.easyopen.session.ApiSessionManager;
import com.gitee.sop.adminserver.common.MyApiSessionManager;
import com.gitee.sop.adminserver.interceptor.LoginInterceptor;
import com.gitee.sop.adminserver.service.RegistryService;
import com.gitee.sop.adminserver.service.impl.RegistryServiceEurekaImpl;
@ -49,7 +48,7 @@ public class WebConfig {
, SerializerFeature.WriteDateUseDateFormat)
);
ApiSessionManager apiSessionManager = new MyApiSessionManager();
ApiSessionManager apiSessionManager = new ApiSessionManager();
// session有效期
int timeout = NumberUtils.toInt(accessTokenTimeout, 30);
apiSessionManager.setSessionTimeout(timeout);

@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=favicon.ico><title>SOP Admin</title><link href=static/css/chunk-elementUI.81cf475c.css rel=stylesheet><link href=static/css/chunk-libs.3dfb7769.css rel=stylesheet><link href=static/css/app.c6dfb7ee.css rel=stylesheet></head><body><noscript><strong>We're sorry but SOP Admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script>(function(e){function n(n){for(var r,c,a=n[0],f=n[1],i=n[2],d=0,l=[];d<a.length;d++)c=a[d],u[c]&&l.push(u[c][0]),u[c]=0;for(r in f)Object.prototype.hasOwnProperty.call(f,r)&&(e[r]=f[r]);h&&h(n);while(l.length)l.shift()();return o.push.apply(o,i||[]),t()}function t(){for(var e,n=0;n<o.length;n++){for(var t=o[n],r=!0,c=1;c<t.length;c++){var a=t[c];0!==u[a]&&(r=!1)}r&&(o.splice(n--,1),e=f(f.s=t[0]))}return e}var r={},c={runtime:0},u={runtime:0},o=[];function a(e){return f.p+"static/js/"+({}[e]||e)+"."+{"chunk-0faf9ba2":"88458f58","chunk-25908fca":"05d6b15b","chunk-2c1f2e8f":"f092c0a0","chunk-2d2085ef":"91d75f3c","chunk-2d221c34":"20057287","chunk-4de1c2b6":"e74e3d03","chunk-6f78c9fe":"3ac83b41","chunk-73b2dcec":"05b5ee28","chunk-9b31c83a":"52bc6b2c","chunk-9f479afe":"0d0ed757","chunk-c3ce42fe":"9517b588"}[e]+".js"}function f(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.e=function(e){var n=[],t={"chunk-0faf9ba2":1,"chunk-25908fca":1,"chunk-2c1f2e8f":1,"chunk-4de1c2b6":1,"chunk-73b2dcec":1,"chunk-9b31c83a":1,"chunk-c3ce42fe":1};c[e]?n.push(c[e]):0!==c[e]&&t[e]&&n.push(c[e]=new Promise(function(n,t){for(var r="static/css/"+({}[e]||e)+"."+{"chunk-0faf9ba2":"ed1510dd","chunk-25908fca":"89ab33e8","chunk-2c1f2e8f":"0314067f","chunk-2d2085ef":"31d6cfe0","chunk-2d221c34":"31d6cfe0","chunk-4de1c2b6":"a37cd815","chunk-6f78c9fe":"31d6cfe0","chunk-73b2dcec":"99cf6327","chunk-9b31c83a":"3b12267b","chunk-9f479afe":"31d6cfe0","chunk-c3ce42fe":"6b789903"}[e]+".css",u=f.p+r,o=document.getElementsByTagName("link"),a=0;a<o.length;a++){var i=o[a],d=i.getAttribute("data-href")||i.getAttribute("href");if("stylesheet"===i.rel&&(d===r||d===u))return n()}var l=document.getElementsByTagName("style");for(a=0;a<l.length;a++){i=l[a],d=i.getAttribute("data-href");if(d===r||d===u)return n()}var h=document.createElement("link");h.rel="stylesheet",h.type="text/css",h.onload=n,h.onerror=function(n){var r=n&&n.target&&n.target.src||u,o=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");o.code="CSS_CHUNK_LOAD_FAILED",o.request=r,delete c[e],h.parentNode.removeChild(h),t(o)},h.href=u;var s=document.getElementsByTagName("head")[0];s.appendChild(h)}).then(function(){c[e]=0}));var r=u[e];if(0!==r)if(r)n.push(r[2]);else{var o=new Promise(function(n,t){r=u[e]=[n,t]});n.push(r[2]=o);var i,d=document.createElement("script");d.charset="utf-8",d.timeout=120,f.nc&&d.setAttribute("nonce",f.nc),d.src=a(e),i=function(n){d.onerror=d.onload=null,clearTimeout(l);var t=u[e];if(0!==t){if(t){var r=n&&("load"===n.type?"missing":n.type),c=n&&n.target&&n.target.src,o=new Error("Loading chunk "+e+" failed.\n("+r+": "+c+")");o.type=r,o.request=c,t[1](o)}u[e]=void 0}};var l=setTimeout(function(){i({type:"timeout",target:d})},12e4);d.onerror=d.onload=i,document.head.appendChild(d)}return Promise.all(n)},f.m=e,f.c=r,f.d=function(e,n,t){f.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},f.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,n){if(1&n&&(e=f(e)),8&n)return e;if(4&n&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)f.d(t,r,function(n){return e[n]}.bind(null,r));return t},f.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return f.d(n,"a",n),n},f.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},f.p="",f.oe=function(e){throw console.error(e),e};var i=window["webpackJsonp"]=window["webpackJsonp"]||[],d=i.push.bind(i);i.push=n,i=i.slice();for(var l=0;l<i.length;l++)n(i[l]);var h=d;t()})([]);</script><script src=static/js/chunk-elementUI.298ac98c.js></script><script src=static/js/chunk-libs.75deb05f.js></script><script src=static/js/app.f05d6d01.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=favicon.ico><title>SOP Admin</title><link href=static/css/chunk-elementUI.81cf475c.css rel=stylesheet><link href=static/css/chunk-libs.3dfb7769.css rel=stylesheet><link href=static/css/app.c6dfb7ee.css rel=stylesheet></head><body><noscript><strong>We're sorry but SOP Admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script>(function(e){function n(n){for(var r,c,a=n[0],f=n[1],i=n[2],d=0,l=[];d<a.length;d++)c=a[d],u[c]&&l.push(u[c][0]),u[c]=0;for(r in f)Object.prototype.hasOwnProperty.call(f,r)&&(e[r]=f[r]);h&&h(n);while(l.length)l.shift()();return o.push.apply(o,i||[]),t()}function t(){for(var e,n=0;n<o.length;n++){for(var t=o[n],r=!0,c=1;c<t.length;c++){var a=t[c];0!==u[a]&&(r=!1)}r&&(o.splice(n--,1),e=f(f.s=t[0]))}return e}var r={},c={runtime:0},u={runtime:0},o=[];function a(e){return f.p+"static/js/"+({}[e]||e)+"."+{"chunk-0faf9ba2":"88458f58","chunk-25908fca":"05d6b15b","chunk-2c1f2e8f":"f092c0a0","chunk-2d2085ef":"91d75f3c","chunk-2d221c34":"20057287","chunk-4de1c2b6":"e74e3d03","chunk-6f78c9fe":"3ac83b41","chunk-73b2dcec":"24dc2be7","chunk-9b31c83a":"52bc6b2c","chunk-9f479afe":"0d0ed757","chunk-c3ce42fe":"9517b588"}[e]+".js"}function f(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.e=function(e){var n=[],t={"chunk-0faf9ba2":1,"chunk-25908fca":1,"chunk-2c1f2e8f":1,"chunk-4de1c2b6":1,"chunk-73b2dcec":1,"chunk-9b31c83a":1,"chunk-c3ce42fe":1};c[e]?n.push(c[e]):0!==c[e]&&t[e]&&n.push(c[e]=new Promise(function(n,t){for(var r="static/css/"+({}[e]||e)+"."+{"chunk-0faf9ba2":"ed1510dd","chunk-25908fca":"89ab33e8","chunk-2c1f2e8f":"0314067f","chunk-2d2085ef":"31d6cfe0","chunk-2d221c34":"31d6cfe0","chunk-4de1c2b6":"a37cd815","chunk-6f78c9fe":"31d6cfe0","chunk-73b2dcec":"99cf6327","chunk-9b31c83a":"3b12267b","chunk-9f479afe":"31d6cfe0","chunk-c3ce42fe":"6b789903"}[e]+".css",u=f.p+r,o=document.getElementsByTagName("link"),a=0;a<o.length;a++){var i=o[a],d=i.getAttribute("data-href")||i.getAttribute("href");if("stylesheet"===i.rel&&(d===r||d===u))return n()}var l=document.getElementsByTagName("style");for(a=0;a<l.length;a++){i=l[a],d=i.getAttribute("data-href");if(d===r||d===u)return n()}var h=document.createElement("link");h.rel="stylesheet",h.type="text/css",h.onload=n,h.onerror=function(n){var r=n&&n.target&&n.target.src||u,o=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");o.code="CSS_CHUNK_LOAD_FAILED",o.request=r,delete c[e],h.parentNode.removeChild(h),t(o)},h.href=u;var s=document.getElementsByTagName("head")[0];s.appendChild(h)}).then(function(){c[e]=0}));var r=u[e];if(0!==r)if(r)n.push(r[2]);else{var o=new Promise(function(n,t){r=u[e]=[n,t]});n.push(r[2]=o);var i,d=document.createElement("script");d.charset="utf-8",d.timeout=120,f.nc&&d.setAttribute("nonce",f.nc),d.src=a(e),i=function(n){d.onerror=d.onload=null,clearTimeout(l);var t=u[e];if(0!==t){if(t){var r=n&&("load"===n.type?"missing":n.type),c=n&&n.target&&n.target.src,o=new Error("Loading chunk "+e+" failed.\n("+r+": "+c+")");o.type=r,o.request=c,t[1](o)}u[e]=void 0}};var l=setTimeout(function(){i({type:"timeout",target:d})},12e4);d.onerror=d.onload=i,document.head.appendChild(d)}return Promise.all(n)},f.m=e,f.c=r,f.d=function(e,n,t){f.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},f.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,n){if(1&n&&(e=f(e)),8&n)return e;if(4&n&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)f.d(t,r,function(n){return e[n]}.bind(null,r));return t},f.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return f.d(n,"a",n),n},f.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},f.p="",f.oe=function(e){throw console.error(e),e};var i=window["webpackJsonp"]=window["webpackJsonp"]||[],d=i.push.bind(i);i.push=n,i=i.slice();for(var l=0;l<i.length;l++)n(i[l]);var h=d;t()})([]);</script><script src=static/js/chunk-elementUI.298ac98c.js></script><script src=static/js/chunk-libs.75deb05f.js></script><script src=static/js/app.f05d6d01.js></script></body></html>

@ -41,7 +41,7 @@
</el-form-item>
</fieldset>
<fieldset v-show="showKeys()">
<legend>平台公私钥</legend>
<legend>平台公私钥[可选]</legend>
<el-form-item class="gen-key">
<el-button type="text" @click="onGenKeysPlatform">重新生成</el-button>
</el-form-item>

@ -26,7 +26,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</dependency>
<!-- sop相关配置 end-->

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>

@ -5,11 +5,11 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sop-gateway-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sop-gateway-common</name>

@ -6,11 +6,11 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sop-service-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sop-service-common</name>

@ -4,8 +4,8 @@ import com.gitee.sop.servercommon.annotation.ApiAbility;
import com.gitee.sop.servercommon.annotation.ApiMapping;
import com.gitee.sop.servercommon.bean.ServiceConfig;
import com.gitee.sop.servercommon.bean.ServiceContext;
import com.gitee.sop.servercommon.util.OpenUtil;
import org.springframework.core.PriorityOrdered;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.StringValueResolver;
import org.springframework.web.servlet.mvc.condition.RequestCondition;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
@ -26,12 +26,14 @@ public class ApiMappingHandlerMapping extends RequestMappingHandlerMapping imple
String sopMvc = System.getProperty(ServiceContext.SOP_MVC);
boolean isMvc = sopMvc != null;
ApiMapping apiMapping = method.getAnnotation(ApiMapping.class);
ApiAbility apiAbility = method.getAnnotation(ApiAbility.class);
ApiAbility apiAbility = OpenUtil.getAnnotationFromMethodOrClass(method, ApiAbility.class);
StringValueResolver valueResolver = null;
if (apiMapping != null || apiAbility != null) {
valueResolver = isMvc ? stringValueResolverMVC : stringValueResolver;
}
this.setEmbeddedValueResolver(valueResolver);
if (valueResolver != null) {
this.setEmbeddedValueResolver(valueResolver);
}
return super.getMappingForMethod(method, handlerType);
}
@ -53,7 +55,7 @@ public class ApiMappingHandlerMapping extends RequestMappingHandlerMapping imple
permission = apiMapping.permission();
needToken = apiMapping.needToken();
} else {
ApiAbility apiAbility = this.findApiAbilityAnnotation(method);
ApiAbility apiAbility = OpenUtil.getAnnotationFromMethodOrClass(method, ApiAbility.class);
if (apiAbility != null) {
version = apiAbility.version();
ignoreValidate = apiAbility.ignoreValidate();
@ -88,12 +90,4 @@ public class ApiMappingHandlerMapping extends RequestMappingHandlerMapping imple
return new ApiMappingRequestCondition(apiMappingInfo);
}
protected ApiAbility findApiAbilityAnnotation(Method method) {
ApiAbility apiAbility = method.getAnnotation(ApiAbility.class);
if (apiAbility == null) {
Class<?> controllerClass = method.getDeclaringClass();
apiAbility = AnnotationUtils.findAnnotation(controllerClass, ApiAbility.class);
}
return apiAbility;
}
}

@ -21,7 +21,6 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartRequest;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor;
import org.springframework.web.servlet.mvc.method.annotation.ServletRequestMethodArgumentResolver;
import javax.servlet.ServletRequest;
@ -40,7 +39,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
@ -85,9 +83,7 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter methodParameter) {
// 是否有注解
boolean hasAnnotation = methodParameter.hasMethodAnnotation(ApiMapping.class)
|| methodParameter.hasMethodAnnotation(ApiAbility.class);
if (hasAnnotation) {
if (hasApiAnnotation(methodParameter)) {
openApiParams.add(methodParameter);
}
Class<?> paramType = methodParameter.getParameterType();
@ -116,6 +112,11 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver {
return !exclude;
}
private boolean hasApiAnnotation(MethodParameter methodParameter) {
return methodParameter.hasMethodAnnotation(ApiMapping.class)
|| OpenUtil.getAnnotationFromMethodOrClass(methodParameter.getMethod(), ApiAbility.class) != null;
}
@Override
public Object resolveArgument(
MethodParameter methodParameter

@ -5,10 +5,13 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.http.MediaType;
import org.springframework.util.DigestUtils;
import javax.servlet.http.HttpServletRequest;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
@ -90,4 +93,22 @@ public class OpenUtil {
String serverSign = DigestUtils.md5DigestAsHex(source.getBytes());
return serverSign.equals(sign);
}
/**
* 在方法或方法对应的类上找指定的注解
* @param method 方法
* @param annotationClass 指定的注解
* @param <T>
* @return 返回指定注解没有返回null
*/
public static <T extends Annotation> T getAnnotationFromMethodOrClass(Method method, Class<T> annotationClass) {
if (method == null) {
return null;
}
T annotation = AnnotationUtils.findAnnotation(method, annotationClass);
if (annotation == null) {
annotation = AnnotationUtils.findAnnotation(method.getDeclaringClass(), annotationClass);
}
return annotation;
}
}

@ -28,7 +28,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gitee.sop</groupId>

@ -29,7 +29,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</dependency>
<!-- 使用nacos注册中心

@ -20,7 +20,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</dependency>
<!-- nacos -->
<dependency>

@ -28,7 +28,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gitee.sop</groupId>

@ -18,6 +18,7 @@ import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -141,6 +142,17 @@ public class AlipayController {
return story;
}
// http://localhost:2222/getStory33
// 遗留接口具备开放平台能力
@ApiAbility
@PostMapping("getStory33")
public StoryResult getStory22(@RequestBody StoryParam param) {
StoryResult story = new StoryResult();
story.setId(1L);
story.setName("遗留接口,param:" + param);
return story;
}
// http://localhost:2222/getStory2?version=2.1
// 遗留接口具备开放平台能力,在原来的基础上加版本号
@ApiAbility(version = "2.1")

@ -0,0 +1,32 @@
package com.gitee.sop.storyweb.controller;
import com.gitee.sop.servercommon.annotation.ApiAbility;
import com.gitee.sop.storyweb.controller.param.StoryParam;
import com.gitee.sop.storyweb.controller.result.StoryResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* 支付宝服务端假设签名验证通过后到达这里进行具体的业务处理
*
* @author tanghc
*/
@RestController
@Slf4j
// 注解放在这里,表示类中的方法都具备接口开放能力
@ApiAbility
public class AlipayController2 {
// http://localhost:2222/getStory44
// 遗留接口具备开放平台能力
@PostMapping("/getStory44")
public StoryResult getStory22(@RequestBody StoryParam param) {
StoryResult story = new StoryResult();
story.setId(1L);
story.setName("遗留接口44,param:" + param);
return story;
}
}

@ -29,7 +29,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</dependency>
<!-- ↓↓↓ 使用spring cloud zuul ↓↓↓ -->

@ -133,7 +133,7 @@ public class Client {
private String url;
private String method;
private String version = DEFAULT_VERSION;
private Map<String, String> bizContent;
private Map<String, Object> bizContent;
private HttpTool.HTTPMethod httpMethod;
private Map<String, String> header;
private boolean ignoreSign;
@ -181,7 +181,7 @@ public class Client {
* @param bizContent 业务参数
* @return 返回RequestBuilder
*/
public RequestBuilder bizContent(Map<String, String> bizContent) {
public RequestBuilder bizContent(Map<String, Object> bizContent) {
this.bizContent = bizContent;
return this;
}
@ -227,6 +227,9 @@ public class Client {
*/
public RequestBuilder postJson(boolean postJson) {
this.postJson = postJson;
if (postJson) {
this.httpMethod(HttpTool.HTTPMethod.POST);
}
return this;
}

@ -58,6 +58,21 @@ public class AllInOneTest extends TestBase {
.version("1.0")
// 以json方式提交
.postJson(true)
.bizContent(new BizContent().add("id", "1").add("name", "葫芦娃"));
client.execute(requestBuilder);
}
/**
* 测试遗留接口
* 以json方式提交(application/json)
*/
public void testPostJSON2() {
Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
.method("getStory33")
.version("1.0")
// 以json方式提交
.postJson(true)
.bizContent(new BizContent().add("id", "1").add("name", "葫芦娃"))
.httpMethod(HttpTool.HTTPMethod.POST);
@ -298,8 +313,8 @@ public class AllInOneTest extends TestBase {
client.execute(requestBuilder);
}
class BizContent extends HashMap<String, String> {
public BizContent add(String key, String value) {
class BizContent extends HashMap<String, Object> {
public BizContent add(String key, Object value) {
this.put(key, value);
return this;
}

@ -35,7 +35,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>2.5.7-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</dependency>
<dependency>

Loading…
Cancel
Save