diff --git a/neuray-pm-base-server/base-auth/auth-client/src/main/java/com/gitee/neuray/security/auth/client/interceptor/UserAuthRestInterceptor.java b/neuray-pm-base-server/base-auth/auth-client/src/main/java/com/gitee/neuray/security/auth/client/interceptor/UserAuthRestInterceptor.java index 11bf76439ca4ec71e80e1d60402344d3300d8104..0380aba9e656837fb0fd10e8641b571c93a0f9e5 100644 --- a/neuray-pm-base-server/base-auth/auth-client/src/main/java/com/gitee/neuray/security/auth/client/interceptor/UserAuthRestInterceptor.java +++ b/neuray-pm-base-server/base-auth/auth-client/src/main/java/com/gitee/neuray/security/auth/client/interceptor/UserAuthRestInterceptor.java @@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** + * 用户鉴权拦截器 * Created by 东睿小组 * @author zhhongyu */ diff --git a/neuray-pm-base-server/base-auth/auth-server/src/main/resources/application.yml b/neuray-pm-base-server/base-auth/auth-server/src/main/resources/application.yml index efefa2cafdbeb956429fa6a2f09029edadb9bf09..f844e735a1a29334de01cfb1dbfaf39b17693b39 100644 --- a/neuray-pm-base-server/base-auth/auth-server/src/main/resources/application.yml +++ b/neuray-pm-base-server/base-auth/auth-server/src/main/resources/application.yml @@ -85,7 +85,6 @@ eureka: # ip-address: 127.0.0.1 client: serviceUrl: -# defaultZone: http://localhost:8761/eureka/ # docker 部署开启 defaultZone: http://${EUREKA_HOST:localhost}:${EUREKA_PORT:8070}/eureka/ ###向注册中心上注册自己 @@ -102,7 +101,7 @@ jwt: rsa-secret: xx1WET12^%3^(WE45 client: - id: air-auth + id: neuray-pm-auth secret: 123456 token-header: client-token expire: 14400 diff --git a/neuray-pm-base-server/base-center/src/main/resources/application.yml b/neuray-pm-base-server/base-center/src/main/resources/application.yml index 145d80df5cdbace25b695ef84aa35b82fabb1de4..9349317ce55db88b25023d28c08f1ee59e554368 100644 --- a/neuray-pm-base-server/base-center/src/main/resources/application.yml +++ b/neuray-pm-base-server/base-center/src/main/resources/application.yml @@ -9,3 +9,5 @@ eureka: client: registerWithEureka: false #false:不作为一个客户端注册到注册中心 fetchRegistry: false #为true时,可以启动,但报异常:Cannot execute request on any known server + serviceUrl: + defaultZone: http://localhost:8770/eureka diff --git a/neuray-pm-base-server/base-code-generator/pom.xml b/neuray-pm-base-server/base-code-generator/pom.xml index f01d1899ee8026d8698a683d37e92bca56f50e61..c6eec651accf4dcf40c20411bbdfa444dd0f76a0 100644 --- a/neuray-pm-base-server/base-code-generator/pom.xml +++ b/neuray-pm-base-server/base-code-generator/pom.xml @@ -92,6 +92,19 @@ neuray-pm-common 1.0-SNAPSHOT + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + com.gitee.neuray.security + auth-client + 1.0-SNAPSHOT + + + org.springframework.cloud + spring-cloud-starter-openfeign + neuray-pm-generator diff --git a/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/BaseCodeGeneratorBoostrap.java b/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/BaseCodeGeneratorBoostrap.java index e5c7ee98ef2e64ddbe90ae8060b801b8829ae66a..0b96e88f5ed7863b3ae5067122608e0bc824b866 100644 --- a/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/BaseCodeGeneratorBoostrap.java +++ b/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/BaseCodeGeneratorBoostrap.java @@ -1,7 +1,10 @@ package com.gitee.neuray.security.generator; +import com.gitee.neuray.security.auth.client.EnableAceAuthClient; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; /** * @author: zhhongyu @@ -9,6 +12,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * @since: Create in 9:41 2019/12/27 */ @SpringBootApplication +@EnableDiscoveryClient +@EnableAceAuthClient +@EnableFeignClients({"com.gitee.neuray.security.auth.client.feign"}) public class BaseCodeGeneratorBoostrap { public static void main(String[] args) { SpringApplication.run(BaseCodeGeneratorBoostrap.class, args); diff --git a/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/config/WebConfiguration.java b/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/config/WebConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..21bc77405390c127e90b186541d556bd3b1dd56a --- /dev/null +++ b/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/config/WebConfiguration.java @@ -0,0 +1,50 @@ +package com.gitee.neuray.security.generator.config; + +import com.gitee.neuray.security.auth.client.interceptor.ServiceAuthRestInterceptor; +import com.gitee.neuray.security.auth.client.interceptor.UserAuthRestInterceptor; +import com.gitee.neuray.security.common.handler.GlobalExceptionHandler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.util.ArrayList; +import java.util.Collections; + +/** + * springmvc适配器 + * @author zhhongyu + * @date 2020年1月8号 + */ +@Configuration +public class WebConfiguration implements WebMvcConfigurer { + @Bean + GlobalExceptionHandler getGlobalExceptionHandler() { + return new GlobalExceptionHandler(); + } + + /** + * 所有请求拦截 + * @param registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { +// registry.addInterceptor(getServiceAuthRestInterceptor()) +// .addPathPatterns("/code/**"); + registry.addInterceptor(getUserAuthRestInterceptor()). + addPathPatterns("/code/**"); + } + + @Bean + ServiceAuthRestInterceptor getServiceAuthRestInterceptor() { + return new ServiceAuthRestInterceptor(); + } + + @Bean + UserAuthRestInterceptor getUserAuthRestInterceptor() { + return new UserAuthRestInterceptor(); + } + + +} diff --git a/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/controller/SysGeneratorController.java b/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/controller/SysGeneratorController.java index e3baf21a3ceeb2b65cae4ec8ba35313cd1b251b5..b3a8b728b273b6bfe684a1fc2c17e6c8260c4be4 100644 --- a/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/controller/SysGeneratorController.java +++ b/neuray-pm-base-server/base-code-generator/src/main/java/com/gitee/neuray/security/generator/controller/SysGeneratorController.java @@ -24,7 +24,7 @@ import java.util.Map; public class SysGeneratorController { @Autowired private SysGeneratorService sysGeneratorService; - + /** * 列表 */ @@ -32,22 +32,22 @@ public class SysGeneratorController { @RequestMapping("/list") public R list(@RequestParam Map params){ PageUtils pageUtil = sysGeneratorService.queryList(new Query(params)); - + return R.ok().put("page", pageUtil); } - + /** * 生成代码 */ @RequestMapping("/code") public void code(String tables, HttpServletResponse response) throws IOException { byte[] data = sysGeneratorService.generatorCode(tables.split(",")); - - response.reset(); - response.setHeader("Content-Disposition", "attachment; filename=\"air-admin.zip\""); - response.addHeader("Content-Length", "" + data.length); - response.setContentType("application/octet-stream; charset=UTF-8"); - + + response.reset(); + response.setHeader("Content-Disposition", "attachment; filename=\"neuray-pm-admin.zip\""); + response.addHeader("Content-Length", "" + data.length); + response.setContentType("application/octet-stream; charset=UTF-8"); + IOUtils.write(data, response.getOutputStream()); } -} \ No newline at end of file +} diff --git a/neuray-pm-base-server/base-code-generator/src/main/resources/application.yml b/neuray-pm-base-server/base-code-generator/src/main/resources/application.yml index df7ba27b2072426bfdef486502e1fb28906f90c7..3cff34b7c9f241fd6cf471f0dbacafe34a0385f8 100644 --- a/neuray-pm-base-server/base-code-generator/src/main/resources/application.yml +++ b/neuray-pm-base-server/base-code-generator/src/main/resources/application.yml @@ -1,7 +1,7 @@ server: port: 8073 servlet: - context-path: /air-generator + context-path: /code spring: @@ -30,8 +30,12 @@ spring: jackson: time-zone: GMT+8 date-format: yyyy-MM-dd HH:mm:ss + default-property-inclusion: non_null resources: static-locations: classpath:/static/,classpath:/views/ + application: + name: neuray-pm-code + mybatis: @@ -47,3 +51,12 @@ pagehelper: #指定数据库,可选值有【mysql、oracle、sqlserver、postgresql】 air: database: oracle + +auth: + serviceId: neuray-pm-auth + user: + token-header: Authorization + client: + token-header: client-token + id: neuray-pm-code #不填则默认读取spring.application.name + secret: 123456 diff --git a/neuray-pm-base-server/base-code-generator/src/main/resources/bootstrap.yml b/neuray-pm-base-server/base-code-generator/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000000000000000000000000000000000..5c98689e495f1bc2d10a13d117b7f6bada097c05 --- /dev/null +++ b/neuray-pm-base-server/base-code-generator/src/main/resources/bootstrap.yml @@ -0,0 +1,32 @@ +eureka: + instance: + statusPageUrlPath: /actuator/info + healthCheckUrlPath: /actuator/health + home-page-url-path: / + # docker 部署开启 +# prefer-ip-address: true +# ip-address: 127.0.0.1 + client: + serviceUrl: + # docker 部署开启 + defaultZone: http://${EUREKA_HOST:localhost}:${EUREKA_PORT:8070}/eureka/ + ###向注册中心上注册自己 + register-with-eureka: true + ###是否需要从eureka上获取注册信息 + fetch-registry: true + +#请求和响应GZIP压缩支持 +feign: + httpclient: + enabled: false + okhttp: + enabled: true + compression: + request: + enabled: true + mime-types: text/xml,application/xml,application/json + min-request-size: 2048 + response: + enabled: true + hystrix: + enabled: true diff --git a/neuray-pm-base-server/base-gateway/gateway-server/src/main/resources/application.yml b/neuray-pm-base-server/base-gateway/gateway-server/src/main/resources/application.yml index ed60ac70d111de8149a1ee1cb11f7e17d8db1a18..e3ee341f812125909cda30d5e21d0900a7d372a0 100644 --- a/neuray-pm-base-server/base-gateway/gateway-server/src/main/resources/application.yml +++ b/neuray-pm-base-server/base-gateway/gateway-server/src/main/resources/application.yml @@ -51,6 +51,10 @@ zuul: path: /auth/** serviceId: neuray-pm-auth + code: + path: /generator/** + serviceId: neuray-pm-code + ribbon: eureka: enabled: true @@ -82,7 +86,7 @@ hystrix: gate: ignore: - startWith: /static,/auth/jwt,/fdfs/fdfs/file,/admin/org/tree,/admin/org/orgUsers,/admin/org/user,/admin/position/userSecret,/admin/api + startWith: /static,/auth/jwt,/admin/org/tree,/admin/org/orgUsers,/admin/org/user,/admin/api auth: @@ -91,5 +95,5 @@ auth: token-header: Authorization client: token-header: client-token - id: air-gate #不填则默认读取spring.application.name + id: neuray-pm-gate #不填则默认读取spring.application.name secret: 123456 diff --git a/neuray-pm-base-server/base-gateway/gateway-server/src/main/resources/bootstrap.yml b/neuray-pm-base-server/base-gateway/gateway-server/src/main/resources/bootstrap.yml index 14e433156375fca4847ebde1c2e8484f378b672e..b8789d63a562add4d1f3effdfdd317b45a2625d0 100644 --- a/neuray-pm-base-server/base-gateway/gateway-server/src/main/resources/bootstrap.yml +++ b/neuray-pm-base-server/base-gateway/gateway-server/src/main/resources/bootstrap.yml @@ -8,8 +8,7 @@ eureka: # ip-address: 127.0.0.1 client: serviceUrl: -# defaultZone: http://localhost:8761/eureka/ - # docker 部署开启 + # docker 部署开启 defaultZone: http://${EUREKA_HOST:localhost}:${EUREKA_PORT:8070}/eureka/ ###向注册中心上注册自己 register-with-eureka: true diff --git a/neuray-pm-provider/neuray-pm-provider-admin/src/main/resources/application.yml b/neuray-pm-provider/neuray-pm-provider-admin/src/main/resources/application.yml index 5cc1744e8e9e86b132ab595c306a5079b772a1b3..b05380e11f314b139e28b2244967038061f0d78f 100644 --- a/neuray-pm-provider/neuray-pm-provider-admin/src/main/resources/application.yml +++ b/neuray-pm-provider/neuray-pm-provider-admin/src/main/resources/application.yml @@ -57,7 +57,6 @@ eureka: # ip-address: 127.0.0.1 client: serviceUrl: -# defaultZone: http://localhost:8761/eureka/ # docker 部署开启 defaultZone: http://${EUREKA_HOST:localhost}:${EUREKA_PORT:8070}/eureka/ ###向注册中心上注册自己 @@ -109,7 +108,7 @@ auth: user: token-header: Authorization client: - id: air-admin + id: neuray-pm-admin secret: 123456 token-header: client-token diff --git a/neuray-pm-provider/neuray-pm-provider-admin/src/main/resources/logback-spring.xml b/neuray-pm-provider/neuray-pm-provider-admin/src/main/resources/logback-spring.xml index 07b83d8b6717ee3f91a7b9da0101cb4ee9142151..0bd7035552e7bc2564d42a1d5f4af1e8ad4da533 100644 --- a/neuray-pm-provider/neuray-pm-provider-admin/src/main/resources/logback-spring.xml +++ b/neuray-pm-provider/neuray-pm-provider-admin/src/main/resources/logback-spring.xml @@ -8,7 +8,7 @@ - +