Merge branch 'master' into registry-nacos

pull/1/head
tanghc 5 years ago
commit 1717a8ab4f
  1. 10
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java
  2. 12
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/config/OpenServiceConfig.java
  3. 5
      sop-gateway/src/main/java/com/gitee/sop/gateway/controller/ErrorLogController.java
  4. 80
      sop-test/pom.xml

@ -17,6 +17,7 @@ import org.springframework.core.env.Environment;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@ -40,6 +41,15 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport
private ApiMappingHandlerMapping apiMappingHandlerMapping = new ApiMappingHandlerMapping(); private ApiMappingHandlerMapping apiMappingHandlerMapping = new ApiMappingHandlerMapping();
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
super.addResourceHandlers(registry);
// 支持swagger-bootstrap-ui首页
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
// 支持默认swagger
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Override @Override
protected void addInterceptors(InterceptorRegistry registry) { protected void addInterceptors(InterceptorRegistry registry) {

@ -4,7 +4,6 @@ import com.gitee.sop.servercommon.bean.ServiceConfig;
import com.gitee.sop.servercommon.configuration.AlipayServiceConfiguration; import com.gitee.sop.servercommon.configuration.AlipayServiceConfiguration;
import com.gitee.sop.servercommon.swagger.SwaggerSupport; import com.gitee.sop.servercommon.swagger.SwaggerSupport;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
/** /**
@ -14,21 +13,10 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration @Configuration
public class OpenServiceConfig extends AlipayServiceConfiguration { public class OpenServiceConfig extends AlipayServiceConfiguration {
static { static {
ServiceConfig.getInstance().getI18nModules().add("i18n/isp/goods_error"); ServiceConfig.getInstance().getI18nModules().add("i18n/isp/goods_error");
} }
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
super.addResourceHandlers(registry);
// 支持swagger-bootstrap-ui首页
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
// 支持默认swagger
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
/** /**
* 开启文档本地微服务文档地址http://localhost:2222/doc.html * 开启文档本地微服务文档地址http://localhost:2222/doc.html

@ -62,7 +62,10 @@ public class ErrorLogController {
private void check(HttpServletRequest request) { private void check(HttpServletRequest request) {
Map<String, String> params = RequestUtil.convertRequestParamsToMap(request); Map<String, String> params = RequestUtil.convertRequestParamsToMap(request);
ApiParam apiParam = ApiParam.build(params); ApiParam apiParam = ApiParam.build(params);
signer.checkSign(apiParam, secret); boolean right = signer.checkSign(apiParam, secret);
if (!right) {
throw new RuntimeException("签名校验失败");
}
} }
} }

@ -15,8 +15,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source> <java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
@ -58,48 +57,39 @@
</dependencies> </dependencies>
<build> <build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins>
<plugins> <!-- 打包时跳过测试 -->
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> <plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.1.0</version> <version>2.12.4</version>
</plugin> <configuration>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> <skipTests>true</skipTests>
<plugin> </configuration>
<artifactId>maven-resources-plugin</artifactId> </plugin>
<version>3.0.2</version> <plugin>
</plugin> <groupId>org.apache.maven.plugins</groupId>
<plugin> <artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId> <version>3.1</version>
<version>3.8.0</version> <configuration>
</plugin> <source>${java.version}</source>
<plugin> <target>${java.version}</target>
<artifactId>maven-surefire-plugin</artifactId> <encoding>UTF-8</encoding>
<version>2.22.1</version> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-jar-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>3.0.2</version> <artifactId>maven-source-plugin</artifactId>
</plugin> <version>2.2.1</version>
<plugin> <executions>
<artifactId>maven-install-plugin</artifactId> <execution>
<version>2.5.2</version> <id>attach-sources</id>
</plugin> <goals>
<plugin> <goal>jar-no-fork</goal>
<artifactId>maven-deploy-plugin</artifactId> </goals>
<version>2.8.2</version> </execution>
</plugin> </executions>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> </plugin>
<plugin> </plugins>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build> </build>
</project> </project>

Loading…
Cancel
Save