فهرست منبع

Merge pull request #1 from wuyouzhuguli/master

merge.
LIUZHUOMING 6 سال پیش
والد
کامیت
6e7f043ace
100فایلهای تغییر یافته به همراه922 افزوده شده و 1659 حذف شده
  1. 23 17
      Readme.md
  2. 2 2
      febs-auth/Dockerfile
  3. 3 3
      febs-auth/pom.xml
  4. 22 6
      febs-auth/src/main/java/cc/mrbird/febs/auth/configure/FebsAuthorizationServerConfigurer.java
  5. 3 2
      febs-auth/src/main/java/cc/mrbird/febs/auth/configure/FebsResourceServerConfigurer.java
  6. 3 2
      febs-auth/src/main/java/cc/mrbird/febs/auth/configure/FebsSecurityConfigure.java
  7. 0 25
      febs-auth/src/main/java/cc/mrbird/febs/auth/configure/JWTConfigure.java
  8. 0 10
      febs-auth/src/main/java/cc/mrbird/febs/auth/controller/SecurityController.java
  9. 7 5
      febs-auth/src/main/java/cc/mrbird/febs/auth/filter/ValidateCodeFilter.java
  10. 4 0
      febs-auth/src/main/java/cc/mrbird/febs/auth/properties/FebsAuthProperties.java
  11. 2 2
      febs-auth/src/main/java/cc/mrbird/febs/auth/properties/FebsClientsProperties.java
  12. 2 1
      febs-auth/src/main/java/cc/mrbird/febs/auth/properties/FebsValidateCodeProperties.java
  13. 5 5
      febs-auth/src/main/java/cc/mrbird/febs/auth/runner/StartedUpRunner.java
  14. 1 1
      febs-auth/src/main/java/cc/mrbird/febs/auth/service/FebsUserDetailService.java
  15. 6 4
      febs-auth/src/main/java/cc/mrbird/febs/auth/service/ValidateCodeService.java
  16. 9 21
      febs-auth/src/main/resources/bootstrap.yml
  17. 1 0
      febs-auth/src/main/resources/febs-auth.properties
  18. 11 47
      febs-cloud/docker compose/febs-cloud/docker-compose.yml
  19. 23 0
      febs-cloud/docker compose/nacos/docker-compose.yml
  20. 11 5
      febs-cloud/pom.xml
  21. 1 1
      febs-cloud/sql/febs_cloud_base.sql
  22. 52 0
      febs-cloud/sql/febs_nacos.sql
  23. 0 0
      febs-cloud/sql/zipkin.sql
  24. 6 6
      febs-common/pom.xml
  25. 7 2
      febs-common/src/main/java/cc/mrbird/febs/common/annotation/ControllerEndpoint.java
  26. 5 5
      febs-common/src/main/java/cc/mrbird/febs/common/configure/FebsOAuth2FeignConfigure.java
  27. 0 45
      febs-common/src/main/java/cc/mrbird/febs/common/entity/FebsConstant.java
  28. 25 0
      febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/EndpointConstant.java
  29. 56 0
      febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/FebsConstant.java
  30. 1 2
      febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/FebsServerConstant.java
  31. 1 1
      febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/GeneratorConstant.java
  32. 30 0
      febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/GrantTypeConstant.java
  33. 18 0
      febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/ImageTypeConstant.java
  34. 23 0
      febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/ParamsConstant.java
  35. 1 1
      febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/RegexpConstant.java
  36. 5 5
      febs-common/src/main/java/cc/mrbird/febs/common/interceptor/FebsServerProtectInterceptor.java
  37. 1 0
      febs-common/src/main/java/cc/mrbird/febs/common/selector/FebsCloudApplicationSelector.java
  38. 12 0
      febs-common/src/main/java/cc/mrbird/febs/common/utils/FebsUtil.java
  39. 3 3
      febs-common/src/main/java/cc/mrbird/febs/common/utils/FileUtil.java
  40. 1 3
      febs-common/src/main/java/cc/mrbird/febs/common/utils/ServletRequestIPUtil.java
  41. 6 5
      febs-common/src/main/java/cc/mrbird/febs/common/utils/SortUtil.java
  42. 0 2
      febs-common/src/main/java/cc/mrbird/febs/common/utils/SpringContextUtil.java
  43. 1 1
      febs-common/src/main/java/cc/mrbird/febs/common/validator/MobileValidator.java
  44. 0 5
      febs-config/Dockerfile
  45. 0 46
      febs-config/pom.xml
  46. 0 60
      febs-config/repository/config/FEBS-Auth-dev.yml
  47. 0 61
      febs-config/repository/config/FEBS-Auth-prod.yml
  48. 0 60
      febs-config/repository/config/FEBS-Auth-test.yml
  49. 0 57
      febs-config/repository/config/FEBS-Gateway.yml
  50. 0 74
      febs-config/repository/config/FEBS-Server-System-dev.yml
  51. 0 74
      febs-config/repository/config/FEBS-Server-System-prod.yml
  52. 0 74
      febs-config/repository/config/FEBS-Server-System-test.yml
  53. 0 42
      febs-config/repository/config/FEBS-Server-Test.yml
  54. 0 4
      febs-config/run.sh
  55. 0 20
      febs-config/src/main/java/cc/mrbird/febs/config/FebsConfigApplication.java
  56. 0 35
      febs-config/src/main/java/cc/mrbird/febs/config/runner/StartedUpRunner.java
  57. 0 8
      febs-config/src/main/resources/banner.txt
  58. 0 49
      febs-config/src/main/resources/bootstrap.yml
  59. 0 53
      febs-config/src/main/resources/logback-spring.xml
  60. 2 2
      febs-gateway/Dockerfile
  61. 44 12
      febs-gateway/pom.xml
  62. 0 4
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/FebsGatewayApplication.java
  63. 14 13
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/configure/FebsGateWayCorsConfigure.java
  64. 57 0
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/configure/FebsGatewayErrorConfigure.java
  65. 0 19
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/configure/FebsGatewaySecurityConfigure.java
  66. 25 22
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/configure/FebsGatewaySentinelConfigure.java
  67. 24 0
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/controller/FallbackController.java
  68. 0 29
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/fallback/FebsGatewayBlockFallbackProvider.java
  69. 0 61
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/filter/FebsGatewayErrorFilter.java
  70. 59 46
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/filter/FebsGatewayRequestFilter.java
  71. 73 0
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/handler/FebsGatewayExceptionHandler.java
  72. 5 5
      febs-gateway/src/main/java/cc/mrbird/febs/gateway/runner/StartedUpRunner.java
  73. 7 23
      febs-gateway/src/main/resources/bootstrap.yml
  74. 0 1
      febs-gateway/src/main/resources/logback-spring.xml
  75. 2 2
      febs-monitor/febs-monitor-admin/Dockerfile
  76. 6 2
      febs-monitor/febs-monitor-admin/pom.xml
  77. 4 4
      febs-monitor/febs-monitor-admin/src/main/java/cc/mrbird/febs/monitor/admin/runner/StartedUpRunner.java
  78. 0 14
      febs-monitor/febs-monitor-admin/src/main/resources/application.yml
  79. 10 0
      febs-monitor/febs-monitor-admin/src/main/resources/bootstrap.yml
  80. 2 2
      febs-monitor/pom.xml
  81. 0 5
      febs-register/Dockerfile
  82. 0 42
      febs-register/pom.xml
  83. 0 4
      febs-register/run.sh
  84. 0 17
      febs-register/src/main/java/cc/mrbird/febs/register/FebsRegisterApplication.java
  85. 0 24
      febs-register/src/main/java/cc/mrbird/febs/register/configure/FebsRegisterWebSecurityConfigure.java
  86. 0 35
      febs-register/src/main/java/cc/mrbird/febs/register/runner/StartedUpRunner.java
  87. 0 8
      febs-register/src/main/resources/banner.txt
  88. 0 46
      febs-register/src/main/resources/bootstrap.yml
  89. 0 54
      febs-register/src/main/resources/logback-spring.xml
  90. 2 2
      febs-server/febs-server-system/Dockerfile
  91. 2 2
      febs-server/febs-server-system/pom.xml
  92. 36 0
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/aspect/AspectSupport.java
  93. 61 0
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/aspect/ControllerEndpointAspect.java
  94. 0 61
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/aspect/LogAspect.java
  95. 5 3
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/configure/FebsServerSystemResourceServerConfigure.java
  96. 4 2
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/configure/FebsWebConfigure.java
  97. 15 40
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/controller/DeptController.java
  98. 35 43
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/controller/EximportController.java
  99. 5 11
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/controller/GeneratorConfigController.java
  100. 30 37
      febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/controller/GeneratorController.java

+ 23 - 17
Readme.md

