chore: 调整项目结构
diff --git a/gateway/pom.xml b/gateway/pom.xml
index d9600f6..0772813 100644
--- a/gateway/pom.xml
+++ b/gateway/pom.xml
@@ -4,9 +4,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>com.supwisdom.institute</groupId>
- <artifactId>sw-backend-parent</artifactId>
- <version>0.0.2-SNAPSHOT</version>
+ <groupId>com.supwisdom.buildcommons</groupId>
+ <artifactId>spring-cloud-parent</artifactId>
+ <version>Finchley.RELEASE-1.1</version>
</parent>
<groupId>com.supwisdom.institute</groupId>
@@ -18,9 +18,100 @@
<description>Supwisdom Backend Framework Gateway project</description>
<properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <java.version>1.8</java.version>
+
+ <argLine>-Dfile.encoding=UTF-8</argLine>
+
+ <downloadSources>true</downloadSources>
+ <downloadJavadocs>true</downloadJavadocs>
+
+ <maven.compiler.source>${java.version}</maven.compiler.source>
+ <maven.compiler.target>${java.version}</maven.compiler.target>
+
+ <dockerfile-maven-plugin.version>1.4.8</dockerfile-maven-plugin.version>
+ <dockerfile.image.server>harbor.supwisdom.com</dockerfile.image.server>
+ <dockerfile.image.prefix>sw-admin-framework</dockerfile.image.prefix>
+
+ <infras.version>0.1.1-SNAPSHOT</infras.version>
+
+ <io.springfox.version>2.9.2</io.springfox.version>
+
+ <mybatis.spring.boot.version>1.3.1</mybatis.spring.boot.version>
+
<start-class>com.supwisdom.institute.backend.gateway.Application</start-class>
</properties>
+ <distributionManagement>
+ <repository>
+ <id>supwisdom-releases</id>
+ <name>internal release</name>
+ <url>https://app.supwisdom.com/nexus/content/repositories/releases</url>
+ </repository>
+ <snapshotRepository>
+ <id>supwisdom-snapshots</id>
+ <name>internal snapshots</name>
+ <url>https://app.supwisdom.com/nexus/content/repositories/snapshots</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>supwisdom</id>
+ <url>https://app.supwisdom.com/nexus/content/groups/public/</url>
+ </repository>
+ <repository>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <id>central</id>
+ <url>http://repo.maven.apache.org/maven2</url>
+ </repository>
+ </repositories>
+
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>com.supwisdom.infras</groupId>
+ <artifactId>infras-bom</artifactId>
+ <version>${infras.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.supwisdom.institute</groupId>
+ <artifactId>sw-backend-common-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.supwisdom.institute</groupId>
+ <artifactId>sw-backend-common-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.supwisdom.institute</groupId>
+ <artifactId>sw-backend-common-framework</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>fastjson</artifactId>
+ <version>1.2.56</version>
+ </dependency>
+
+
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
@@ -100,6 +191,15 @@
<groupId>com.supwisdom.institute</groupId>
<artifactId>sw-backend-common-framework</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-redis</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>redis.clients</groupId>
+ <artifactId>jedis</artifactId>
+ </dependency>
<dependency>
<groupId>commons-codec</groupId>
@@ -112,14 +212,14 @@
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
- </dependency>
+ </dependency> -->
<!-- 热部署,无需重启项目 -->
@@ -140,6 +240,26 @@
<build>
<finalName>${project.artifactId}</finalName>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>${dockerfile-maven-plugin.version}</version>
+ <configuration>
+ <repository>${dockerfile.image.server}/${dockerfile.image.prefix}/${project.artifactId}</repository>
+ <tag>${project.version}</tag>
+ <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
+ <buildArgs>
+ <JAR_FILE>${project.build.finalName}.${project.packaging}</JAR_FILE>
+ <VERSION>${project.version}</VERSION>
+ <NAME>${project.artifactId}</NAME>
+ </buildArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -162,52 +282,6 @@
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
-
- <!-- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <configuration>
- <encoding>${project.build.sourceEncoding}</encoding>
- </configuration>
- <executions>
- <execution>
- <id>copy-doc-resources</id>
- <phase>package</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <encoding>utf-8</encoding>
- <outputDirectory>${basedir}/target/doc</outputDirectory>
- <overwrite>true</overwrite>
- <resources>
- <resource>
- <directory>${basedir}/../../doc</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>copy-certs-jwt-resources</id>
- <phase>package</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <encoding>utf-8</encoding>
- <outputDirectory>${basedir}/target/certs/jwt</outputDirectory>
- <overwrite>true</overwrite>
- <resources>
- <resource>
- <directory>${basedir}/../../certs/jwt</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin> -->
-
-
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
diff --git a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/configuration/AuthnRestTemplateConfig.java b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/configuration/AuthnRestTemplateConfig.java
index 789f930..9041e1a 100644
--- a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/configuration/AuthnRestTemplateConfig.java
+++ b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/configuration/AuthnRestTemplateConfig.java
@@ -92,8 +92,8 @@
return factory;
}
- @Bean(name = "authnAccountRestTemplate")
- public RestTemplate authnAccountRestTemplate(ClientHttpRequestFactory requestFactory) {
+ @Bean(name = "authnRestTemplate")
+ public RestTemplate authnRestTemplate(ClientHttpRequestFactory requestFactory) {
return new RestTemplate(requestFactory);
}
diff --git a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/web/client/AuthnRemoteRestTemplate.java b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/web/client/AuthnRemoteClient.java
similarity index 98%
rename from gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/web/client/AuthnRemoteRestTemplate.java
rename to gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/web/client/AuthnRemoteClient.java
index b0fe53d..78d8c3f 100644
--- a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/web/client/AuthnRemoteRestTemplate.java
+++ b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/remote/web/client/AuthnRemoteClient.java
@@ -12,7 +12,7 @@
@Slf4j
@Component
-public class AuthnRemoteRestTemplate {
+public class AuthnRemoteClient {
@Autowired
private RestTemplate authnRestTemplate;
diff --git a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/service/AuthnService.java b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/service/AuthnService.java
index 13434ec..160c5d8 100644
--- a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/service/AuthnService.java
+++ b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/authn/service/AuthnService.java
@@ -12,18 +12,18 @@
import com.supwisdom.institute.backend.gateway.authn.model.ResourceRoleSet;
import com.supwisdom.institute.backend.gateway.authn.model.Role;
import com.supwisdom.institute.backend.gateway.authn.model.Route;
-import com.supwisdom.institute.backend.gateway.authn.remote.web.client.AuthnRemoteRestTemplate;
+import com.supwisdom.institute.backend.gateway.authn.remote.web.client.AuthnRemoteClient;
@Slf4j
@Service
public class AuthnService {
@Autowired
- private AuthnRemoteRestTemplate authnRemote;
+ private AuthnRemoteClient authnRemoteClient;
public Account account(String username) {
- JSONObject jsonObject = authnRemote.account(username);
+ JSONObject jsonObject = authnRemoteClient.account(username);
if (jsonObject == null) {
return null;
}
@@ -40,7 +40,7 @@
public List<Role> accountRoles(String username) {
- JSONObject jsonObject = authnRemote.accountRoles(username);
+ JSONObject jsonObject = authnRemoteClient.accountRoles(username);
if (jsonObject == null) {
return null;
}
@@ -57,7 +57,7 @@
public List<ResourceRoleSet> resourceRoleSets() {
- JSONObject jsonObject = authnRemote.resourceRoleSets();
+ JSONObject jsonObject = authnRemoteClient.resourceRoleSets();
if (jsonObject == null) {
return null;
}
@@ -74,7 +74,7 @@
public List<Route> routes() {
- JSONObject jsonObject = authnRemote.routes();
+ JSONObject jsonObject = authnRemoteClient.routes();
if (jsonObject == null) {
return null;
}
diff --git a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/security/core/userdetails/InMemeryUserDetailsService.java b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/security/core/userdetails/InMemeryUserDetailsService.java
index 4e761a5..5dea61c 100644
--- a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/security/core/userdetails/InMemeryUserDetailsService.java
+++ b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/security/core/userdetails/InMemeryUserDetailsService.java
@@ -59,13 +59,6 @@
MyUser myUser = new MyUser(username, passwordEncoder.encode(username), authorities, attributes);
log.debug("myUser is {}", myUser);
- List<String> roles = new ArrayList<>();
- roles.add("ROLE_ADMIN");
- roles.add("administrator");
- roles.add("user");
- User user = new User(username, roles, attributes);
- UserContext.setUser(user);
-
return Mono.just(myUser);
}