diff --git a/dq-financial-api/src/main/java/com/daqing/financial/config/SwaggerConfig.java b/dq-financial-api/src/main/java/com/daqing/financial/config/SwaggerConfig.java new file mode 100644 index 00000000..e919e8e1 --- /dev/null +++ b/dq-financial-api/src/main/java/com/daqing/financial/config/SwaggerConfig.java @@ -0,0 +1,35 @@ +package com.daqing.financial.config; + +import io.swagger.annotations.ApiOperation; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +//@Profile({"dev","test"}) +//@ConditionalOnProperty(name = "swagger.enable", havingValue = "true") +public class SwaggerConfig { + + @Bean + public Docket productApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select()//添加ApiOperiation注解的被扫描 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder().title("大庆智慧金融平台api文档").description("大庆智慧金融平台api文档") + .version("1.0").build(); + } + +} \ No newline at end of file diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/DqFinancialCrmsApplication.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/DqFinancialCrmsApplication.java index a9afcab8..90326d15 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/DqFinancialCrmsApplication.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/DqFinancialCrmsApplication.java @@ -4,10 +4,12 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; @EnableFeignClients(basePackages = "com.daqing.financial.crms.feign") @EnableDiscoveryClient @SpringBootApplication +@ComponentScan(basePackages = "com.daqing.financial") public class DqFinancialCrmsApplication { public static void main(String[] args) { diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java index 6b8b3c6a..0aaf8d6a 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java @@ -32,6 +32,7 @@ public class CustomerController implements CustomerControllerApi { /** * 列表 */ + @Override @GetMapping("/list") //@RequiresPermissions("crms:customer:list") public ResponseResult list(@RequestParam Map params) { diff --git a/dq-govern-gateway/src/main/java/com/daqing/financial/gateway/config/FinancialCorsConfiguration.java b/dq-govern-gateway/src/main/java/com/daqing/financial/gateway/config/FinancialCorsConfiguration.java new file mode 100644 index 00000000..70d59b30 --- /dev/null +++ b/dq-govern-gateway/src/main/java/com/daqing/financial/gateway/config/FinancialCorsConfiguration.java @@ -0,0 +1,27 @@ +package com.daqing.financial.gateway.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.reactive.CorsWebFilter; +import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; + +@Configuration +public class FinancialCorsConfiguration { + + @Bean + public CorsWebFilter corsWebFilter(){ + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + + CorsConfiguration corsConfiguration = new CorsConfiguration(); + + //1、配置跨域 + corsConfiguration.addAllowedHeader("*"); + corsConfiguration.addAllowedMethod("*"); + corsConfiguration.addAllowedOrigin("*"); + corsConfiguration.setAllowCredentials(true); + + source.registerCorsConfiguration("/**",corsConfiguration); + return new CorsWebFilter(source); + } +} diff --git a/dq-govern-gateway/src/main/resources/application.yml b/dq-govern-gateway/src/main/resources/application.yml index dd9cd4b3..1c28ccc3 100644 --- a/dq-govern-gateway/src/main/resources/application.yml +++ b/dq-govern-gateway/src/main/resources/application.yml @@ -17,4 +17,4 @@ spring: predicates: - Path=/api/hrms/** filters: - - RewritePath=/api/(?.*),/$\{segment} \ No newline at end of file + - RewritePath=/api/(?.*),/ $\{segment} \ No newline at end of file