@@ -1,10 +1,11 @@
 ### FEBS Cloud 微服务权限系统
 ![https://img.shields.io/badge/license-Apache%202.0-blue.svg?longCache=true&style=flat-square](https://img.shields.io/badge/license-Apache%202.0-blue.svg?longCache=true&style=flat-square)
-![https://img.shields.io/badge/springcloud-Greenwich.SR1-yellow.svg?style=flat-square](https://img.shields.io/badge/springcloud-Greenwich.SR1-yellow.svg?style=flat-square)
-![https://img.shields.io/badge/springboot-2.1.6.RELEASE-brightgreen.svg?style=flat-square](https://img.shields.io/badge/springboot-2.1.6.RELEASE-brightgreen.svg?style=flat-square)
+![https://img.shields.io/badge/springcloud-Greenwich.SR3-yellow.svg?style=flat-square](https://img.shields.io/badge/springcloud-Greenwich.SR3-yellow.svg?style=flat-square)
+![https://img.shields.io/badge/SpringCloudAlibaba-0.9.0.RELEASE-blueviolet.svg?style=flat-square](https://img.shields.io/badge/SpringCloudAlibaba-0.9.0.RELEASE-blueviolet.svg?style=flat-square)
+![https://img.shields.io/badge/springboot-2.1.8.RELEASE-brightgreen.svg?style=flat-square](https://img.shields.io/badge/springboot-2.1.8.RELEASE-brightgreen.svg?style=flat-square)
 ![https://img.shields.io/badge/vue-2.6.10-orange.svg?style=flat-square](https://img.shields.io/badge/vue-2.6.10-orange.svg?style=flat-square)
 
-FEBS Cloud是一款使用Spring Cloud Greenwich.SR1、Spring Cloud OAuth2和Spring Cloud Security构建的权限管理系统,前端(FEBS Cloud Web)采用vue element admin构建。FEBS意指:**F**ast,**E**asy use,**B**eautiful和**S**afe。该系统具有如下特点:
+FEBS Cloud是一款使用Spring Cloud Greenwich.SR3、Spring Cloud OAuth2 & Spring Cloud Alibaba构建的低耦合权限管理系统,前端(FEBS Cloud Web)采用vue element admin构建。FEBS意指:**F**ast,**E**asy use,**B**eautiful和**S**afe。该系统具有如下特点:
 
 1. 前后端分离架构,客户端和服务端纯Token交互;
  
@@ -14,19 +15,27 @@ FEBS Cloud是一款使用Spring Cloud Greenwich.SR1、Spring Cloud OAuth2和Spri
 
 4. 集成Spring Boot Admin,多维度监控微服务;
 
-5. 集成Zipkin,方便跟踪Feign调用链
+5. 集成Spring Cloud Alibaba Nacos服务治理和集中配置管理
 
-6. 集成ELK,集中管理日志,便于问题分析
+6. 网关集成Sentinel流控
 
-7. 微服务Docker化,使用Docker Compose一键部署
+7. 集成Zipkin,方便跟踪Feign调用链
 
-8. 提供详细的使用文档和搭建教程
+8. 集成ELK,集中管理日志,便于问题分析
 
-9. 前后端请求参数校验,Excel导入导出,代码生成等。
+9. 微服务Docker化,使用Docker Compose一键部署;
+
+10. 提供详细的使用文档和搭建教程;
+
+11. 前后端请求参数校验,Excel导入导出,代码生成等。
 
 ### 文档与教程
 
-项目文档及手摸手搭建教程地址:[https://www.kancloud.cn/mrbird/spring-cloud/1263679](https://www.kancloud.cn/mrbird/spring-cloud/1263679)
+项目文档及**手摸手搭建教程**地址:[https://www.kancloud.cn/mrbird/spring-cloud/1263679](https://www.kancloud.cn/mrbird/spring-cloud/1263679)
+
+### 更新日志
+
+[https://www.kancloud.cn/mrbird/spring-cloud/1292659](https://www.kancloud.cn/mrbird/spring-cloud/1292659)
 
 ### 系统架构
 
@@ -65,19 +74,18 @@ FEBS模块:
 
 服务名称 | 端口 | 描述
 ---|---|---
-FEBS-Register| 8001 |微服务注册中心 
 FEBS-Auth| 8101| 微服务认证服务器 
 FEBS-Server-System| 8201 | 微服务子系统(资源服务器)
 FEBS-Server-Test|8202 | 微服务子系统(资源服务器)
 FEBS-Gateway|8301|微服务网关
 FEBS-Monitor-Admin|8401|微服务监控子系统
-Zipkin-Server|8402|Zipkin服务器
-FEBS-Config|8501|微服务配置子系统
 
 第三方模块:
 
 服务名称 | 端口 | 描述
 ---|---|---
+Nacos| 8001 |注册中心,配置中心 
+Zipkin-Server|8402|Zipkin服务器
 MySQL| 3306 |MySQL 数据库 
 RabbitMQ|5672|RabbitMQ 消息中间件 
 Redis| 6379 | K-V 缓存数据库 
@@ -89,17 +97,16 @@ Kibana|5601|日志展示
 ```
 ├─febs-auth                       ------ 微服务认证服务器
 ├─febs-cloud                      ------ 整个项目的父模块
+│  ├─sql                          ------ SQL脚本
 │  └─docker compose               ------ 存放docker compose文件
 │      ├─elk                      ------ ELK docker compose文件
 │      ├─febs-cloud               ------ 聚合所有微服务子项目的docker compose文件
 │      └─third-part               ------ 第三方服务(MySQL,Redis等)docker compose文件
 ├─febs-common                     ------ 通用模块
-├─febs-config                     ------ 微服务配置中心
 ├─febs-gateway                    ------ 微服务网关
 ├─febs-monitor                    ------ 微服务监控父模块
 │  ├─febs-monitor-admin           ------ 微服务监控中心
 │  └─zipkin-server                ------ zipkin 服务
-├─febs-register                   ------ 微服务注册中心
 └─febs-server                     ------ 资源服务器
    ├─febs-server-system           ------- 资源服务器系统模块
    └─febs-server-test             ------ 资源服务器demo,演示如何整合自己的微服务系统
@@ -120,12 +127,11 @@ Kibana|5601|日志展示
 
 ![7](images/7.png)
 
-![8](images/8.png)
-
 ### 参与贡献
-
 欢迎提交PR一起完善项目,以下为提PR并合并的小伙伴(排名不分先后):
 
+<a href="https://github.com/yuuki80code">
+    <img src="https://avatars1.githubusercontent.com/u/17798853?s=400&v=4" width="45px"></a>
 <a href="https://github.com/sonake">
     <img src="https://avatars3.githubusercontent.com/u/46209482?s=400&v=4" width="45px"></a>
 <a href="https://github.com/mgzu">

+ 2 - 2
febs-auth/Dockerfile

@@ -1,5 +1,5 @@
 FROM openjdk:8u212-jre
 MAINTAINER MrBird 852252810@qq.com
 
-COPY ./target/febs-auth-1.0-SNAPSHOT.jar /febs/febs-auth-1.0-SNAPSHOT.jar
-ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-auth-1.0-SNAPSHOT.jar"]
+COPY ./target/febs-auth-1.1-SNAPSHOT.jar /febs/febs-auth-1.1-SNAPSHOT.jar
+ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-auth-1.1-SNAPSHOT.jar"]

+ 3 - 3
febs-auth/pom.xml

@@ -5,12 +5,12 @@
     <parent>
         <groupId>cc.mrbird</groupId>
         <artifactId>febs-cloud</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1-SNAPSHOT</version>
         <relativePath>../febs-cloud/pom.xml</relativePath>
     </parent>
 
     <artifactId>febs-auth</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>1.1-SNAPSHOT</version>
     <name>FEBS-Auth</name>
     <description>FEBS-Cloud认证服务器</description>
 
@@ -18,7 +18,7 @@
         <dependency>
             <groupId>cc.mrbird</groupId>
             <artifactId>febs-common</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>1.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>com.baomidou</groupId>

+ 22 - 6
febs-auth/src/main/java/cc/mrbird/febs/auth/configure/FebsAuthorizationServerConfigurer.java

@@ -7,6 +7,7 @@ import cc.mrbird.febs.auth.translator.FebsWebResponseExceptionTranslator;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.crypto.password.PasswordEncoder;
@@ -15,8 +16,11 @@ import org.springframework.security.oauth2.config.annotation.configurers.ClientD
 import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
 import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
+import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter;
 import org.springframework.security.oauth2.provider.token.TokenStore;
 import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
 
 /**
  * 认证服务器配置
@@ -36,10 +40,6 @@ public class FebsAuthorizationServerConfigurer extends AuthorizationServerConfig
     @Autowired
     private FebsWebResponseExceptionTranslator exceptionTranslator;
     @Autowired
-    private TokenStore jwtTokenStore;
-    @Autowired
-    private JwtAccessTokenConverter jwtAccessTokenConverter;
-    @Autowired
     private FebsAuthProperties properties;
 
     @Override
@@ -68,11 +68,27 @@ public class FebsAuthorizationServerConfigurer extends AuthorizationServerConfig
     @Override
     @SuppressWarnings("unchecked")
     public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
-        endpoints.tokenStore(jwtTokenStore)
-                .accessTokenConverter(jwtAccessTokenConverter)
+        endpoints.tokenStore(jwtTokenStore())
+                .accessTokenConverter(jwtAccessTokenConverter())
                 .userDetailsService(userDetailService)
                 .authenticationManager(authenticationManager)
                 .exceptionTranslator(exceptionTranslator);
     }
 
+    @Bean
+    public TokenStore jwtTokenStore() {
+        return new JwtTokenStore(jwtAccessTokenConverter());
+    }
+
+    @Bean
+    public JwtAccessTokenConverter jwtAccessTokenConverter() {
+        JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
+        DefaultAccessTokenConverter defaultAccessTokenConverter = (DefaultAccessTokenConverter) accessTokenConverter.getAccessTokenConverter();
+        DefaultUserAuthenticationConverter userAuthenticationConverter = new DefaultUserAuthenticationConverter();
+        userAuthenticationConverter.setUserDetailsService(userDetailService);
+        defaultAccessTokenConverter.setUserTokenConverter(userAuthenticationConverter);
+        accessTokenConverter.setSigningKey(properties.getJwtAccessKey());
+        return accessTokenConverter;
+    }
+
 }

+ 3 - 2
febs-auth/src/main/java/cc/mrbird/febs/auth/configure/FebsResourceServerConfigurer.java

@@ -1,6 +1,7 @@
 package cc.mrbird.febs.auth.configure;
 
 import cc.mrbird.febs.auth.properties.FebsAuthProperties;
+import cc.mrbird.febs.common.entity.constant.EndpointConstant;
 import cc.mrbird.febs.common.handler.FebsAccessDeniedHandler;
 import cc.mrbird.febs.common.handler.FebsAuthExceptionEntryPoint;
 import org.apache.commons.lang3.StringUtils;
@@ -32,11 +33,11 @@ public class FebsResourceServerConfigurer extends ResourceServerConfigurerAdapte
         String[] anonUrls = StringUtils.splitByWholeSeparatorPreserveAllTokens(properties.getAnonUrl(), ",");
 
         http.csrf().disable()
-                .requestMatchers().antMatchers("/**")
+                .requestMatchers().antMatchers(EndpointConstant.ALL)
                 .and()
                 .authorizeRequests()
                 .antMatchers(anonUrls).permitAll()
-                .antMatchers("/**").authenticated()
+                .antMatchers(EndpointConstant.ALL).authenticated()
                 .and().httpBasic();
     }
 

+ 3 - 2
febs-auth/src/main/java/cc/mrbird/febs/auth/configure/FebsSecurityConfigure.java

@@ -2,6 +2,7 @@ package cc.mrbird.febs.auth.configure;
 
 import cc.mrbird.febs.auth.filter.ValidateCodeFilter;
 import cc.mrbird.febs.auth.service.FebsUserDetailService;
+import cc.mrbird.febs.common.entity.constant.EndpointConstant;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.core.annotation.Order;
@@ -38,10 +39,10 @@ public class FebsSecurityConfigure extends WebSecurityConfigurerAdapter {
     protected void configure(HttpSecurity http) throws Exception {
         http.addFilterBefore(validateCodeFilter, UsernamePasswordAuthenticationFilter.class)
                 .requestMatchers()
-                .antMatchers("/oauth/**")
+                .antMatchers(EndpointConstant.OAUTH_ALL)
                 .and()
                 .authorizeRequests()
-                .antMatchers("/oauth/**").authenticated()
+                .antMatchers(EndpointConstant.OAUTH_ALL).authenticated()
                 .and()
                 .csrf().disable();
     }

+ 0 - 25
febs-auth/src/main/java/cc/mrbird/febs/auth/configure/JWTConfigure.java

@@ -1,25 +0,0 @@
-package cc.mrbird.febs.auth.configure;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
-import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
-
-/**
- * @author MrBird
- */
-@Configuration
-public class JWTConfigure {
-    @Bean
-    public TokenStore jwtTokenStore() {
-        return new JwtTokenStore(jwtAccessTokenConverter());
-    }
-
-    @Bean
-    public JwtAccessTokenConverter jwtAccessTokenConverter() {
-        JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
-        accessTokenConverter.setSigningKey("febs");
-        return accessTokenConverter;
-    }
-}

+ 0 - 10
febs-auth/src/main/java/cc/mrbird/febs/auth/controller/SecurityController.java

@@ -2,8 +2,6 @@ package cc.mrbird.febs.auth.controller;
 
 import cc.mrbird.febs.auth.manager.UserManager;
 import cc.mrbird.febs.auth.service.ValidateCodeService;
-import cc.mrbird.febs.common.entity.FebsResponse;
-import cc.mrbird.febs.common.entity.system.SystemUser;
 import cc.mrbird.febs.common.exception.ValidateCodeException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -30,16 +28,8 @@ public class SecurityController {
         return principal;
     }
 
-    @GetMapping("user/detail")
-    public FebsResponse currentUserDetail(Principal principal) {
-        SystemUser user = userManager.findByName(principal.getName());
-        user.setPassword("secret");
-        return new FebsResponse().data(user);
-    }
-
     @GetMapping("captcha")
     public void captcha(HttpServletRequest request, HttpServletResponse response) throws IOException, ValidateCodeException {
         validateCodeService.create(request, response);
     }
-
 }

+ 7 - 5
febs-auth/src/main/java/cc/mrbird/febs/auth/filter/ValidateCodeFilter.java

@@ -2,6 +2,9 @@ package cc.mrbird.febs.auth.filter;
 
 import cc.mrbird.febs.auth.service.ValidateCodeService;
 import cc.mrbird.febs.common.entity.FebsResponse;
+import cc.mrbird.febs.common.entity.constant.EndpointConstant;
+import cc.mrbird.febs.common.entity.constant.GrantTypeConstant;
+import cc.mrbird.febs.common.entity.constant.ParamsConstant;
 import cc.mrbird.febs.common.exception.ValidateCodeException;
 import cc.mrbird.febs.common.utils.FebsUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -41,9 +44,9 @@ public class ValidateCodeFilter extends OncePerRequestFilter {
         String header = httpServletRequest.getHeader(HttpHeaders.AUTHORIZATION);
         String clientId = getClientId(header, httpServletRequest);
 
-        RequestMatcher matcher = new AntPathRequestMatcher("/oauth/token", HttpMethod.POST.toString());
+        RequestMatcher matcher = new AntPathRequestMatcher(EndpointConstant.OAUTH_TOKEN, HttpMethod.POST.toString());
         if (matcher.matches(httpServletRequest)
-                && StringUtils.equalsIgnoreCase(httpServletRequest.getParameter("grant_type"), "password")
+                && StringUtils.equalsIgnoreCase(httpServletRequest.getParameter(ParamsConstant.GRANT_TYPE), GrantTypeConstant.PASSWORD)
                 && !StringUtils.equalsAnyIgnoreCase(clientId, "swagger")) {
             try {
                 validateCode(httpServletRequest);
@@ -60,8 +63,8 @@ public class ValidateCodeFilter extends OncePerRequestFilter {
     }
 
     private void validateCode(HttpServletRequest httpServletRequest) throws ValidateCodeException {
-        String code = httpServletRequest.getParameter("code");
-        String key = httpServletRequest.getParameter("key");
+        String code = httpServletRequest.getParameter(ParamsConstant.VALIDATE_CODE_CODE);
+        String key = httpServletRequest.getParameter(ParamsConstant.VALIDATE_CODE_KEY);
         validateCodeService.check(key, code);
     }
 
@@ -71,7 +74,6 @@ public class ValidateCodeFilter extends OncePerRequestFilter {
             byte[] base64Token = header.substring(6).getBytes(StandardCharsets.UTF_8);
             byte[] decoded;
             decoded = Base64.getDecoder().decode(base64Token);
-
             String token = new String(decoded, StandardCharsets.UTF_8);
             int delim = token.indexOf(":");
             if (delim != -1) {

+ 4 - 0
febs-auth/src/main/java/cc/mrbird/febs/auth/properties/FebsAuthProperties.java

@@ -26,4 +26,8 @@ public class FebsAuthProperties {
      * 验证码配置
      */
     private FebsValidateCodeProperties code = new FebsValidateCodeProperties();
+    /**
+     * JWT加签密钥
+     */
+    private String jwtAccessKey;
 }

+ 2 - 2
febs-auth/src/main/java/cc/mrbird/febs/auth/properties/FebsClientsProperties.java

@@ -18,11 +18,11 @@ public class FebsClientsProperties {
     /**
      * 认证类型
      */
-    private String grantType = "password,authorization_code,refresh_token";
+    private String grantType;
     /**
      * 范围
      */
-    private String scope = "all";
+    private String scope;
     /**
      * 访问令牌有效时间,单位秒
      */

+ 2 - 1
febs-auth/src/main/java/cc/mrbird/febs/auth/properties/FebsValidateCodeProperties.java

@@ -1,5 +1,6 @@
 package cc.mrbird.febs.auth.properties;
 
+import cc.mrbird.febs.common.entity.constant.ImageTypeConstant;
 import lombok.Data;
 
 /**
@@ -15,7 +16,7 @@ public class FebsValidateCodeProperties {
     /**
      * 验证码类型,可选值 png和 gif
      */
-    private String type = "png";
+    private String type = ImageTypeConstant.PNG;
     /**
      * 图片宽度,px
      */

+ 5 - 5
febs-auth/src/main/java/cc/mrbird/febs/auth/runner/StartedUpRunner.java

@@ -1,6 +1,6 @@
 package cc.mrbird.febs.auth.runner;
 
-import cc.mrbird.febs.common.entity.FebsServerConstant;
+import cc.mrbird.febs.common.entity.constant.FebsServerConstant;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -24,10 +24,10 @@ public class StartedUpRunner implements ApplicationRunner {
     @Override
     public void run(ApplicationArguments args) {
         if (context.isActive()) {
-            log.info(" __    ___   _      ___   _     ____ _____  ____ ");
-            log.info("/ /`  / / \\ | |\\/| | |_) | |   | |_   | |  | |_  ");
-            log.info("\\_\\_, \\_\\_/ |_|  | |_|   |_|__ |_|__  |_|  |_|__ ");
-            log.info("                                                      ");
+            log.info("  _   _   _   _   _   _   _   _");
+            log.info(" / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\");
+            log.info("( c | o | m | p | l | e | t | e )");
+            log.info(" \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/");
             log.info("{} 启动完毕,时间:{}", applicationName, LocalDateTime.now());
         }
     }

+ 1 - 1
febs-auth/src/main/java/cc/mrbird/febs/auth/service/FebsUserDetailService.java

@@ -35,7 +35,7 @@ public class FebsUserDetailService implements UserDetailsService {
             FebsAuthUser authUser = new FebsAuthUser(systemUser.getUsername(), systemUser.getPassword(), true, true, true, notLocked,
                     AuthorityUtils.commaSeparatedStringToAuthorityList(permissions));
 
-            BeanUtils.copyProperties(systemUser,authUser);
+            BeanUtils.copyProperties(systemUser, authUser);
             return authUser;
         } else {
             throw new UsernameNotFoundException("");

+ 6 - 4
febs-auth/src/main/java/cc/mrbird/febs/auth/service/ValidateCodeService.java

@@ -2,7 +2,9 @@ package cc.mrbird.febs.auth.service;
 
 import cc.mrbird.febs.auth.properties.FebsAuthProperties;
 import cc.mrbird.febs.auth.properties.FebsValidateCodeProperties;
-import cc.mrbird.febs.common.entity.FebsConstant;
+import cc.mrbird.febs.common.entity.constant.FebsConstant;
+import cc.mrbird.febs.common.entity.constant.ImageTypeConstant;
+import cc.mrbird.febs.common.entity.constant.ParamsConstant;
 import cc.mrbird.febs.common.exception.ValidateCodeException;
 import cc.mrbird.febs.common.service.RedisService;
 import com.wf.captcha.GifCaptcha;
@@ -38,7 +40,7 @@ public class ValidateCodeService {
      * @param response HttpServletResponse
      */
     public void create(HttpServletRequest request, HttpServletResponse response) throws IOException, ValidateCodeException {
-        String key = request.getParameter("key");
+        String key = request.getParameter(ParamsConstant.VALIDATE_CODE_KEY);
         if (StringUtils.isBlank(key)) {
             throw new ValidateCodeException("验证码key不能为空");
         }
@@ -71,7 +73,7 @@ public class ValidateCodeService {
 
     private Captcha createCaptcha(FebsValidateCodeProperties code) {
         Captcha captcha = null;
-        if (StringUtils.equalsIgnoreCase(code.getType(), FebsConstant.GIF)) {
+        if (StringUtils.equalsIgnoreCase(code.getType(), ImageTypeConstant.GIF)) {
             captcha = new GifCaptcha(code.getWidth(), code.getHeight(), code.getLength());
         } else {
             captcha = new SpecCaptcha(code.getWidth(), code.getHeight(), code.getLength());
@@ -81,7 +83,7 @@ public class ValidateCodeService {
     }
 
     private void setHeader(HttpServletResponse response, String type) {
-        if (StringUtils.equalsIgnoreCase(type, FebsConstant.GIF)) {
+        if (StringUtils.equalsIgnoreCase(type, ImageTypeConstant.GIF)) {
             response.setContentType(MediaType.IMAGE_GIF_VALUE);
         } else {
             response.setContentType(MediaType.IMAGE_PNG_VALUE);

+ 9 - 21
febs-auth/src/main/resources/bootstrap.yml

@@ -1,26 +1,14 @@
-server:
-  port: 8101
 spring:
   application:
     name: FEBS-Auth
-  cloud:
-    config:
-      fail-fast: true
-      name: ${spring.application.name}
-      profile: ${spring.profiles.active}
-      discovery:
-        enabled: true
-        service-id: FEBS-Config
   profiles:
     active: dev
-
-eureka:
-  instance:
-    lease-renewal-interval-in-seconds: 20
-  client:
-    register-with-eureka: true
-    fetch-registry: true
-    instance-info-replication-interval-seconds: 30
-    registry-fetch-interval-seconds: 3
-    serviceUrl:
-      defaultZone: http://febs:123456@${febs-register}:8001/register/eureka/
+  cloud:
+    nacos:
+      config:
+        server-addr: ${nacos.url}:8001
+        group: DEFAULT_GROUP
+        prefix: febs-auth
+        file-extension: yaml
+      discovery:
+        server-addr: ${nacos.url}:8001

+ 1 - 0
febs-auth/src/main/resources/febs-auth.properties

@@ -12,6 +12,7 @@ febs.auth.clients[1].scope=test
 febs.auth.clients[1].accessTokenValiditySeconds=3600
 
 febs.auth.anonUrl=/actuator/**,/captcha
+febs.auth.jwtAccessKey=febs
 
 febs.auth.code.time=120
 febs.auth.code.type=png

+ 11 - 47
febs-cloud/docker compose/febs-cloud/docker-compose.yml

@@ -1,30 +1,6 @@
 version: '3'
 
 services:
-  febs-register:
-    image: febs-register:latest
-    container_name: febs-register
-    volumes:
-      - "/febs/log:/log"
-    command:
-      - "--febs-monitor-admin=127.0.0.1"
-      - "--febs-register=127.0.0.1"
-    ports:
-      - 8001:8001
-    restart: always
-  febs-config:
-    image: febs-config:latest
-    container_name: febs-config
-    depends_on:
-      - febs-register
-    volumes:
-      - "/febs/log:/log"
-    command:
-      - "--febs-monitor-admin=127.0.0.1"
-      - "--febs-register=127.0.0.1"
-    ports:
-      - 8501:8501
-    restart: always
   febs-monitor-admin:
     image: febs-monitor-admin:latest
     container_name: febs-monitor-admin
@@ -32,66 +8,54 @@ services:
       - "/febs/log:/log"
     ports:
       - 8401:8401
-    restart: always
+    restart: on-failure
   febs-gateway:
     image: febs-gateway:latest
     container_name: febs-gateway
-    depends_on:
-      - febs-config
-      - febs-register
     volumes:
       - "/febs/log:/log"
     command:
       - "--febs-monitor-admin=127.0.0.1"
-      - "--febs-register=127.0.0.1"
+      - "--nacos.url=127.0.0.1"
     ports:
       - 8301:8301
-    restart: always
+    restart: on-failure
   febs-auth:
     image: febs-auth:latest
     container_name: febs-auth
-    depends_on:
-      - febs-config
-      - febs-register
     volumes:
       - "/febs/log:/log"
     command:
       - "--febs-monitor-admin=127.0.0.1"
-      - "--febs-register=127.0.0.1"
+      - "--nacos.url=127.0.0.1"
       - "--mysql.url=127.0.0.1"
       - "--redis.url=127.0.0.1"
       - "--spring.profiles.active=prod"
-    restart: always
+    restart: on-failure
   febs-server-system:
     image: febs-server-system:latest
     container_name: febs-server-system
-    depends_on:
-      - febs-register
-      - febs-config
     volumes:
       - "/febs/log:/log"
     command:
       - "--febs-monitor-admin=127.0.0.1"
-      - "--febs-register=127.0.0.1"
       - "--febs-gateway=127.0.0.1"
+      - "--nacos.url=127.0.0.1"
       - "--mysql.url=127.0.0.1"
       - "--rabbitmq.url=127.0.0.1"
       - "--spring.profiles.active=prod"
-    restart: always
+    restart: on-failure
   febs-server-test:
     image: febs-server-test:latest
     container_name: febs-server-test
-    depends_on:
-      - febs-config
-      - febs-register
     volumes:
       - "/febs/log:/log"
     command:
       - "--rabbitmq.url=127.0.0.1"
+      - "--nacos.url=127.0.0.1"
       - "--febs-monitor-admin=127.0.0.1"
-      - "--febs-register=127.0.0.1"
       - "--febs-gateway=127.0.0.1"
-    restart: always
+    restart: on-failure
   zipkin-server:
     image: zipkin-server
     container_name: zipkin-server
@@ -108,7 +72,7 @@ services:
       - "--zipkin.collector.rabbitmq.password=123456"
     ports:
       - 8402:8402
-    restart: always
+    restart: on-failure
   febs-clou-web:
     image: febs-cloud-web
     container_name: febs-cloud-web
@@ -116,4 +80,4 @@ services:
       - "/febs/log:/log"
     ports:
       - 9527:80
-    restart: always
+    restart: on-failure

+ 23 - 0
febs-cloud/docker compose/nacos/docker-compose.yml

@@ -0,0 +1,23 @@
+version: '3'
+
+services:
+  nacos:
+    image: nacos/nacos-server:latest
+    container_name: nacos-standalone-mysql
+    environment:
+      - "PREFER_HOST_MODE=hostname"
+      - "MODE=standalone"
+      - "SPRING_DATASOURCE_PLATFORM=mysql"
+      - "MYSQL_MASTER_SERVICE_HOST=127.0.0.1"
+      - "MYSQL_MASTER_SERVICE_DB_NAME=febs_nacos"
+      - "MYSQL_MASTER_SERVICE_PORT=3306"
+      - "MYSQL_MASTER_SERVICE_USER=root"
+      - "MYSQL_MASTER_SERVICE_PASSWORD=123456"
+      - "MYSQL_SLAVE_SERVICE_HOST=127.0.0.1"
+      - "MYSQL_SLAVE_SERVICE_PORT=3306"
+    volumes:
+      - /febs/nacos/standalone-logs/:/home/nacos/logs
+      - /febs/nacos/custom.properties:/home/nacos/init.d/custom.properties
+    ports:
+      - 8001:8848
+    restart: on-failure

+ 11 - 5
febs-cloud/pom.xml

@@ -6,32 +6,31 @@
 
     <groupId>cc.mrbird</groupId>
     <artifactId>febs-cloud</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>1.1-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <name>FEBS-Cloud</name>
     <description>FEBS-Cloud:Spring Cloud,Spring Security OAuth2 微服务权限管理系统</description>
 
     <modules>
-        <module>../febs-register</module>
         <module>../febs-auth</module>
         <module>../febs-common</module>
         <module>../febs-server</module>
         <module>../febs-gateway</module>
         <module>../febs-monitor</module>
-        <module>../febs-config</module>
     </modules>
 
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.1.6.RELEASE</version>
+        <version>2.1.8.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
 
     <properties>
         <java.version>1.8</java.version>
-        <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
+        <spring-cloud.version>Greenwich.SR3</spring-cloud.version>
+        <spring-cloud-alibaba.version>0.9.0.RELEASE</spring-cloud-alibaba.version>
     </properties>
 
     <dependencyManagement>
@@ -43,6 +42,13 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
+                <version>${spring-cloud-alibaba.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

+ 1 - 1
sql/febs_cloud_base.sql → febs-cloud/sql/febs_cloud_base.sql

@@ -169,7 +169,7 @@ INSERT INTO `t_menu` VALUES (133, 6, '导出Excel', NULL, NULL, 'dept:export', N
 INSERT INTO `t_menu` VALUES (135, 3, '密码重置', NULL, NULL, 'user:reset', NULL, '1', NULL, '2019-01-23 06:37:00', NULL);
 INSERT INTO `t_menu` VALUES (136, 10, '导出Excel', NULL, NULL, 'log:export', NULL, '1', NULL, '2019-01-23 06:37:27', NULL);
 INSERT INTO `t_menu` VALUES (148, 2, '监控中心', '/monitor/admin', 'febs/monitor/admin/Index', 'mobitor:admin', '', '0', 6, '2019-07-20 19:42:07', '2019-09-01 10:48:12');
-INSERT INTO `t_menu` VALUES (149, 2, '注册中心', '/monitor/register', 'febs/monitor/register/Index', 'monitor:register', '', '0', 3, '2019-07-20 20:07:00', '2019-07-22 20:22:43');
+INSERT INTO `t_menu` VALUES (149, 2, '注册中心', 'http://localhost:8001/nacos', 'Layout', 'monitor:register', '', '0', 3, '2019-07-20 20:07:00', '2019-07-22 20:22:43');
 INSERT INTO `t_menu` VALUES (150, 2, '登录日志', '/monitor/loginlog', 'febs/monitor/loginlog/Index', 'monitor:loginlog', '', '0', 2, '2019-07-22 13:41:17', '2019-07-22 20:22:35');
 INSERT INTO `t_menu` VALUES (151, 150, '删除日志', NULL, NULL, 'loginlog:delete', NULL, '1', NULL, '2019-07-22 13:43:04', NULL);
 INSERT INTO `t_menu` VALUES (152, 150, '导出Excel', NULL, NULL, 'loginlog:export', NULL, '1', NULL, '2019-07-22 13:43:30', NULL);

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 52 - 0
febs-cloud/sql/febs_nacos.sql


+ 0 - 0
sql/zipkin.sql → febs-cloud/sql/zipkin.sql


+ 6 - 6
febs-common/pom.xml

@@ -5,12 +5,12 @@
     <parent>
         <groupId>cc.mrbird</groupId>
         <artifactId>febs-cloud</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1-SNAPSHOT</version>
         <relativePath>../febs-cloud/pom.xml</relativePath>
     </parent>
 
     <artifactId>febs-common</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>1.1-SNAPSHOT</version>
     <name>FEBS-Common</name>
     <description>FEBS-Common通用模块</description>
 
@@ -22,7 +22,7 @@
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>fastjson</artifactId>
-            <version>1.2.51</version>
+            <version>1.2.60</version>
         </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
@@ -45,7 +45,7 @@
         <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
-            <version>3.1.1</version>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
@@ -57,11 +57,11 @@
         </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
         </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-config-client</artifactId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
         </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>

+ 7 - 2
febs-common/src/main/java/cc/mrbird/febs/common/annotation/Log.java → febs-common/src/main/java/cc/mrbird/febs/common/annotation/ControllerEndpoint.java

@@ -5,8 +5,13 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+/**
+ * @author MrBird
+ */
 @Target(ElementType.METHOD)
 @Retention(RetentionPolicy.RUNTIME)
-public @interface Log {
-    String value() default "";
+public @interface ControllerEndpoint {
+
+    String operation() default "";
+    String exceptionMessage() default "FEBS系统内部异常";
 }

+ 5 - 5
febs-common/src/main/java/cc/mrbird/febs/common/configure/FebsOAuth2FeignConfigure.java

@@ -1,6 +1,6 @@
 package cc.mrbird.febs.common.configure;
 
-import cc.mrbird.febs.common.entity.FebsConstant;
+import cc.mrbird.febs.common.entity.constant.FebsConstant;
 import com.google.common.net.HttpHeaders;
 import feign.RequestInterceptor;
 import org.springframework.context.annotation.Bean;
@@ -18,14 +18,14 @@ public class FebsOAuth2FeignConfigure {
     @Bean
     public RequestInterceptor oauth2FeignRequestInterceptor() {
         return requestTemplate -> {
-            // 请求头中添加 Zuul Token
-            String zuulToken = new String(Base64Utils.encode(FebsConstant.ZUUL_TOKEN_VALUE.getBytes()));
-            requestTemplate.header(FebsConstant.ZUUL_TOKEN_HEADER, zuulToken);
+            // 请求头中添加 Gateway Token
+            String zuulToken = new String(Base64Utils.encode(FebsConstant.GATEWAY_TOKEN_VALUE.getBytes()));
+            requestTemplate.header(FebsConstant.GATEWAY_TOKEN_HEADER, zuulToken);
             // 请求头中添加原请求头中的 Token
             Object details = SecurityContextHolder.getContext().getAuthentication().getDetails();
             if (details instanceof OAuth2AuthenticationDetails) {
                 String authorizationToken = ((OAuth2AuthenticationDetails) details).getTokenValue();
-                requestTemplate.header(HttpHeaders.AUTHORIZATION, "bearer " + authorizationToken);
+                requestTemplate.header(HttpHeaders.AUTHORIZATION, FebsConstant.OAUTH2_TOKEN_TYPE + authorizationToken);
             }
         };
     }

+ 0 - 45
febs-common/src/main/java/cc/mrbird/febs/common/entity/FebsConstant.java

@@ -1,45 +0,0 @@
-package cc.mrbird.febs.common.entity;
-
-/**
- * @author MrBird
- */
-public class FebsConstant {
-
-    /**
-     * 排序规则:降序
-     */
-    public static final String ORDER_DESC = "descending";
-    /**
-     * 排序规则:升序
-     */
-    public static final String ORDER_ASC = "ascending";
-
-    /**
-     * Zuul请求头TOKEN名称(不要有空格)
-     */
-    public static final String ZUUL_TOKEN_HEADER = "ZuulToken";
-    /**
-     * Zuul请求头TOKEN值
-     */
-    public static final String ZUUL_TOKEN_VALUE = "febs:zuul:123456";
-
-    /**
-     * 允许下载的文件类型,根据需求自己添加(小写)
-     */
-    public static final String[] VALID_FILE_TYPE = {"xlsx", "zip"};
-
-    /**
-     * gif类型
-     */
-    public static final String GIF = "gif";
-    /**
-     * png类型
-     */
-    public static final String PNG = "png";
-
-    /**
-     * 验证码 key前缀
-     */
-    public static final String CODE_PREFIX = "febs.captcha.";
-
-}

+ 25 - 0
febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/EndpointConstant.java

@@ -0,0 +1,25 @@
+package cc.mrbird.febs.common.entity.constant;
+
+/**
+ * 端点常量
+ *
+ * @author MrBird
+ */
+public class EndpointConstant {
+
+    public static final String ALL = "/**";
+
+    public static final String OAUTH_ALL = "/oauth/**";
+
+    public static final String OAUTH_AUTHORIZE = "/oauth/authorize";
+
+    public static final String OAUTH_CHECK_TOKEN = "/oauth/check_token";
+
+    public static final String OAUTH_CONFIRM_ACCESS = "/oauth/confirm_access";
+
+    public static final String OAUTH_TOKEN = "/oauth/token";
+
+    public static final String OAUTH_TOKEN_KEY = "/oauth/token_key";
+
+    public static final String OAUTH_ERROR = "/oauth/error";
+}

+ 56 - 0
febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/FebsConstant.java

@@ -0,0 +1,56 @@
+package cc.mrbird.febs.common.entity.constant;
+
+/**
+ * FEBS系统常量类
+ *
+ * @author MrBird
+ */
+public class FebsConstant {
+
+    /**
+     * 排序规则:降序
+     */
+    public static final String ORDER_DESC = "descending";
+    /**
+     * 排序规则:升序
+     */
+    public static final String ORDER_ASC = "ascending";
+
+    /**
+     * Gateway请求头TOKEN名称(不要有空格)
+     */
+    public static final String GATEWAY_TOKEN_HEADER = "GatewayToken";
+    /**
+     * Gateway请求头TOKEN值
+     */
+    public static final String GATEWAY_TOKEN_VALUE = "febs:gateway:123456";
+
+    /**
+     * 允许下载的文件类型,根据需求自己添加(小写)
+     */
+    public static final String[] VALID_FILE_TYPE = {"xlsx", "zip"};
+
+    /**
+     * 验证码 key前缀
+     */
+    public static final String CODE_PREFIX = "febs.captcha.";
+
+    /**
+     * 异步线程池名称
+     */
+    public static final String ASYNC_POOL = "febsAsyncThreadPool";
+
+    /**
+     * OAUTH2 令牌类型 https://oauth.net/2/bearer-tokens/
+     */
+    public static final String OAUTH2_TOKEN_TYPE = "bearer";
+    /**
+     * Java默认临时目录
+     */
+    public static final String JAVA_TEMP_DIR = "java.io.tmpdir";
+    /**
+     * utf-8
+     */
+    public static final String UTF8 = "utf-8";
+
+}

+ 1 - 2
febs-common/src/main/java/cc/mrbird/febs/common/entity/FebsServerConstant.java → febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/FebsServerConstant.java

@@ -1,4 +1,4 @@
-package cc.mrbird.febs.common.entity;
+package cc.mrbird.febs.common.entity.constant;
 
 /**
  * @author MrBird
@@ -11,7 +11,6 @@ public class FebsServerConstant {
     public static final String FEBS_GATEWAY = "FEBS-Gateway";
     public static final String FEBS_MONITOR = "FEBS-Monitor";
     public static final String FEBS_MONITOR_ADMIN = "FEBS-Monitor_Admin";
-    public static final String FEBS_REGISTER = "FEBS-Register";
     public static final String FEBS_SERVER = "FEBS-Server";
     public static final String FEBS_SERVER_SYSTEM= "FEBS-Server-System";
     public static final String FEBS_SERVER_TEST= "FEBS-Server-Test";

+ 1 - 1
febs-common/src/main/java/cc/mrbird/febs/common/entity/system/GeneratorConstant.java → febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/GeneratorConstant.java

@@ -1,4 +1,4 @@
-package cc.mrbird.febs.common.entity.system;
+package cc.mrbird.febs.common.entity.constant;
 
 /**
  * 代码生成常量

+ 30 - 0
febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/GrantTypeConstant.java

@@ -0,0 +1,30 @@
+package cc.mrbird.febs.common.entity.constant;
+
+/**
+ * 认证类型常量类
+ *
+ * @author MrBird
+ */
+public class GrantTypeConstant {
+
+    /**
+     * 刷新模式
+     */
+    public static final String REFRESH_TOKEN = "refresh_token";
+    /**
+     * 授权码模式
+     */
+    public static final String AUTHORIZATION_CODE = "authorization_code";
+    /**
+     * 客户端模式
+     */
+    public static final String CLIENT_CREDENTIALS = "client_credentials";
+    /**
+     * 密码模式
+     */
+    public static final String PASSWORD = "password";
+    /**
+     * 简化模式
+     */
+    public static final String IMPLICIT = "implicit";
+}

+ 18 - 0
febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/ImageTypeConstant.java

@@ -0,0 +1,18 @@
+package cc.mrbird.febs.common.entity.constant;
+
+/**
+ * 图片类型常量类
+ *
+ * @author MrBird
+ */
+public class ImageTypeConstant {
+
+    /**
+     * gif类型
+     */
+    public static final String GIF = "gif";
+    /**
+     * png类型
+     */
+    public static final String PNG = "png";
+}

+ 23 - 0
febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/ParamsConstant.java

@@ -0,0 +1,23 @@
+package cc.mrbird.febs.common.entity.constant;
+
+/**
+ * 请求参数常量
+ *
+ * @author MrBird
+ */
+public class ParamsConstant {
+
+    /**
+     * 验证码 key
+     */
+    public static final String VALIDATE_CODE_KEY = "key";
+    /**
+     * 验证码 code
+     */
+    public static final String VALIDATE_CODE_CODE = "code";
+    /**
+     * 认证类型参数 key
+     */
+    public static final String GRANT_TYPE = "grant_type";
+
+}

+ 1 - 1
febs-common/src/main/java/cc/mrbird/febs/common/entity/RegexpConstant.java → febs-common/src/main/java/cc/mrbird/febs/common/entity/constant/RegexpConstant.java

@@ -1,4 +1,4 @@
-package cc.mrbird.febs.common.entity;
+package cc.mrbird.febs.common.entity.constant;
 
 /**
  * 正则常量

+ 5 - 5
febs-common/src/main/java/cc/mrbird/febs/common/interceptor/FebsServerProtectInterceptor.java

@@ -1,6 +1,6 @@
 package cc.mrbird.febs.common.interceptor;
 
-import cc.mrbird.febs.common.entity.FebsConstant;
+import cc.mrbird.febs.common.entity.constant.FebsConstant;
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.utils.FebsUtil;
 import org.apache.commons.lang3.StringUtils;
@@ -19,10 +19,10 @@ public class FebsServerProtectInterceptor implements HandlerInterceptor {
 
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
-        // 从请求头中获取 Zuul Token
-        String token = request.getHeader(FebsConstant.ZUUL_TOKEN_HEADER);
-        String zuulToken = new String(Base64Utils.encode(FebsConstant.ZUUL_TOKEN_VALUE.getBytes()));
-        // 校验 Zuul Token的正确性
+        // 从请求头中获取 Gateway Token
+        String token = request.getHeader(FebsConstant.GATEWAY_TOKEN_HEADER);
+        String zuulToken = new String(Base64Utils.encode(FebsConstant.GATEWAY_TOKEN_VALUE.getBytes()));
+        // 校验 Gateway Token的正确性
         if (StringUtils.equals(zuulToken, token)) {
             return true;
         } else {

+ 1 - 0
febs-common/src/main/java/cc/mrbird/febs/common/selector/FebsCloudApplicationSelector.java

@@ -14,6 +14,7 @@ import javax.annotation.Nonnull;
 public class FebsCloudApplicationSelector implements ImportSelector {
 
     @Override
+    @SuppressWarnings("all")
     public String[] selectImports(@Nonnull AnnotationMetadata annotationMetadata) {
         return new String[]{
                 FebsAuthExceptionConfigure.class.getName(),

+ 12 - 0
febs-common/src/main/java/cc/mrbird/febs/common/utils/FebsUtil.java

@@ -111,4 +111,16 @@ public class FebsUtil {
         data.put("total", pageInfo.getTotal());
         return data;
     }
+
+    /**
+     * 判断是否包含中文
+     *
+     * @param value 内容
+     * @return 结果
+     */
+    public static boolean containChinese(String value) {
+        Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
+        Matcher m = p.matcher(value);
+        return m.find();
+    }
 }

+ 3 - 3
febs-common/src/main/java/cc/mrbird/febs/common/utils/FileUtil.java

@@ -1,6 +1,6 @@
 package cc.mrbird.febs.common.utils;
 
-import cc.mrbird.febs.common.entity.FebsConstant;
+import cc.mrbird.febs.common.entity.constant.FebsConstant;
 import com.google.common.base.Preconditions;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ArrayUtils;
@@ -64,9 +64,9 @@ public class FileUtil {
         if (!fileTypeIsValid(fileType)) {
             throw new Exception("暂不支持该类型文件下载");
         }
-        response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;fileName=" + java.net.URLEncoder.encode(fileName, "utf-8"));
+        response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;fileName=" + java.net.URLEncoder.encode(fileName, FebsConstant.UTF8));
         response.setContentType(MediaType.MULTIPART_FORM_DATA_VALUE);
-        response.setCharacterEncoding("utf-8");
+        response.setCharacterEncoding(FebsConstant.UTF8);
         try (InputStream inputStream = new FileInputStream(file); OutputStream os = response.getOutputStream()) {
             byte[] b = new byte[2048];
             int length;

+ 1 - 3
febs-common/src/main/java/cc/mrbird/febs/common/utils/IPUtil.java → febs-common/src/main/java/cc/mrbird/febs/common/utils/ServletRequestIPUtil.java

@@ -1,13 +1,11 @@
 package cc.mrbird.febs.common.utils;
 
-import org.springframework.http.HttpHeaders;
-
 import javax.servlet.http.HttpServletRequest;
 
 /**
  * @author MrBird
  */
-public class IPUtil {
+public class ServletRequestIPUtil {
 
 	private static final String UNKNOWN = "unknown";
 

+ 6 - 5
febs-common/src/main/java/cc/mrbird/febs/common/utils/SortUtil.java

@@ -1,8 +1,9 @@
 package cc.mrbird.febs.common.utils;
 
-import cc.mrbird.febs.common.entity.FebsConstant;
+import cc.mrbird.febs.common.entity.constant.FebsConstant;
 import cc.mrbird.febs.common.entity.QueryRequest;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.commons.lang3.StringUtils;
 
@@ -35,15 +36,15 @@ public class SortUtil {
                 && !StringUtils.equalsIgnoreCase(request.getField(), "null")
                 && !StringUtils.equalsIgnoreCase(request.getOrder(), "null")) {
             if (StringUtils.equals(request.getOrder(), FebsConstant.ORDER_DESC))
-                page.setDesc(sortField);
+                page.addOrder(OrderItem.desc(sortField));
             else
-                page.setAsc(sortField);
+                page.addOrder(OrderItem.asc(sortField));
         } else {
             if (StringUtils.isNotBlank(defaultSort)) {
                 if (StringUtils.equals(defaultOrder, FebsConstant.ORDER_DESC))
-                    page.setDesc(defaultSort);
+                    page.addOrder(OrderItem.desc(defaultSort));
                 else
-                    page.setAsc(defaultSort);
+                    page.addOrder(OrderItem.asc(defaultSort));
             }
         }
     }

+ 0 - 2
febs-common/src/main/java/cc/mrbird/febs/common/utils/SpringContextUtil.java

@@ -3,7 +3,6 @@ package cc.mrbird.febs.common.utils;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
 
 /**
  * 用于从 IOC容器中获取 Bean
@@ -11,7 +10,6 @@ import org.springframework.stereotype.Component;
  * @author MrBird
  *
  */
-@Component
 public class SpringContextUtil implements ApplicationContextAware {
 	private static ApplicationContext applicationContext;
 

+ 1 - 1
febs-common/src/main/java/cc/mrbird/febs/common/validator/MobileValidator.java

@@ -1,7 +1,7 @@
 package cc.mrbird.febs.common.validator;
 
 import cc.mrbird.febs.common.annotation.IsMobile;
-import cc.mrbird.febs.common.entity.RegexpConstant;
+import cc.mrbird.febs.common.entity.constant.RegexpConstant;
 import cc.mrbird.febs.common.utils.FebsUtil;
 import org.apache.commons.lang3.StringUtils;
 

+ 0 - 5
febs-config/Dockerfile

@@ -1,5 +0,0 @@
-FROM openjdk:8u212-jre
-MAINTAINER MrBird 852252810@qq.com
-
-COPY ./target/febs-config-1.0-SNAPSHOT.jar /febs/febs-config-1.0-SNAPSHOT.jar
-ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-config-1.0-SNAPSHOT.jar"]

+ 0 - 46
febs-config/pom.xml

@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>cc.mrbird</groupId>
-        <artifactId>febs-cloud</artifactId>
-        <version>1.0-SNAPSHOT</version>
-        <relativePath>../febs-cloud/pom.xml</relativePath>
-    </parent>
-    <groupId>cc.mrbird.febs</groupId>
-    <artifactId>febs-config</artifactId>
-    <version>1.0-SNAPSHOT</version>
-    <name>FEBS-Config</name>
-    <description>FEBS-Config微服务配置中心</description>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-config-server</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>de.codecentric</groupId>
-            <artifactId>spring-boot-admin-starter-client</artifactId>
-            <version>2.1.6</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>

+ 0 - 60
febs-config/repository/config/FEBS-Auth-dev.yml

@@ -1,60 +0,0 @@
-spring:
-  datasource:
-    dynamic:
-      hikari:
-        connection-timeout: 30000
-        max-lifetime: 1800000
-        max-pool-size: 15
-        min-idle: 5
-        connection-test-query: select 1
-        pool-name: FebsHikariCP
-      primary: base
-      datasource:
-        base:
-          username: root
-          password: 123456
-          driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://${mysql.url}:3306/febs_cloud_base?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
-
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    time-zone: GMT+8
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-
-  redis:
-    database: 0
-    host: ${redis.url}
-    port: 6379
-    lettuce:
-      pool:
-        min-idle: 8
-        max-idle: 500
-        max-active: 2000
-        max-wait: 10000
-    timeout: 5000
-mybatis-plus:
-  type-aliases-package: cc.mrbird.febs.common.entity.system
-  mapper-locations: classpath:mapper/*.xml
-  configuration:
-    jdbc-type-for-null: null
-  global-config:
-    banner: false
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 61
febs-config/repository/config/FEBS-Auth-prod.yml

@@ -1,61 +0,0 @@
-spring:
-  datasource:
-    dynamic:
-      hikari:
-        connection-timeout: 30000
-        max-lifetime: 1800000
-        max-pool-size: 15
-        min-idle: 5
-        connection-test-query: select 1
-        pool-name: FebsHikariCP
-      primary: base
-      datasource:
-        base:
-          username: root
-          password: 123456
-          driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://${mysql.url}:3306/febs_cloud_base?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
-
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    time-zone: GMT+8
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-
-  redis:
-    database: 0
-    host: ${redis.url}
-    port: 6379
-    password: 123456
-    lettuce:
-      pool:
-        min-idle: 8
-        max-idle: 500
-        max-active: 2000
-        max-wait: 10000
-    timeout: 5000
-mybatis-plus:
-  type-aliases-package: cc.mrbird.febs.common.entity.system
-  mapper-locations: classpath:mapper/*.xml
-  configuration:
-    jdbc-type-for-null: null
-  global-config:
-    banner: false
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 60
febs-config/repository/config/FEBS-Auth-test.yml

@@ -1,60 +0,0 @@
-spring:
-  datasource:
-    dynamic:
-      hikari:
-        connection-timeout: 30000
-        max-lifetime: 1800000
-        max-pool-size: 15
-        min-idle: 5
-        connection-test-query: select 1
-        pool-name: FebsHikariCP
-      primary: base
-      datasource:
-        base:
-          username: root
-          password: 123456
-          driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://${mysql.url}:3306/febs_cloud_base?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
-
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    time-zone: GMT+8
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-
-  redis:
-    database: 0
-    host: ${redis.url}
-    port: 6379
-    lettuce:
-      pool:
-        min-idle: 8
-        max-idle: 500
-        max-active: 2000
-        max-wait: 10000
-    timeout: 5000
-mybatis-plus:
-  type-aliases-package: cc.mrbird.febs.common.entity.system
-  mapper-locations: classpath:mapper/*.xml
-  configuration:
-    jdbc-type-for-null: null
-  global-config:
-    banner: false
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 57
febs-config/repository/config/FEBS-Gateway.yml

@@ -1,57 +0,0 @@
-spring:
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-  mvc:
-    throw-exception-if-no-handler-found: true
-  autoconfigure:
-    exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
-zuul:
-  routes:
-    auth:
-      path: /auth/**
-      serviceId: FEBS-Auth
-      sensitiveHeaders: "*"
-    system:
-      path: /system/**
-      serviceId: FEBS-Server-System
-      sensitiveHeaders: "*"
-    test:
-      path: /test/**
-      serviceId: FEBS-Server-Test
-      sensitiveHeaders: "*"
-  retryable: false
-  ignored-services: "*"
-  ribbon:
-    eager-load:
-      enabled: true
-  host:
-    connect-timeout-millis: 5000
-    socket-timeout-millis: 5000
-  add-proxy-headers: true
-
-  SendErrorFilter:
-    error:
-      disable: true
-
-ribbon:
-  ConnectTimeout: 3000
-  ReadTimeout: 5000
-
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 74
febs-config/repository/config/FEBS-Server-System-dev.yml

@@ -1,74 +0,0 @@
-spring:
-  aop:
-    proxy-target-class: true
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    time-zone: GMT+8
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-  freemarker:
-    check-template-location: false
-
-  datasource:
-    dynamic:
-      p6spy: true
-      hikari:
-        connection-timeout: 30000
-        max-lifetime: 1800000
-        max-pool-size: 15
-        min-idle: 5
-        connection-test-query: select 1
-        pool-name: FebsHikariCP
-      primary: base
-      datasource:
-        base:
-          username: root
-          password: 123456
-          driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://${mysql.url}:3306/febs_cloud_base?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
-  zipkin:
-    sender:
-      type: rabbit
-  sleuth:
-    sampler:
-      probability: 1
-  rabbitmq:
-    host: ${rabbitmq.url}
-    port: 5672
-    username: febs
-    password: 123456
-
-  autoconfigure:
-    exclude: org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
-
-mybatis-plus:
-  type-aliases-package: cc.mrbird.febs.common.entity.system
-  mapper-locations: classpath:mapper/*/*.xml
-  configuration:
-    jdbc-type-for-null: null
-  global-config:
-    banner: false
-security:
-  oauth2:
-    resource:
-      id: ${spring.application.name}
-      user-info-uri: http://${febs-gateway}:8301/auth/user
-
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 74
febs-config/repository/config/FEBS-Server-System-prod.yml

@@ -1,74 +0,0 @@
-spring:
-  aop:
-    proxy-target-class: true
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    time-zone: GMT+8
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-  freemarker:
-    check-template-location: false
-
-  datasource:
-    dynamic:
-      p6spy: true
-      hikari:
-        connection-timeout: 30000
-        max-lifetime: 1800000
-        max-pool-size: 15
-        min-idle: 5
-        connection-test-query: select 1
-        pool-name: FebsHikariCP
-      primary: base
-      datasource:
-        base:
-          username: root
-          password: 123456
-          driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://${mysql.url}:3306/febs_cloud_base?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
-  zipkin:
-    sender:
-      type: rabbit
-  sleuth:
-    sampler:
-      probability: 1
-  rabbitmq:
-    host: ${rabbitmq.url}
-    port: 5672
-    username: febs
-    password: 123456
-
-  autoconfigure:
-    exclude: org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
-
-mybatis-plus:
-  type-aliases-package: cc.mrbird.febs.common.entity.system
-  mapper-locations: classpath:mapper/*/*.xml
-  configuration:
-    jdbc-type-for-null: null
-  global-config:
-    banner: false
-security:
-  oauth2:
-    resource:
-      id: ${spring.application.name}
-      user-info-uri: http://${febs-gateway}:8301/auth/user
-
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 74
febs-config/repository/config/FEBS-Server-System-test.yml

@@ -1,74 +0,0 @@
-spring:
-  aop:
-    proxy-target-class: true
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    time-zone: GMT+8
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-  freemarker:
-    check-template-location: false
-
-  datasource:
-    dynamic:
-      p6spy: true
-      hikari:
-        connection-timeout: 30000
-        max-lifetime: 1800000
-        max-pool-size: 15
-        min-idle: 5
-        connection-test-query: select 1
-        pool-name: FebsHikariCP
-      primary: base
-      datasource:
-        base:
-          username: root
-          password: 123456
-          driver-class-name: com.mysql.cj.jdbc.Driver
-          url: jdbc:mysql://${mysql.url}:3306/febs_cloud_base?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
-  zipkin:
-    sender:
-      type: rabbit
-  sleuth:
-    sampler:
-      probability: 1
-  rabbitmq:
-    host: ${rabbitmq.url}
-    port: 5672
-    username: febs
-    password: 123456
-
-  autoconfigure:
-    exclude: org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
-
-mybatis-plus:
-  type-aliases-package: cc.mrbird.febs.common.entity.system
-  mapper-locations: classpath:mapper/*/*.xml
-  configuration:
-    jdbc-type-for-null: null
-  global-config:
-    banner: false
-security:
-  oauth2:
-    resource:
-      id: ${spring.application.name}
-      user-info-uri: http://${febs-gateway}:8301/auth/user
-
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 42
febs-config/repository/config/FEBS-Server-Test.yml

@@ -1,42 +0,0 @@
-spring:
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-  autoconfigure:
-    exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration,org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
-
-  zipkin:
-    sender:
-      type: rabbit
-  sleuth:
-    sampler:
-      probability: 1
-  rabbitmq:
-    host: ${rabbitmq.url}
-    port: 5672
-    username: febs
-    password: 123456
-
-security:
-  oauth2:
-    resource:
-      id: ${spring.application.name}
-      user-info-uri: http://${febs-gateway}:8301/auth/user
-
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 4
febs-config/run.sh

@@ -1,4 +0,0 @@
-#!/usr/bin/env bash
-mvn package
-
-docker build - t febs-config .

+ 0 - 20
febs-config/src/main/java/cc/mrbird/febs/config/FebsConfigApplication.java

@@ -1,20 +0,0 @@
-package cc.mrbird.febs.config;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.config.server.EnableConfigServer;
-
-/**
- * 配置中心服务
- */
-@EnableDiscoveryClient
-@EnableConfigServer
-@SpringBootApplication
-public class FebsConfigApplication {
-
-    public static void main(String[] args) {
-        SpringApplication.run(FebsConfigApplication.class, args);
-    }
-
-}

+ 0 - 35
febs-config/src/main/java/cc/mrbird/febs/config/runner/StartedUpRunner.java

@@ -1,35 +0,0 @@
-package cc.mrbird.febs.config.runner;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.stereotype.Component;
-
-import java.time.LocalDateTime;
-
-@Component
-public class StartedUpRunner implements ApplicationRunner {
-
-    private Logger log = LoggerFactory.getLogger(this.getClass());
-
-    @Autowired
-    private ConfigurableApplicationContext context;
-
-    @Value("${spring.application.name:'FEBS-Config'}")
-    private String applicationName;
-
-    @Override
-    public void run(ApplicationArguments args) {
-        if (context.isActive()) {
-            log.info(" __    ___   _      ___   _     ____ _____  ____ ");
-            log.info("/ /`  / / \\ | |\\/| | |_) | |   | |_   | |  | |_  ");
-            log.info("\\_\\_, \\_\\_/ |_|  | |_|   |_|__ |_|__  |_|  |_|__ ");
-            log.info("                                                      ");
-            log.info("{} 启动完毕,时间:{}", applicationName, LocalDateTime.now());
-        }
-    }
-}

+ 0 - 8
febs-config/src/main/resources/banner.txt

@@ -1,8 +0,0 @@
-|------------------------------|
-|    ____  ____  ___   __      |
-|   | |_  | |_  | |_) ( (`     |
-|   |_|   |_|__ |_|_) _)_)     |
-|                              |
-|   ${spring.application.name}                |
-|   Spring-Boot: ${spring-boot.version} |
-|------------------------------|

+ 0 - 49
febs-config/src/main/resources/bootstrap.yml

@@ -1,49 +0,0 @@
-server:
-  port: 8501
-spring:
-  application:
-    name: FEBS-Config
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-
-  profiles:
-    active: git
-  cloud:
-    config:
-      server:
-        git:
-          uri: 您的git仓库链接
-          search-paths: /config/
-          username: 您的git仓库用户名
-          password: 您的git仓库密码
-          clone-on-start: true
-
-eureka:
-  instance:
-    lease-renewal-interval-in-seconds: 20
-  client:
-    register-with-eureka: true
-    fetch-registry: true
-    instance-info-replication-interval-seconds: 30
-    registry-fetch-interval-seconds: 3
-    serviceUrl:
-      defaultZone: http://febs:123456@${febs-register}:8001/register/eureka/
-
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 53
febs-config/src/main/resources/logback-spring.xml

@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <contextName>febs</contextName>
-    <property name="log.path" value="log/febs-config" />
-    <property name="log.maxHistory" value="15" />
-    <property name="log.colorPattern" value="%magenta(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %yellow(%thread) %green(%logger) %msg%n"/>
-    <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level %thread %logger %msg%n"/>
-    <!--输出到控制台-->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${log.colorPattern}</pattern>
-        </encoder>
-    </appender>
-
-    <!--输出到文件-->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${log.path}/info/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <MaxHistory>${log.maxHistory}</MaxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <level>INFO</level>
-            <onMatch>ACCEPT</onMatch>
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${log.path}/error/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <level>ERROR</level>
-            <onMatch>ACCEPT</onMatch>
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <root level="debug">
-        <appender-ref ref="console" />
-    </root>
-
-    <root level="info">
-        <appender-ref ref="file_info" />
-        <appender-ref ref="file_error" />
-    </root>
-</configuration>

+ 2 - 2
febs-gateway/Dockerfile

@@ -1,5 +1,5 @@
 FROM openjdk:8u212-jre
 MAINTAINER MrBird 852252810@qq.com
 
-COPY ./target/febs-gateway-1.0-SNAPSHOT.jar /febs/febs-gateway-1.0-SNAPSHOT.jar
-ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-gateway-1.0-SNAPSHOT.jar"]
+COPY ./target/febs-gateway-1.1-SNAPSHOT.jar /febs/febs-gateway-1.1-SNAPSHOT.jar
+ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-gateway-1.1-SNAPSHOT.jar"]

+ 44 - 12
febs-gateway/pom.xml

@@ -1,17 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
-
     <parent>
         <groupId>cc.mrbird</groupId>
         <artifactId>febs-cloud</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1-SNAPSHOT</version>
         <relativePath>../febs-cloud/pom.xml</relativePath>
     </parent>
-
     <artifactId>febs-gateway</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>1.1-SNAPSHOT</version>
     <name>FEBS-Gateway</name>
     <description>FEBS-Gateway服务网关模块</description>
 
@@ -19,21 +17,56 @@
         <dependency>
             <groupId>cc.mrbird</groupId>
             <artifactId>febs-common</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>1.1-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-web</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.baomidou</groupId>
+                    <artifactId>mybatis-plus-boot-starter</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-data-redis</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework.cloud</groupId>
+                    <artifactId>spring-cloud-starter-oauth2</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework.cloud</groupId>
+                    <artifactId>spring-cloud-starter-security</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
+            <artifactId>spring-cloud-starter-gateway</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
         </dependency>
         <dependency>
             <groupId>com.alibaba.csp</groupId>
-            <artifactId>sentinel-zuul-adapter</artifactId>
+            <artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
             <version>1.6.3</version>
         </dependency>
         <dependency>
-            <groupId>net.logstash.logback</groupId>
-            <artifactId>logstash-logback-encoder</artifactId>
-            <version>6.1</version>
+            <groupId>com.alibaba.csp</groupId>
+            <artifactId>sentinel-core</artifactId>
+            <version>1.6.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.csp</groupId>
+            <artifactId>sentinel-parameter-flow-control</artifactId>
+            <version>1.6.3</version>
         </dependency>
     </dependencies>
 
@@ -45,5 +78,4 @@
             </plugin>
         </plugins>
     </build>
-
 </project>

+ 0 - 4
febs-gateway/src/main/java/cc/mrbird/febs/gateway/FebsGatewayApplication.java

@@ -2,11 +2,7 @@ package cc.mrbird.febs.gateway;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
 
-@EnableDiscoveryClient
-@EnableZuulProxy
 @SpringBootApplication
 public class FebsGatewayApplication {
 

+ 14 - 13
febs-gateway/src/main/java/cc/mrbird/febs/gateway/configure/FebsGateWayCorsConfigure.java

@@ -1,28 +1,29 @@
 package cc.mrbird.febs.gateway.configure;
 
+import cc.mrbird.febs.common.entity.constant.EndpointConstant;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.cors.CorsConfiguration;
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
-import org.springframework.web.filter.CorsFilter;
+import org.springframework.web.cors.reactive.CorsWebFilter;
+import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
+import org.springframework.web.util.pattern.PathPatternParser;
 
 /**
- * 跨域处理
- *
  * @author MrBird
  */
 @Configuration
 public class FebsGateWayCorsConfigure {
 
     @Bean
-    public CorsFilter corsFilter() {
-        final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
-        final CorsConfiguration corsConfiguration = new CorsConfiguration();
-        corsConfiguration.setAllowCredentials(true);
-        corsConfiguration.addAllowedHeader(CorsConfiguration.ALL);
-        corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL);
-        corsConfiguration.addAllowedMethod(CorsConfiguration.ALL);
-        source.registerCorsConfiguration("/**", corsConfiguration);
-        return new CorsFilter(source);
+    public CorsWebFilter corsFilter() {
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
+        CorsConfiguration cors = new CorsConfiguration();
+        cors.setAllowCredentials(true);
+        cors.addAllowedOrigin(CorsConfiguration.ALL);
+        cors.addAllowedHeader(CorsConfiguration.ALL);
+        cors.addAllowedMethod(CorsConfiguration.ALL);
+        source.registerCorsConfiguration(EndpointConstant.ALL, cors);
+        return new CorsWebFilter(source);
     }
+
 }

+ 57 - 0
febs-gateway/src/main/java/cc/mrbird/febs/gateway/configure/FebsGatewayErrorConfigure.java

@@ -0,0 +1,57 @@
+package cc.mrbird.febs.gateway.configure;
+
+import cc.mrbird.febs.gateway.handler.FebsGatewayExceptionHandler;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.web.ResourceProperties;
+import org.springframework.boot.autoconfigure.web.ServerProperties;
+import org.springframework.boot.web.reactive.error.ErrorAttributes;
+import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.http.codec.ServerCodecConfigurer;
+import org.springframework.web.reactive.result.view.ViewResolver;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author MrBird
+ */
+@Configuration
+public class FebsGatewayErrorConfigure {
+
+    private final ServerProperties serverProperties;
+    private final ApplicationContext applicationContext;
+    private final ResourceProperties resourceProperties;
+    private final List<ViewResolver> viewResolvers;
+    private final ServerCodecConfigurer serverCodecConfigurer;
+
+    public FebsGatewayErrorConfigure(ServerProperties serverProperties,
+                                     ResourceProperties resourceProperties,
+                                     ObjectProvider<List<ViewResolver>> viewResolversProvider,
+                                     ServerCodecConfigurer serverCodecConfigurer,
+                                     ApplicationContext applicationContext) {
+        this.serverProperties = serverProperties;
+        this.applicationContext = applicationContext;
+        this.resourceProperties = resourceProperties;
+        this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
+        this.serverCodecConfigurer = serverCodecConfigurer;
+    }
+
+    @Bean
+    @Order(Ordered.HIGHEST_PRECEDENCE)
+    public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
+        FebsGatewayExceptionHandler exceptionHandler = new FebsGatewayExceptionHandler(
+                errorAttributes,
+                this.resourceProperties,
+                this.serverProperties.getError(),
+                this.applicationContext);
+        exceptionHandler.setViewResolvers(this.viewResolvers);
+        exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
+        exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
+        return exceptionHandler;
+    }
+}

+ 0 - 19
febs-gateway/src/main/java/cc/mrbird/febs/gateway/configure/FebsGatewaySecurityConfigure.java

@@ -1,19 +0,0 @@
-package cc.mrbird.febs.gateway.configure;
-
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-
-/**
- * WebSecurity配置
- *
- * @author MrBird
- */
-@EnableWebSecurity
-public class FebsGatewaySecurityConfigure extends WebSecurityConfigurerAdapter {
-
-    @Override
-    protected void configure(HttpSecurity http) throws Exception {
-        http.csrf().disable().headers().frameOptions().disable();
-    }
-}

+ 25 - 22
febs-gateway/src/main/java/cc/mrbird/febs/gateway/filter/FebsGatewaySentinelFilter.java → febs-gateway/src/main/java/cc/mrbird/febs/gateway/configure/FebsGatewaySentinelConfigure.java

@@ -1,6 +1,5 @@
-package cc.mrbird.febs.gateway.filter;
+package cc.mrbird.febs.gateway.configure;
 
-import cc.mrbird.febs.gateway.fallback.FebsGatewayBlockFallbackProvider;
 import com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants;
 import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition;
 import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem;
@@ -9,52 +8,56 @@ import com.alibaba.csp.sentinel.adapter.gateway.common.api.GatewayApiDefinitionM
 import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
 import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayParamFlowItem;
 import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
-import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.ZuulBlockFallbackManager;
-import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulErrorFilter;
-import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPostFilter;
-import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPreFilter;
-import com.netflix.zuul.ZuulFilter;
-import lombok.extern.slf4j.Slf4j;
+import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
+import com.alibaba.csp.sentinel.adapter.gateway.sc.exception.SentinelGatewayBlockExceptionHandler;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.cloud.gateway.filter.GlobalFilter;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.http.codec.ServerCodecConfigurer;
+import org.springframework.web.reactive.result.view.ViewResolver;
 
 import javax.annotation.PostConstruct;
+import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 /**
- * 限流过滤器
- *
  * @author MrBird
  */
-@Slf4j
 @Configuration
-public class FebsGatewaySentinelFilter {
+public class FebsGatewaySentinelConfigure {
+    private final List<ViewResolver> viewResolvers;
+    private final ServerCodecConfigurer serverCodecConfigurer;
 
-    @Bean
-    public ZuulFilter sentinelZuulPreFilter() {
-        return new SentinelZuulPreFilter();
+    public FebsGatewaySentinelConfigure(ObjectProvider<List<ViewResolver>> viewResolversProvider,
+                                        ServerCodecConfigurer serverCodecConfigurer) {
+        this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
+        this.serverCodecConfigurer = serverCodecConfigurer;
     }
 
     @Bean
-    public ZuulFilter sentinelZuulPostFilter() {
-        return new SentinelZuulPostFilter();
+    @Order(Ordered.HIGHEST_PRECEDENCE)
+    public SentinelGatewayBlockExceptionHandler sentinelGatewayBlockExceptionHandler() {
+        return new SentinelGatewayBlockExceptionHandler(viewResolvers, serverCodecConfigurer);
     }
 
     @Bean
-    public ZuulFilter sentinelZuulErrorFilter() {
-        return new SentinelZuulErrorFilter();
+    @Order(-1)
+    public GlobalFilter sentinelGatewayFilter() {
+        return new SentinelGatewayFilter();
     }
 
     @PostConstruct
     public void doInit() {
-        ZuulBlockFallbackManager.registerProvider(new FebsGatewayBlockFallbackProvider());
         initGatewayRules();
     }
 
     /**
-     * 定义验证码请求限流,限流规则:
-     * 60秒内同一个IP,同一个 key最多访问 10次
+     * 验证码限流
      */
     private void initGatewayRules() {
         Set<ApiDefinition> definitions = new HashSet<>();

+ 24 - 0
febs-gateway/src/main/java/cc/mrbird/febs/gateway/controller/FallbackController.java

@@ -0,0 +1,24 @@
+package cc.mrbird.febs.gateway.controller;
+
+import cc.mrbird.febs.common.entity.FebsResponse;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
+
+/**
+ * @author MrBird
+ */
+@RestController
+public class FallbackController{
+
+    @RequestMapping("fallback/{name}")
+    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+    public Mono<FebsResponse> systemFallback(@PathVariable String name) {
+        String response = String.format("访问%s超时或者服务不可用", name);
+        return Mono.just(new FebsResponse().message(response));
+    }
+
+}

+ 0 - 29
febs-gateway/src/main/java/cc/mrbird/febs/gateway/fallback/FebsGatewayBlockFallbackProvider.java

@@ -1,29 +0,0 @@
-package cc.mrbird.febs.gateway.fallback;
-
-import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.BlockResponse;
-import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.ZuulBlockFallbackProvider;
-import com.alibaba.csp.sentinel.slots.block.BlockException;
-import org.springframework.http.HttpStatus;
-
-/**
- * 自定义限流异常
- *
- * @author MrBird
- */
-public class FebsGatewayBlockFallbackProvider implements ZuulBlockFallbackProvider {
-    @Override
-    public String getRoute() {
-        return "*";
-    }
-
-    @Override
-    public BlockResponse fallbackResponse(String route, Throwable throwable) {
-        if (throwable instanceof BlockException) {
-            return new BlockResponse(HttpStatus.TOO_MANY_REQUESTS.value(),
-                    "访问频率超限", route);
-        } else {
-            return new BlockResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),
-                    "系统内部异常", route);
-        }
-    }
-}

+ 0 - 61
febs-gateway/src/main/java/cc/mrbird/febs/gateway/filter/FebsGatewayErrorFilter.java

@@ -1,61 +0,0 @@
-package cc.mrbird.febs.gateway.filter;
-
-import cc.mrbird.febs.common.entity.FebsResponse;
-import cc.mrbird.febs.common.utils.FebsUtil;
-import com.netflix.zuul.context.RequestContext;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter;
-import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Component;
-import org.springframework.util.ReflectionUtils;
-
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * 处理 Zuul 异常
- *
- * @author MrBird
- */
-@Slf4j
-@Component
-public class FebsGatewayErrorFilter extends SendErrorFilter {
-
-    @Override
-    public Object run() {
-        try {
-            FebsResponse febsResponse = new FebsResponse();
-            RequestContext ctx = RequestContext.getCurrentContext();
-            String serviceId = (String) ctx.get(FilterConstants.SERVICE_ID_KEY);
-
-            ExceptionHolder exception = findZuulException(ctx.getThrowable());
-            String errorCause = exception.getErrorCause();
-            Throwable throwable = exception.getThrowable();
-            String message = throwable.getMessage();
-            message = StringUtils.isBlank(message) ? errorCause : message;
-            febsResponse = resolveExceptionMessage(message, serviceId, febsResponse);
-
-            HttpServletResponse response = ctx.getResponse();
-            FebsUtil.makeResponse(
-                    response, MediaType.APPLICATION_JSON_UTF8_VALUE,
-                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR, febsResponse
-            );
-            log.error("Zull sendError:{}", febsResponse.getMessage());
-        } catch (Exception ex) {
-            log.error("Zuul sendError", ex);
-            ReflectionUtils.rethrowRuntimeException(ex);
-        }
-        return null;
-    }
-
-    private FebsResponse resolveExceptionMessage(String message, String serviceId, FebsResponse febsResponse) {
-        if (StringUtils.containsIgnoreCase(message, "time out")) {
-            return febsResponse.message("请求" + serviceId + "服务超时");
-        }
-        if (StringUtils.containsIgnoreCase(message, "forwarding error")) {
-            return febsResponse.message(serviceId + "服务不可用");
-        }
-        return febsResponse.message("Zuul请求" + serviceId + "服务异常");
-    }
-}

+ 59 - 46
febs-gateway/src/main/java/cc/mrbird/febs/gateway/filter/FebsGatewayRequestFilter.java

@@ -1,64 +1,84 @@
 package cc.mrbird.febs.gateway.filter;
 
-import cc.mrbird.febs.common.entity.FebsConstant;
 import cc.mrbird.febs.common.entity.FebsResponse;
-import cc.mrbird.febs.common.utils.FebsUtil;
+import cc.mrbird.febs.common.entity.constant.FebsConstant;
 import cc.mrbird.febs.gateway.properties.FebsGatewayProperties;
-import com.netflix.zuul.ZuulFilter;
-import com.netflix.zuul.context.RequestContext;
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
+import org.springframework.cloud.gateway.filter.GlobalFilter;
+import org.springframework.cloud.gateway.route.Route;
+import org.springframework.core.annotation.Order;
+import org.springframework.core.io.buffer.DataBuffer;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
 import org.springframework.stereotype.Component;
 import org.springframework.util.AntPathMatcher;
 import org.springframework.util.Base64Utils;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
+import java.net.URI;
+import java.time.LocalDateTime;
+import java.util.LinkedHashSet;
+
+import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.*;
 
 /**
- * 请求前置过滤器
- *
  * @author MrBird
  */
 @Slf4j
 @Component
-public class FebsGatewayRequestFilter extends ZuulFilter {
+@Order(0)
+public class FebsGatewayRequestFilter implements GlobalFilter {
 
     @Autowired
     private FebsGatewayProperties properties;
-
     private AntPathMatcher pathMatcher = new AntPathMatcher();
 
     @Override
-    public String filterType() {
-        return FilterConstants.PRE_TYPE;
-    }
+    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
+        ServerHttpRequest request = exchange.getRequest();
+        ServerHttpResponse response = exchange.getResponse();
 
-    @Override
-    public int filterOrder() {
-        return 6;
-    }
+        Mono<Void> checkForbidUriResult = checkForbidUri(request, response);
+        if (checkForbidUriResult != null) {
+            return checkForbidUriResult;
+        }
 
-    @Override
-    public boolean shouldFilter() {
-        return true;
+        printLog(exchange);
+
+        byte[] token = Base64Utils.encode((FebsConstant.GATEWAY_TOKEN_VALUE).getBytes());
+        String[] headerValues = {new String(token)};
+        ServerHttpRequest build = request.mutate().header(FebsConstant.GATEWAY_TOKEN_HEADER, headerValues).build();
+        ServerWebExchange newExchange = exchange.mutate().request(build).build();
+        return chain.filter(newExchange);
     }
 
-    @Override
-    public Object run() {
-        RequestContext ctx = RequestContext.getCurrentContext();
-        String serviceId = (String) ctx.get(FilterConstants.SERVICE_ID_KEY);
-        HttpServletRequest request = ctx.getRequest();
-        String host = request.getRemoteHost();
-        String method = request.getMethod();
-        String uri = request.getRequestURI();
-        log.info("请求URI:{},HTTP Method:{},请求IP:{},ServerId:{}", uri, method, host, serviceId);
+    private void printLog(ServerWebExchange exchange) {
+        URI url = exchange.getAttribute(GATEWAY_REQUEST_URL_ATTR);
+        Route route = exchange.getAttribute(GATEWAY_ROUTE_ATTR);
+        LinkedHashSet<URI> uris = exchange.getAttribute(GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
+        URI originUri = null;
+        if (uris != null) {
+            originUri = uris.stream().findFirst().orElse(null);
+        }
+        if (url != null && route != null && originUri != null) {
+            log.info("转发请求:{}://{}{} --> 目标服务:{},目标地址:{}://{}{},转发时间:{}",
+                    originUri.getScheme(), originUri.getAuthority(), originUri.getPath(),
+                    route.getId(), url.getScheme(), url.getAuthority(), url.getPath(), LocalDateTime.now()
+            );
+        }
+    }
 
+    private Mono<Void> checkForbidUri(ServerHttpRequest request, ServerHttpResponse response) {
+        String uri = request.getPath().toString();
         boolean shouldForward = true;
         String forbidRequestUri = properties.getForbidRequestUri();
         String[] forbidRequestUris = StringUtils.splitByWholeSeparatorPreserveAllTokens(forbidRequestUri, ",");
@@ -70,23 +90,16 @@ public class FebsGatewayRequestFilter extends ZuulFilter {
             }
         }
         if (!shouldForward) {
-            HttpServletResponse response = ctx.getResponse();
             FebsResponse febsResponse = new FebsResponse().message("该URI不允许外部访问");
-            try {
-                FebsUtil.makeResponse(
-                        response, MediaType.APPLICATION_JSON_UTF8_VALUE,
-                        HttpServletResponse.SC_FORBIDDEN, febsResponse
-                );
-                ctx.setSendZuulResponse(false);
-                ctx.setResponse(response);
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-            return null;
+            return makeResponse(response, febsResponse);
         }
-
-        byte[] token = Base64Utils.encode((FebsConstant.ZUUL_TOKEN_VALUE).getBytes());
-        ctx.addZuulRequestHeader(FebsConstant.ZUUL_TOKEN_HEADER, new String(token));
         return null;
     }
+
+    private Mono<Void> makeResponse(ServerHttpResponse response, FebsResponse febsResponse) {
+        response.setStatusCode(HttpStatus.FORBIDDEN);
+        response.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE);
+        DataBuffer dataBuffer = response.bufferFactory().wrap(JSONObject.toJSONString(febsResponse).getBytes());
+        return response.writeWith(Mono.just(dataBuffer));
+    }
 }

+ 73 - 0
febs-gateway/src/main/java/cc/mrbird/febs/gateway/handler/FebsGatewayExceptionHandler.java

@@ -0,0 +1,73 @@
+package cc.mrbird.febs.gateway.handler;
+
+import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowException;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.boot.autoconfigure.web.ErrorProperties;
+import org.springframework.boot.autoconfigure.web.ResourceProperties;
+import org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler;
+import org.springframework.boot.web.reactive.error.ErrorAttributes;
+import org.springframework.cloud.gateway.support.NotFoundException;
+import org.springframework.cloud.gateway.support.TimeoutException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.reactive.function.server.*;
+import org.springframework.web.server.ResponseStatusException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author MrBird
+ */
+@Slf4j
+public class FebsGatewayExceptionHandler extends DefaultErrorWebExceptionHandler {
+
+    public FebsGatewayExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties,
+                                       ErrorProperties errorProperties, ApplicationContext applicationContext) {
+        super(errorAttributes, resourceProperties, errorProperties, applicationContext);
+    }
+
+    /**
+     * 异常处理,定义返回报文格式
+     */
+    @Override
+    protected Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
+        Throwable error = super.getError(request);
+        log.error(
+                "请求发生异常,请求URI:{},请求方法:{},异常信息:{}",
+                request.path(), request.methodName(), error.getMessage()
+        );
+        String errorMessage;
+        if (error instanceof NotFoundException) {
+            String serverId = StringUtils.substringAfterLast(error.getMessage(), "Unable to find instance for ");
+            serverId = StringUtils.replace(serverId, "\"", StringUtils.EMPTY);
+            errorMessage = String.format("无法找到%s服务", serverId);
+        } else if (StringUtils.containsIgnoreCase(error.getMessage(), "connection refused")) {
+            errorMessage = "目标服务拒绝连接";
+        } else if (error instanceof TimeoutException) {
+            errorMessage = "访问服务超时";
+        } else if (error instanceof ResponseStatusException
+                && StringUtils.containsIgnoreCase(error.getMessage(), HttpStatus.NOT_FOUND.toString())) {
+            errorMessage = "未找到该资源";
+        } else if (error instanceof ParamFlowException) {
+            errorMessage = "访问频率超限";
+        } else {
+            errorMessage = "网关转发异常";
+        }
+        Map<String, Object> errorAttributes = new HashMap<>(3);
+        errorAttributes.put("message", errorMessage);
+        return errorAttributes;
+    }
+
+    @Override
+    @SuppressWarnings("all")
+    protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes) {
+        return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
+    }
+
+    @Override
+    protected HttpStatus getHttpStatus(Map<String, Object> errorAttributes) {
+        return HttpStatus.INTERNAL_SERVER_ERROR;
+    }
+}

+ 5 - 5
febs-gateway/src/main/java/cc/mrbird/febs/gateway/runner/StartedUpRunner.java

@@ -1,6 +1,6 @@
 package cc.mrbird.febs.gateway.runner;
 
-import cc.mrbird.febs.common.entity.FebsServerConstant;
+import cc.mrbird.febs.common.entity.constant.FebsServerConstant;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -24,10 +24,10 @@ public class StartedUpRunner implements ApplicationRunner {
     @Override
     public void run(ApplicationArguments args) {
         if (context.isActive()) {
-            log.info(" __    ___   _      ___   _     ____ _____  ____ ");
-            log.info("/ /`  / / \\ | |\\/| | |_) | |   | |_   | |  | |_  ");
-            log.info("\\_\\_, \\_\\_/ |_|  | |_|   |_|__ |_|__  |_|  |_|__ ");
-            log.info("                                                      ");
+            log.info("  _   _   _   _   _   _   _   _");
+            log.info(" / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\");
+            log.info("( c | o | m | p | l | e | t | e )");
+            log.info(" \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/");
             log.info("{} 启动完毕,时间:{}", applicationName, LocalDateTime.now());
         }
     }

+ 7 - 23
febs-gateway/src/main/resources/bootstrap.yml

@@ -1,28 +1,12 @@
-server:
-  port: 8301
-
 spring:
   application:
     name: FEBS-Gateway
   cloud:
-    config:
-      fail-fast: true
-      name: ${spring.application.name}
-      profile: ${spring.profiles.active}
+    nacos:
+      config:
+        server-addr: ${nacos.url}:8001
+        group: DEFAULT_GROUP
+        prefix: febs-gateway
+        file-extension: yaml
       discovery:
-        enabled: true
-        service-id: FEBS-Config
-  profiles:
-    active: dev
-
-eureka:
-  instance:
-    lease-renewal-interval-in-seconds: 20
-  client:
-    register-with-eureka: true
-    fetch-registry: true
-    instance-info-replication-interval-seconds: 30
-    registry-fetch-interval-seconds: 3
-    serviceUrl:
-      defaultZone: http://febs:123456@${febs-register}:8001/register/eureka/
-
+        server-addr: ${nacos.url}:8001

+ 0 - 1
febs-gateway/src/main/resources/logback-spring.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <contextName>febs</contextName>
     <property name="log.path" value="log/febs-gateway" />
     <property name="log.maxHistory" value="15" />
     <property name="log.colorPattern" value="%magenta(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %yellow(%thread) %green(%logger) %msg%n"/>

+ 2 - 2
febs-monitor/febs-monitor-admin/Dockerfile

@@ -1,5 +1,5 @@
 FROM openjdk:8u212-jre
 MAINTAINER MrBird 852252810@qq.com
 
-COPY ./target/febs-monitor-admin-1.0-SNAPSHOT.jar /febs/febs-monitor-admin-1.0-SNAPSHOT.jar
-ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-monitor-admin-1.0-SNAPSHOT.jar"]
+COPY ./target/febs-monitor-admin-1.1-SNAPSHOT.jar /febs/febs-monitor-admin-1.1-SNAPSHOT.jar
+ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-monitor-admin-1.1-SNAPSHOT.jar"]

+ 6 - 2
febs-monitor/febs-monitor-admin/pom.xml

@@ -5,12 +5,12 @@
     <parent>
         <groupId>cc.mrbird</groupId>
         <artifactId>febs-monitor</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
     <artifactId>febs-monitor-admin</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>1.1-SNAPSHOT</version>
     <name>Febs-Monitor-Admin</name>
     <description>Febs-Monitor-Admin基于Spring Boot Admin搭建的监控程序</description>
 
@@ -33,6 +33,10 @@
             <artifactId>spring-boot-admin-server-ui</artifactId>
             <version>2.1.6</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 4 - 4
febs-monitor/febs-monitor-admin/src/main/java/cc/mrbird/febs/monitor/admin/runner/StartedUpRunner.java

@@ -25,10 +25,10 @@ public class StartedUpRunner implements ApplicationRunner {
     @Override
     public void run(ApplicationArguments args) {
         if (context.isActive()) {
-            log.info(" __    ___   _      ___   _     ____ _____  ____ ");
-            log.info("/ /`  / / \\ | |\\/| | |_) | |   | |_   | |  | |_  ");
-            log.info("\\_\\_, \\_\\_/ |_|  | |_|   |_|__ |_|__  |_|  |_|__ ");
-            log.info("                                                      ");
+            log.info("  _   _   _   _   _   _   _   _");
+            log.info(" / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\");
+            log.info("( c | o | m | p | l | e | t | e )");
+            log.info(" \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/");
             log.info("{} 启动完毕,时间:{}", applicationName, LocalDateTime.now());
         }
     }

+ 0 - 14
febs-monitor/febs-monitor-admin/src/main/resources/application.yml

@@ -1,14 +0,0 @@
-server:
-  port: 8401
-
-spring:
-  application:
-    name: FEBS-Monitor-Admin
-  security:
-    user:
-      name: febs
-      password: 123456
-  boot:
-    admin:
-      ui:
-        title: ${spring.application.name}

+ 10 - 0
febs-monitor/febs-monitor-admin/src/main/resources/bootstrap.yml

@@ -0,0 +1,10 @@
+spring:
+  application:
+    name: FEBS-Monitor-Admin
+  cloud:
+    nacos:
+      config:
+        server-addr: ${nacos.url}:8001
+        group: DEFAULT_GROUP
+        prefix: febs-monitor-admin
+        file-extension: yaml

+ 2 - 2
febs-monitor/pom.xml

@@ -5,13 +5,13 @@
     <parent>
         <artifactId>febs-cloud</artifactId>
         <groupId>cc.mrbird</groupId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1-SNAPSHOT</version>
         <relativePath>../febs-cloud/pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>febs-monitor</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>1.1-SNAPSHOT</version>
     <packaging>pom</packaging>
     <name>FEBS-Monitor</name>
     <description>FEBS-Monitor监控模块</description>

+ 0 - 5
febs-register/Dockerfile

@@ -1,5 +0,0 @@
-FROM openjdk:8u212-jre
-MAINTAINER MrBird 852252810@qq.com
-
-COPY ./target/febs-register-1.0-SNAPSHOT.jar /febs/febs-register-1.0-SNAPSHOT.jar
-ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-register-1.0-SNAPSHOT.jar"]

+ 0 - 42
febs-register/pom.xml

@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>cc.mrbird</groupId>
-        <artifactId>febs-cloud</artifactId>
-        <version>1.0-SNAPSHOT</version>
-        <relativePath>../febs-cloud/pom.xml</relativePath>
-    </parent>
-
-    <artifactId>febs-register</artifactId>
-    <version>1.0-SNAPSHOT</version>
-    <name>FEBS-Register</name>
-    <description>FEBS-Cloud服务注册中心</description>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-security</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>de.codecentric</groupId>
-            <artifactId>spring-boot-admin-starter-client</artifactId>
-            <version>2.1.6</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>

+ 0 - 4
febs-register/run.sh

@@ -1,4 +0,0 @@
-#!/usr/bin/env bash
-mvn package
-
-docker build -t febs-register .

+ 0 - 17
febs-register/src/main/java/cc/mrbird/febs/register/FebsRegisterApplication.java

@@ -1,17 +0,0 @@
-package cc.mrbird.febs.register;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
-
-/**
- * @author MrBird
- */
-@EnableEurekaServer
-@SpringBootApplication
-public class FebsRegisterApplication {
-
-    public static void main(String[] args) {
-        SpringApplication.run(FebsRegisterApplication.class, args);
-    }
-}

+ 0 - 24
febs-register/src/main/java/cc/mrbird/febs/register/configure/FebsRegisterWebSecurityConfigure.java

@@ -1,24 +0,0 @@
-package cc.mrbird.febs.register.configure;
-
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-
-/**
- * WebSecurity配置
- *
- * @author MrBird
- */
-@EnableWebSecurity
-public class FebsRegisterWebSecurityConfigure extends WebSecurityConfigurerAdapter {
-    @Override
-    protected void configure(HttpSecurity http) throws Exception {
-        http.headers().frameOptions().disable()
-                .and()
-                .csrf().ignoringAntMatchers("/eureka/**")
-                .and()
-                .authorizeRequests().antMatchers("/actuator/**").permitAll();
-        super.configure(http);
-    }
-
-}

+ 0 - 35
febs-register/src/main/java/cc/mrbird/febs/register/runner/StartedUpRunner.java

@@ -1,35 +0,0 @@
-package cc.mrbird.febs.register.runner;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.stereotype.Component;
-
-import java.time.LocalDateTime;
-
-@Component
-public class StartedUpRunner implements ApplicationRunner {
-
-    private Logger log = LoggerFactory.getLogger(this.getClass());
-
-    @Autowired
-    private ConfigurableApplicationContext context;
-
-    @Value("${spring.application.name:'FEBS-Register'}")
-    private String applicationName;
-
-    @Override
-    public void run(ApplicationArguments args) {
-        if (context.isActive()) {
-            log.info(" __    ___   _      ___   _     ____ _____  ____ ");
-            log.info("/ /`  / / \\ | |\\/| | |_) | |   | |_   | |  | |_  ");
-            log.info("\\_\\_, \\_\\_/ |_|  | |_|   |_|__ |_|__  |_|  |_|__ ");
-            log.info("                                                      ");
-            log.info("{} 启动完毕,时间:{}", applicationName, LocalDateTime.now());
-        }
-    }
-}

+ 0 - 8
febs-register/src/main/resources/banner.txt

@@ -1,8 +0,0 @@
-|------------------------------|
-|    ____  ____  ___   __      |
-|   | |_  | |_  | |_) ( (`     |
-|   |_|   |_|__ |_|_) _)_)     |
-|                              |
-|   ${spring.application.name}              |
-|   Spring-Boot: ${spring-boot.version} |
-|------------------------------|

+ 0 - 46
febs-register/src/main/resources/bootstrap.yml

@@ -1,46 +0,0 @@
-server:
-  port: 8001
-  servlet:
-    context-path: /register
-
-spring:
-  application:
-    name: FEBS-Register
-  boot:
-    admin:
-      client:
-        url: http://${febs-monitor-admin}:8401
-        username: febs
-        password: 123456
-  security:
-    user:
-      name: febs
-      password: 123456
-
-eureka:
-  instance:
-    hostname: ${febs-register}
-    lease-renewal-interval-in-seconds: 20
-    lease-expiration-duration-in-seconds: 60
-    prefer-ip-address: true
-  client:
-    register-with-eureka: false
-    fetch-registry: false
-    instance-info-replication-interval-seconds: 30
-    serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@${eureka.instance.hostname}:${server.port}${server.servlet.context-path}/eureka/
-
-info:
-  app:
-    name: ${spring.application.name}
-    description: "@project.description@"
-    version: "@project.version@"
-
-management:
-  endpoints:
-    web:
-      exposure:
-        include: '*'
-  endpoint:
-    health:
-      show-details: ALWAYS

+ 0 - 54
febs-register/src/main/resources/logback-spring.xml

@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration scan="true" scanPeriod="60 seconds" debug="false">
-    <contextName>febs</contextName>
-    <property name="log.path" value="log/febs-register" />
-    <property name="log.maxHistory" value="15" />
-    <property name="log.colorPattern" value="%magenta(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %yellow(%thread) %green(%logger) %msg%n"/>
-    <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level %thread %logger %msg%n"/>
-
-    <!--输出到控制台-->
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>${log.colorPattern}</pattern>
-        </encoder>
-    </appender>
-
-    <!--输出到文件-->
-    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${log.path}/info/info.%d{yyyy-MM-dd}.log</fileNamePattern>
-            <MaxHistory>${log.maxHistory}</MaxHistory>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <level>INFO</level>
-            <onMatch>ACCEPT</onMatch>
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${log.path}/error/error.%d{yyyy-MM-dd}.log</fileNamePattern>
-        </rollingPolicy>
-        <encoder>
-            <pattern>${log.pattern}</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <level>ERROR</level>
-            <onMatch>ACCEPT</onMatch>
-            <onMismatch>DENY</onMismatch>
-        </filter>
-    </appender>
-
-    <root level="debug">
-        <appender-ref ref="console" />
-    </root>
-
-    <root level="info">
-        <appender-ref ref="file_info" />
-        <appender-ref ref="file_error" />
-    </root>
-</configuration>

+ 2 - 2
febs-server/febs-server-system/Dockerfile

@@ -1,5 +1,5 @@
 FROM openjdk:8u212-jre
 MAINTAINER MrBird 852252810@qq.com
 
-COPY ./target/febs-server-system-1.0-SNAPSHOT.jar /febs/febs-server-system-1.0-SNAPSHOT.jar
-ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-server-system-1.0-SNAPSHOT.jar"]
+COPY ./target/febs-server-system-1.1-SNAPSHOT.jar /febs/febs-server-system-1.1-SNAPSHOT.jar
+ENTRYPOINT ["java", "-Xmx256m", "-jar", "/febs/febs-server-system-1.1-SNAPSHOT.jar"]

+ 2 - 2
febs-server/febs-server-system/pom.xml

@@ -6,12 +6,12 @@
     <parent>
         <groupId>cc.mrbird</groupId>
         <artifactId>febs-server</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
     <artifactId>febs-server-system</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>1.1-SNAPSHOT</version>
     <name>FEBS-Server-System</name>
     <description>FEBS-Server-System微服务系统模块</description>
 

+ 36 - 0
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/aspect/AspectSupport.java

@@ -0,0 +1,36 @@
+package cc.mrbird.febs.server.system.aspect;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.reflect.MethodSignature;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author MrBird
+ */
+public abstract class AspectSupport {
+
+    Method resolveMethod(ProceedingJoinPoint point) {
+        MethodSignature signature = (MethodSignature)point.getSignature();
+        Class<?> targetClass = point.getTarget().getClass();
+
+        Method method = getDeclaredMethod(targetClass, signature.getName(),
+                signature.getMethod().getParameterTypes());
+        if (method == null) {
+            throw new IllegalStateException("无法解析目标方法: " + signature.getMethod().getName());
+        }
+        return method;
+    }
+
+    private Method getDeclaredMethod(Class<?> clazz, String name, Class<?>... parameterTypes) {
+        try {
+            return clazz.getDeclaredMethod(name, parameterTypes);
+        } catch (NoSuchMethodException e) {
+            Class<?> superClass = clazz.getSuperclass();
+            if (superClass != null) {
+                return getDeclaredMethod(superClass, name, parameterTypes);
+            }
+        }
+        return null;
+    }
+}

+ 61 - 0
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/aspect/ControllerEndpointAspect.java

@@ -0,0 +1,61 @@
+package cc.mrbird.febs.server.system.aspect;
+
+import cc.mrbird.febs.common.annotation.ControllerEndpoint;
+import cc.mrbird.febs.common.exception.FebsException;
+import cc.mrbird.febs.common.utils.FebsUtil;
+import cc.mrbird.febs.common.utils.HttpContextUtil;
+import cc.mrbird.febs.server.system.service.ILogService;
+import org.apache.commons.lang3.StringUtils;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+
+/**
+ * @author MrBird
+ */
+@Aspect
+@Component
+public class ControllerEndpointAspect extends AspectSupport {
+
+    @Autowired
+    private ILogService logService;
+
+    @Pointcut("@annotation(cc.mrbird.febs.common.annotation.ControllerEndpoint)")
+    public void pointcut() {
+    }
+
+    @Around("pointcut()")
+    public Object around(ProceedingJoinPoint point) throws FebsException {
+        Object result;
+        Method targetMethod = resolveMethod(point);
+        ControllerEndpoint annotation = targetMethod.getAnnotation(ControllerEndpoint.class);
+        String operation = annotation.operation();
+        long start = System.currentTimeMillis();
+        try {
+            result = point.proceed();
+            if (StringUtils.isNotBlank(operation)) {
+                HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
+                Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+                String username = (String) authentication.getPrincipal();
+                logService.saveLog(point, targetMethod, request, operation, username, start);
+            }
+            return result;
+        } catch (Throwable throwable) {
+            String exceptionMessage = annotation.exceptionMessage();
+            String message = throwable.getMessage();
+            String error = FebsUtil.containChinese(message) ? exceptionMessage + "," + message : exceptionMessage;
+            throw new FebsException(error);
+        }
+    }
+}
+
+
+

+ 0 - 61
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/aspect/LogAspect.java

@@ -1,61 +0,0 @@
-package cc.mrbird.febs.server.system.aspect;
-
-import cc.mrbird.febs.common.entity.system.Log;
-import cc.mrbird.febs.common.utils.HttpContextUtil;
-import cc.mrbird.febs.common.utils.IPUtil;
-import cc.mrbird.febs.server.system.service.ILogService;
-import cc.mrbird.febs.server.system.service.IUserService;
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * AOP 记录用户操作日志
- *
- * @author MrBird
- */
-@Slf4j
-@Aspect
-@Component
-public class LogAspect {
-
-    @Autowired
-    private ILogService logService;
-    @Autowired
-    private IUserService userService;
-
-    @Pointcut("@annotation(cc.mrbird.febs.common.annotation.Log)")
-    public void pointcut() {
-        // do nothing
-    }
-
-    @Around("pointcut()")
-    public Object around(ProceedingJoinPoint point) throws Throwable {
-        Object result;
-        long beginTime = System.currentTimeMillis();
-        // 执行方法
-        result = point.proceed();
-        HttpServletRequest request = HttpContextUtil.getHttpServletRequest();
-        // 设置 IP地址
-        String ip = IPUtil.getIpAddr(request);
-        // 执行时长(毫秒)
-        long time = System.currentTimeMillis() - beginTime;
-        // 保存日志
-        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
-        String username = (String) authentication.getPrincipal();
-        Log log = new Log();
-        log.setUsername(username);
-        log.setIp(ip);
-        log.setTime(time);
-        logService.saveLog(point, log);
-        return result;
-    }
-}

+ 5 - 3
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/configure/FebsServerSystemResourceServerConfigure.java

@@ -1,5 +1,6 @@
 package cc.mrbird.febs.server.system.configure;
 
+import cc.mrbird.febs.common.entity.constant.EndpointConstant;
 import cc.mrbird.febs.common.handler.FebsAccessDeniedHandler;
 import cc.mrbird.febs.common.handler.FebsAuthExceptionEntryPoint;
 import cc.mrbird.febs.server.system.properties.FebsServerSystemProperties;
@@ -31,12 +32,13 @@ public class FebsServerSystemResourceServerConfigure extends ResourceServerConfi
     public void configure(HttpSecurity http) throws Exception {
         String[] anonUrls = StringUtils.splitByWholeSeparatorPreserveAllTokens(properties.getAnonUrl(), ",");
 
-        http.csrf().disable()
-                .requestMatchers().antMatchers("/**")
+        http.headers().frameOptions().disable()
+                .and().csrf().disable()
+                .requestMatchers().antMatchers(EndpointConstant.ALL)
                 .and()
                 .authorizeRequests()
                 .antMatchers(anonUrls).permitAll()
-                .antMatchers("/**").authenticated()
+                .antMatchers(EndpointConstant.ALL).authenticated()
                 .and().httpBasic();
     }
 

+ 4 - 2
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/configure/FebsWebConfigure.java

@@ -1,10 +1,12 @@
 package cc.mrbird.febs.server.system.configure;
 
+import cc.mrbird.febs.common.entity.constant.FebsConstant;
 import cc.mrbird.febs.server.system.properties.FebsServerSystemProperties;
 import cc.mrbird.febs.server.system.properties.FesbSwaggerProperties;
 import com.baomidou.mybatisplus.core.parser.ISqlParser;
 import com.baomidou.mybatisplus.extension.parsers.BlockAttackSqlParser;
 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -37,7 +39,7 @@ public class FebsWebConfigure {
     /**
      * 注册异步线程池
      */
-    @Bean("febsAsyncThreadPool")
+    @Bean(FebsConstant.ASYNC_POOL)
     public ThreadPoolTaskExecutor asyncThreadPoolTaskExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(5);
@@ -109,7 +111,7 @@ public class FebsWebConfigure {
 
     private AuthorizationScope[] scopes(FesbSwaggerProperties swagger) {
         return new AuthorizationScope[]{
-                new AuthorizationScope(swagger.getScope(), "")
+                new AuthorizationScope(swagger.getScope(), StringUtils.EMPTY)
         };
     }
 }

+ 15 - 40
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/controller/DeptController.java

@@ -1,10 +1,9 @@
 package cc.mrbird.febs.server.system.controller;
 
-import cc.mrbird.febs.common.annotation.Log;
+import cc.mrbird.febs.common.annotation.ControllerEndpoint;
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.entity.QueryRequest;
 import cc.mrbird.febs.common.entity.system.Dept;
-import cc.mrbird.febs.common.exception.FebsException;
 import cc.mrbird.febs.server.system.service.IDeptService;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.wuwenze.poi.ExcelKit;
@@ -35,57 +34,33 @@ public class DeptController {
         return new FebsResponse().data(depts);
     }
 
-    @Log("新增部门")
     @PostMapping
     @PreAuthorize("hasAnyAuthority('dept:add')")
-    public void addDept(@Valid Dept dept) throws FebsException {
-        try {
-            this.deptService.createDept(dept);
-        } catch (Exception e) {
-            String message = "新增部门失败";
-            log.error(message, e);
-            throw new FebsException(message);
-        }
+    @ControllerEndpoint(operation = "新增部门", exceptionMessage = "新增部门失败")
+    public void addDept(@Valid Dept dept) {
+        this.deptService.createDept(dept);
     }
 
-    @Log("删除部门")
     @DeleteMapping("/{deptIds}")
     @PreAuthorize("hasAnyAuthority('dept:delete')")
-    public void deleteDepts(@NotBlank(message = "{required}") @PathVariable String deptIds) throws FebsException {
-        try {
-            String[] ids = deptIds.split(StringPool.COMMA);
-            this.deptService.deleteDepts(ids);
-        } catch (Exception e) {
-            String message = "删除部门失败";
-            log.error(message, e);
-            throw new FebsException(message);
-        }
+    @ControllerEndpoint(operation = "删除部门", exceptionMessage = "删除部门失败")
+    public void deleteDepts(@NotBlank(message = "{required}") @PathVariable String deptIds) {
+        String[] ids = deptIds.split(StringPool.COMMA);
+        this.deptService.deleteDepts(ids);
     }
 
-    @Log("修改部门")
     @PutMapping
     @PreAuthorize("hasAnyAuthority('dept:update')")
-    public void updateDept(@Valid Dept dept) throws FebsException {
-        try {
-            this.deptService.updateDept(dept);
-        } catch (Exception e) {
-            String message = "修改部门失败";
-            log.error(message, e);
-            throw new FebsException(message);
-        }
+    @ControllerEndpoint(operation = "修改部门", exceptionMessage = "修改部门失败")
+    public void updateDept(@Valid Dept dept) {
+        this.deptService.updateDept(dept);
     }
 
-    @Log("导出部门数据")
     @PostMapping("excel")
     @PreAuthorize("hasAnyAuthority('dept:export')")
-    public void export(Dept dept, QueryRequest request, HttpServletResponse response) throws FebsException {
-        try {
-            List<Dept> depts = this.deptService.findDepts(dept, request);
-            ExcelKit.$Export(Dept.class, response).downXlsx(depts, false);
-        } catch (Exception e) {
-            String message = "导出Excel失败";
-            log.error(message, e);
-            throw new FebsException(message);
-        }
+    @ControllerEndpoint(operation = "导出部门数据", exceptionMessage = "导出Excel失败")
+    public void export(Dept dept, QueryRequest request, HttpServletResponse response) {
+        List<Dept> depts = this.deptService.findDepts(dept, request);
+        ExcelKit.$Export(Dept.class, response).downXlsx(depts, false);
     }
 }

+ 35 - 43
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/controller/EximportController.java

@@ -1,5 +1,6 @@
 package cc.mrbird.febs.server.system.controller;
 
+import cc.mrbird.febs.common.annotation.ControllerEndpoint;
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.entity.QueryRequest;
 import cc.mrbird.febs.common.entity.system.Eximport;
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -60,55 +62,45 @@ public class EximportController {
     }
 
     @PostMapping("import")
-    public FebsResponse importExcels(MultipartFile file) throws FebsException {
-        try {
-            if (file.isEmpty()) {
-                throw new FebsException("导入数据为空");
-            }
-            String filename = file.getOriginalFilename();
-            if (!StringUtils.endsWith(filename, ".xlsx")) {
-                throw new FebsException("只支持.xlsx类型文件导入");
+    @ControllerEndpoint(exceptionMessage = "导入Excel数据失败")
+    public FebsResponse importExcels(MultipartFile file) throws IOException, FebsException {
+        if (file.isEmpty()) {
+            throw new FebsException("导入数据为空");
+        }
+        String filename = file.getOriginalFilename();
+        if (!StringUtils.endsWith(filename, ".xlsx")) {
+            throw new FebsException("只支持.xlsx类型文件导入");
+        }
+        Stopwatch stopwatch = Stopwatch.createStarted();
+        final List<Eximport> data = Lists.newArrayList();
+        final List<Map<String, Object>> error = Lists.newArrayList();
+        ExcelKit.$Import(Eximport.class).readXlsx(file.getInputStream(), new ExcelReadHandler<Eximport>() {
+            @Override
+            public void onSuccess(int sheet, int row, Eximport eximport) {
+                eximport.setCreateTime(new Date());
+                data.add(eximport);
             }
-            Stopwatch stopwatch = Stopwatch.createStarted();
-            final List<Eximport> data = Lists.newArrayList();
-            final List<Map<String, Object>> error = Lists.newArrayList();
-            ExcelKit.$Import(Eximport.class).readXlsx(file.getInputStream(), new ExcelReadHandler<Eximport>() {
-                @Override
-                public void onSuccess(int sheet, int row, Eximport eximport) {
-                    eximport.setCreateTime(new Date());
-                    data.add(eximport);
-                }
 
-                @Override
-                public void onError(int sheet, int row, List<ExcelErrorField> errorFields) {
-                    error.add(ImmutableMap.of("row", row, "errorFields", errorFields));
-                }
-            });
-            if (CollectionUtils.isNotEmpty(data)) {
-                this.eximportService.batchInsert(data);
+            @Override
+            public void onError(int sheet, int row, List<ExcelErrorField> errorFields) {
+                error.add(ImmutableMap.of("row", row, "errorFields", errorFields));
             }
-            ImmutableMap<String, Object> result = ImmutableMap.of(
-                    "time", stopwatch.stop().toString(),
-                    "data", data,
-                    "error", error
-            );
-            return new FebsResponse().data(result);
-        } catch (Exception e) {
-            String message = "导入Excel数据失败," + e.getMessage();
-            log.error(message);
-            throw new FebsException(message);
+        });
+        if (CollectionUtils.isNotEmpty(data)) {
+            this.eximportService.batchInsert(data);
         }
+        ImmutableMap<String, Object> result = ImmutableMap.of(
+                "time", stopwatch.stop().toString(),
+                "data", data,
+                "error", error
+        );
+        return new FebsResponse().data(result);
     }
 
     @PostMapping("excel")
-    public void export(QueryRequest queryRequest, Eximport eximport, HttpServletResponse response) throws FebsException {
-        try {
-            List<Eximport> eximports = this.eximportService.findEximports(queryRequest, eximport).getRecords();
-            ExcelKit.$Export(Eximport.class, response).downXlsx(eximports, false);
-        } catch (Exception e) {
-            String message = "导出Excel失败";
-            log.error(message, e);
-            throw new FebsException(message);
-        }
+    @ControllerEndpoint(exceptionMessage = "导出Excel失败")
+    public void export(QueryRequest queryRequest, Eximport eximport, HttpServletResponse response) {
+        List<Eximport> eximports = this.eximportService.findEximports(queryRequest, eximport).getRecords();
+        ExcelKit.$Export(Eximport.class, response).downXlsx(eximports, false);
     }
 }

+ 5 - 11
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/controller/GeneratorConfigController.java

@@ -1,6 +1,6 @@
 package cc.mrbird.febs.server.system.controller;
 
-import cc.mrbird.febs.common.annotation.Log;
+import cc.mrbird.febs.common.annotation.ControllerEndpoint;
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.entity.system.GeneratorConfig;
 import cc.mrbird.febs.common.exception.FebsException;
@@ -33,18 +33,12 @@ public class GeneratorConfigController {
         return new FebsResponse().data(generatorConfigService.findGeneratorConfig());
     }
 
-    @Log("修改生成代码配置")
     @PostMapping
     @PreAuthorize("hasAnyAuthority('gen:config:update')")
+    @ControllerEndpoint(operation = "修改生成代码配置", exceptionMessage = "修改GeneratorConfig失败")
     public void updateGeneratorConfig(@Valid GeneratorConfig generatorConfig) throws FebsException {
-        try {
-            if (StringUtils.isBlank(generatorConfig.getId()))
-                throw new FebsException("配置id不能为空");
-            this.generatorConfigService.updateGeneratorConfig(generatorConfig);
-        } catch (Exception e) {
-            String message = "修改GeneratorConfig失败";
-            log.error(message, e);
-            throw new FebsException(message);
-        }
+        if (StringUtils.isBlank(generatorConfig.getId()))
+            throw new FebsException("配置id不能为空");
+        this.generatorConfigService.updateGeneratorConfig(generatorConfig);
     }
 }

+ 30 - 37
febs-server/febs-server-system/src/main/java/cc/mrbird/febs/server/system/controller/GeneratorController.java

@@ -1,13 +1,12 @@
 package cc.mrbird.febs.server.system.controller;
 
-import cc.mrbird.febs.common.annotation.Log;
+import cc.mrbird.febs.common.annotation.ControllerEndpoint;
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.entity.QueryRequest;
 import cc.mrbird.febs.common.entity.system.Column;
 import cc.mrbird.febs.common.entity.system.GeneratorConfig;
-import cc.mrbird.febs.common.entity.system.GeneratorConstant;
+import cc.mrbird.febs.common.entity.constant.GeneratorConstant;
 import cc.mrbird.febs.common.exception.FebsException;
-import cc.mrbird.febs.common.exception.FileDownloadException;
 import cc.mrbird.febs.common.utils.FebsUtil;
 import cc.mrbird.febs.common.utils.FileUtil;
 import cc.mrbird.febs.server.system.helper.GeneratorHelper;
@@ -52,43 +51,37 @@ public class GeneratorController {
         return new FebsResponse().data(dataTable);
     }
 
-    @Log("生成代码")
     @PostMapping
     @PreAuthorize("hasAnyAuthority('gen:generate:gen')")
-    public void generate(@NotBlank(message = "{required}") String name, String remark, HttpServletResponse response) throws FileDownloadException {
-        try {
-            GeneratorConfig generatorConfig = generatorConfigService.findGeneratorConfig();
-            if (generatorConfig == null) {
-                throw new FebsException("代码生成配置为空");
-            }
-
-            String className = name;
-            if (GeneratorConfig.TRIM_YES.equals(generatorConfig.getIsTrim())) {
-                className = RegExUtils.replaceFirst(name, generatorConfig.getTrimValue(), StringUtils.EMPTY);
-            }
+    @ControllerEndpoint(operation = "生成代码", exceptionMessage = "代码生成失败")
+    public void generate(@NotBlank(message = "{required}") String name, String remark, HttpServletResponse response) throws Exception {
+        GeneratorConfig generatorConfig = generatorConfigService.findGeneratorConfig();
+        if (generatorConfig == null) {
+            throw new FebsException("代码生成配置为空");
+        }
 
-            generatorConfig.setTableName(name);
-            generatorConfig.setClassName(FebsUtil.underscoreToCamel(className));
-            generatorConfig.setTableComment(remark);
-            // 生成代码到临时目录
-            List<Column> columns = generatorService.getColumns(GeneratorConstant.DATABASE_TYPE, GeneratorConstant.DATABASE_NAME, name);
-            generatorHelper.generateEntityFile(columns, generatorConfig);
-            generatorHelper.generateMapperFile(columns, generatorConfig);
-            generatorHelper.generateMapperXmlFile(columns, generatorConfig);
-            generatorHelper.generateServiceFile(columns, generatorConfig);
-            generatorHelper.generateServiceImplFile(columns, generatorConfig);
-            generatorHelper.generateControllerFile(columns, generatorConfig);
-            // 打包
-            String zipFile = System.currentTimeMillis() + SUFFIX;
-            FileUtil.compress(GeneratorConstant.TEMP_PATH + "src", zipFile);
-            // 下载
-            FileUtil.download(zipFile, name + SUFFIX, true, response);
-            // 删除临时目录
-            FileUtil.delete(GeneratorConstant.TEMP_PATH);
-        } catch (Exception e) {
-            String message = "代码生成失败," + e.getMessage();
-            log.error(message, e);
-            throw new FileDownloadException(message);
+        String className = name;
+        if (GeneratorConfig.TRIM_YES.equals(generatorConfig.getIsTrim())) {
+            className = RegExUtils.replaceFirst(name, generatorConfig.getTrimValue(), StringUtils.EMPTY);
         }
+
+        generatorConfig.setTableName(name);
+        generatorConfig.setClassName(FebsUtil.underscoreToCamel(className));
+        generatorConfig.setTableComment(remark);
+        // 生成代码到临时目录
+        List<Column> columns = generatorService.getColumns(GeneratorConstant.DATABASE_TYPE, GeneratorConstant.DATABASE_NAME, name);
+        generatorHelper.generateEntityFile(columns, generatorConfig);
+        generatorHelper.generateMapperFile(columns, generatorConfig);
+        generatorHelper.generateMapperXmlFile(columns, generatorConfig);
+        generatorHelper.generateServiceFile(columns, generatorConfig);
+        generatorHelper.generateServiceImplFile(columns, generatorConfig);
+        generatorHelper.generateControllerFile(columns, generatorConfig);
+        // 打包
+        String zipFile = System.currentTimeMillis() + SUFFIX;
+        FileUtil.compress(GeneratorConstant.TEMP_PATH + "src", zipFile);
+        // 下载
+        FileUtil.download(zipFile, name + SUFFIX, true, response);
+        // 删除临时目录
+        FileUtil.delete(GeneratorConstant.TEMP_PATH);
     }
 }

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است