mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
160
pom.xml
160
pom.xml
@@ -14,10 +14,11 @@
|
|||||||
<version>5.0.0-SNAPSHOT</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<description>一个开放平台解决方案项目,基于Spring Cloud实现,目标是能够让用户快速得搭建起自己的开放平台</description>
|
<description>一个开放平台解决方案项目,基于Spring Cloud实现,目标是能够让用户快速得搭建起自己的开放平台</description>
|
||||||
|
<url></url>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>doc</module>
|
<module>doc</module>
|
||||||
<module>sop-common</module>
|
<!-- <module>sop-common</module>-->
|
||||||
<!-- <module>sop-auth</module>-->
|
<!-- <module>sop-auth</module>-->
|
||||||
<module>sop-example</module>
|
<module>sop-example</module>
|
||||||
<module>sop-admin</module>
|
<module>sop-admin</module>
|
||||||
@@ -31,13 +32,142 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<!-- springboot 版本-->
|
||||||
|
<spring-boot.version>2.6.15</spring-boot.version>
|
||||||
|
<!-- spring cloud 版本 -->
|
||||||
|
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
||||||
|
<!-- spring cloud alibaba 版本 -->
|
||||||
|
<!-- 具体版本对应关系见:https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E -->
|
||||||
|
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
||||||
|
<!-- dubbo版本 -->
|
||||||
|
<dubbo.version>3.2.10</dubbo.version>
|
||||||
|
|
||||||
|
<junit.version>4.11</junit.version>
|
||||||
|
<commons-io.version>2.5</commons-io.version>
|
||||||
|
<commons-fileupload.version>1.3.3</commons-fileupload.version>
|
||||||
|
<commons-collection.version>3.2.2</commons-collection.version>
|
||||||
|
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||||
|
<commons-codec.version>1.11</commons-codec.version>
|
||||||
|
<commons-logging.version>1.2</commons-logging.version>
|
||||||
|
<validation-api.version>2.0.1.Final</validation-api.version>
|
||||||
|
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
|
||||||
|
<fastmybatis.version>3.0.12</fastmybatis.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<!-- 加了这个就不需要加版本号了 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud-alibaba.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dubbo</groupId>
|
||||||
|
<artifactId>dubbo-bom</artifactId>
|
||||||
|
<version>${dubbo.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.gitee.durcframework</groupId>
|
||||||
|
<artifactId>fastmybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>${fastmybatis.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>3.14.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>${validation-api.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
<version>${hibernate-validator.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.auth0</groupId>
|
||||||
|
<artifactId>java-jwt</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>transmittable-thread-local</artifactId>
|
||||||
|
<version>2.14.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- commons -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-collections</groupId>
|
||||||
|
<artifactId>commons-collections</artifactId>
|
||||||
|
<version>${commons-collection.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>${commons-io.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>${commons-codec.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
<version>${commons-fileupload.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<version>${commons-logging.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.34</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>aliyun</id>
|
<id>aliyun</id>
|
||||||
@@ -67,6 +197,26 @@
|
|||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
|
<consoleOutput>true</consoleOutput>
|
||||||
|
<failsOnError>true</failsOnError>
|
||||||
|
<linkXRef>false</linkXRef>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>validate</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@@ -4,9 +4,12 @@
|
|||||||
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-admin</artifactId>
|
<artifactId>sop-parent</artifactId>
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>sop-admin</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
@@ -4,41 +4,18 @@
|
|||||||
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>sop-admin</artifactId>
|
||||||
<version>2.6.15</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>com.gitee.sop</groupId>
|
|
||||||
<artifactId>sop-admin-backend</artifactId>
|
<artifactId>sop-admin-backend</artifactId>
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
<!-- springboot 版本-->
|
|
||||||
<spring-boot.version>2.6.15</spring-boot.version>
|
|
||||||
<!-- spring cloud 版本 -->
|
|
||||||
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
|
||||||
<!-- spring cloud alibaba 版本 -->
|
|
||||||
<!-- 具体版本对应关系见:https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E -->
|
|
||||||
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
|
||||||
<!-- dubbo版本 -->
|
|
||||||
<dubbo.version>3.2.10</dubbo.version>
|
|
||||||
|
|
||||||
<junit.version>4.11</junit.version>
|
|
||||||
<commons-io.version>2.5</commons-io.version>
|
|
||||||
<commons-fileupload.version>1.3.3</commons-fileupload.version>
|
|
||||||
<commons-collection.version>3.2.2</commons-collection.version>
|
|
||||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
|
||||||
<commons-codec.version>1.11</commons-codec.version>
|
|
||||||
<commons-logging.version>1.2</commons-logging.version>
|
|
||||||
<validation-api.version>2.0.1.Final</validation-api.version>
|
|
||||||
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
|
|
||||||
<fastmybatis.version>3.0.12</fastmybatis.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -150,110 +127,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<!-- 加了这个就不需要加版本号了 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-dependencies</artifactId>
|
|
||||||
<version>${spring-cloud.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
|
||||||
<version>${spring-cloud-alibaba.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.dubbo</groupId>
|
|
||||||
<artifactId>dubbo-bom</artifactId>
|
|
||||||
<version>${dubbo.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.gitee.durcframework</groupId>
|
|
||||||
<artifactId>fastmybatis-spring-boot-starter</artifactId>
|
|
||||||
<version>${fastmybatis.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
<version>3.14.7</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.validation</groupId>
|
|
||||||
<artifactId>validation-api</artifactId>
|
|
||||||
<version>${validation-api.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-validator</artifactId>
|
|
||||||
<version>${hibernate-validator.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- commons -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>${commons-lang3.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-collections</groupId>
|
|
||||||
<artifactId>commons-collections</artifactId>
|
|
||||||
<version>${commons-collection.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
<version>${commons-io.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-codec</groupId>
|
|
||||||
<artifactId>commons-codec</artifactId>
|
|
||||||
<version>${commons-codec.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-fileupload</groupId>
|
|
||||||
<artifactId>commons-fileupload</artifactId>
|
|
||||||
<version>${commons-fileupload.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
<version>${commons-logging.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.auth0</groupId>
|
|
||||||
<artifactId>java-jwt</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.30</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
<version>3.1.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
@@ -288,6 +161,26 @@
|
|||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
|
<consoleOutput>true</consoleOutput>
|
||||||
|
<failsOnError>true</failsOnError>
|
||||||
|
<linkXRef>false</linkXRef>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>validate</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@@ -23,10 +23,10 @@ import java.util.Objects;
|
|||||||
* @author 六如
|
* @author 六如
|
||||||
*/
|
*/
|
||||||
public class RSATool {
|
public class RSATool {
|
||||||
public static String RSA_ALGORITHM = "RSA";
|
private static final String RSA_ALGORITHM = "RSA";
|
||||||
|
|
||||||
private KeyFormat keyFormat;
|
private final KeyFormat keyFormat;
|
||||||
private KeyLength keyLength;
|
private final KeyLength keyLength;
|
||||||
|
|
||||||
public RSATool(KeyFormat keyFormat, KeyLength keyLength) {
|
public RSATool(KeyFormat keyFormat, KeyLength keyLength) {
|
||||||
this.keyFormat = keyFormat;
|
this.keyFormat = keyFormat;
|
||||||
@@ -120,9 +120,9 @@ public class RSATool {
|
|||||||
Cipher cipher = Cipher.getInstance(keyFormat.getCipherAlgorithm());
|
Cipher cipher = Cipher.getInstance(keyFormat.getCipherAlgorithm());
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||||
// 模长
|
// 模长
|
||||||
int key_len = publicKey.getModulus().bitLength() / 8;
|
int keyLen = publicKey.getModulus().bitLength() / 8;
|
||||||
// 加密数据长度 <= 模长-11
|
// 加密数据长度 <= 模长-11
|
||||||
String[] datas = splitString(data, key_len - 11);
|
String[] datas = splitString(data, keyLen - 11);
|
||||||
String mi = "";
|
String mi = "";
|
||||||
// 如果明文长度大于模长-11则要分组加密
|
// 如果明文长度大于模长-11则要分组加密
|
||||||
for (String s : datas) {
|
for (String s : datas) {
|
||||||
@@ -147,9 +147,9 @@ public class RSATool {
|
|||||||
Cipher cipher = Cipher.getInstance(keyFormat.getCipherAlgorithm());
|
Cipher cipher = Cipher.getInstance(keyFormat.getCipherAlgorithm());
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
|
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
|
||||||
// 模长
|
// 模长
|
||||||
int key_len = privateKey.getModulus().bitLength() / 8;
|
int keyLen = privateKey.getModulus().bitLength() / 8;
|
||||||
// 加密数据长度 <= 模长-11
|
// 加密数据长度 <= 模长-11
|
||||||
String[] datas = splitString(data, key_len - 11);
|
String[] datas = splitString(data, keyLen - 11);
|
||||||
String mi = "";
|
String mi = "";
|
||||||
// 如果明文长度大于模长-11则要分组加密
|
// 如果明文长度大于模长-11则要分组加密
|
||||||
for (String s : datas) {
|
for (String s : datas) {
|
||||||
@@ -174,12 +174,12 @@ public class RSATool {
|
|||||||
Cipher cipher = Cipher.getInstance(keyFormat.getCipherAlgorithm());
|
Cipher cipher = Cipher.getInstance(keyFormat.getCipherAlgorithm());
|
||||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||||
// 模长
|
// 模长
|
||||||
int key_len = privateKey.getModulus().bitLength() / 8;
|
int keyLen = privateKey.getModulus().bitLength() / 8;
|
||||||
byte[] bytes = data.getBytes();
|
byte[] bytes = data.getBytes();
|
||||||
byte[] bcd = ASCII_To_BCD(bytes, bytes.length);
|
byte[] bcd = asciiToBcd(bytes, bytes.length);
|
||||||
// 如果密文长度大于模长则要分组解密
|
// 如果密文长度大于模长则要分组解密
|
||||||
String ming = "";
|
String ming = "";
|
||||||
byte[][] arrays = splitArray(bcd, key_len);
|
byte[][] arrays = splitArray(bcd, keyLen);
|
||||||
for (byte[] arr : arrays) {
|
for (byte[] arr : arrays) {
|
||||||
ming += new String(cipher.doFinal(arr));
|
ming += new String(cipher.doFinal(arr));
|
||||||
}
|
}
|
||||||
@@ -198,19 +198,19 @@ public class RSATool {
|
|||||||
Cipher cipher = Cipher.getInstance(keyFormat.getCipherAlgorithm());
|
Cipher cipher = Cipher.getInstance(keyFormat.getCipherAlgorithm());
|
||||||
cipher.init(Cipher.DECRYPT_MODE, rsaPublicKey);
|
cipher.init(Cipher.DECRYPT_MODE, rsaPublicKey);
|
||||||
// 模长
|
// 模长
|
||||||
int key_len = rsaPublicKey.getModulus().bitLength() / 8;
|
int keyLen = rsaPublicKey.getModulus().bitLength() / 8;
|
||||||
byte[] bytes = data.getBytes();
|
byte[] bytes = data.getBytes();
|
||||||
byte[] bcd = ASCII_To_BCD(bytes, bytes.length);
|
byte[] bcd = asciiToBcd(bytes, bytes.length);
|
||||||
// 如果密文长度大于模长则要分组解密
|
// 如果密文长度大于模长则要分组解密
|
||||||
String ming = "";
|
String ming = "";
|
||||||
byte[][] arrays = splitArray(bcd, key_len);
|
byte[][] arrays = splitArray(bcd, keyLen);
|
||||||
for (byte[] arr : arrays) {
|
for (byte[] arr : arrays) {
|
||||||
ming += new String(cipher.doFinal(arr));
|
ming += new String(cipher.doFinal(arr));
|
||||||
}
|
}
|
||||||
return ming;
|
return ming;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertPkcs8ToPkcs1(byte[] privateKeyData) throws Exception{
|
public static String convertPkcs8ToPkcs1(byte[] privateKeyData) throws Exception {
|
||||||
PrivateKeyInfo pkInfo = PrivateKeyInfo.getInstance(privateKeyData);
|
PrivateKeyInfo pkInfo = PrivateKeyInfo.getInstance(privateKeyData);
|
||||||
ASN1Encodable encodable = pkInfo.parsePrivateKey();
|
ASN1Encodable encodable = pkInfo.parsePrivateKey();
|
||||||
ASN1Primitive primitive = encodable.toASN1Primitive();
|
ASN1Primitive primitive = encodable.toASN1Primitive();
|
||||||
@@ -222,17 +222,17 @@ public class RSATool {
|
|||||||
/**
|
/**
|
||||||
* ASCII码转BCD码
|
* ASCII码转BCD码
|
||||||
*/
|
*/
|
||||||
public static byte[] ASCII_To_BCD(byte[] ascii, int asc_len) {
|
public static byte[] asciiToBcd(byte[] ascii, int asc_len) {
|
||||||
byte[] bcd = new byte[asc_len / 2];
|
byte[] bcd = new byte[asc_len / 2];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < (asc_len + 1) / 2; i++) {
|
for (int i = 0; i < (asc_len + 1) / 2; i++) {
|
||||||
bcd[i] = asc_to_bcd(ascii[j++]);
|
bcd[i] = ascToBcd(ascii[j++]);
|
||||||
bcd[i] = (byte) (((j >= asc_len) ? 0x00 : asc_to_bcd(ascii[j++]) & 0xff) + (bcd[i] << 4));
|
bcd[i] = (byte) (((j >= asc_len) ? 0x00 : ascToBcd(ascii[j++]) & 0xff) + (bcd[i] << 4));
|
||||||
}
|
}
|
||||||
return bcd;
|
return bcd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte asc_to_bcd(byte asc) {
|
public static byte ascToBcd(byte asc) {
|
||||||
byte bcd;
|
byte bcd;
|
||||||
|
|
||||||
if ((asc >= '0') && (asc <= '9')) {
|
if ((asc >= '0') && (asc <= '9')) {
|
||||||
@@ -380,47 +380,4 @@ public class RSATool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------ Test ------------
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
|
|
||||||
RSATool rsa_pkcs8_1024 = new RSATool(KeyFormat.PKCS8, KeyLength.LENGTH_1024);
|
|
||||||
RSATool rsa_pkcs8_2048 = new RSATool(KeyFormat.PKCS8, KeyLength.LENGTH_2048);
|
|
||||||
|
|
||||||
doTest(rsa_pkcs8_1024);
|
|
||||||
doTest(rsa_pkcs8_2048);
|
|
||||||
|
|
||||||
// PKCS在Java环境无法测试,可以生成一对,到非java平台测试,如C#
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void doTest(RSATool rsaTool) throws Exception {
|
|
||||||
System.out.println("秘钥格式:" + rsaTool.keyFormat.name() + ", 秘钥长度:" + rsaTool.keyLength.getLength());
|
|
||||||
KeyStore keys = rsaTool.createKeys();
|
|
||||||
String pubKey = keys.getPublicKey();
|
|
||||||
System.out.println("pubKey:");
|
|
||||||
System.out.println(pubKey);
|
|
||||||
String priKey = keys.getPrivateKey();
|
|
||||||
System.out.println("priKey:");
|
|
||||||
System.out.println(priKey);
|
|
||||||
System.out.println("--------");
|
|
||||||
|
|
||||||
String ming = "你好,abc123~!@=";
|
|
||||||
// 用公钥加密
|
|
||||||
String mi = rsaTool.encryptByPublicKey(ming, rsaTool.getPublicKey(pubKey));
|
|
||||||
System.out.println("mi : " + mi);
|
|
||||||
// 用私钥解密
|
|
||||||
String ming2 = rsaTool.decryptByPrivateKey(mi, rsaTool.getPrivateKey(priKey));
|
|
||||||
System.out.println("ming : " + ming2 + ", 结果:" + ming2.equals(ming));
|
|
||||||
|
|
||||||
// 用私钥加密
|
|
||||||
String mi2 = rsaTool.encryptByPrivateKey(ming, rsaTool.getPrivateKey(priKey));
|
|
||||||
|
|
||||||
System.out.println("mi2 : " + mi2);
|
|
||||||
// 用公钥解密
|
|
||||||
String ming3 = rsaTool.decryptByPublicKey(mi2, rsaTool.getPublicKey(pubKey));
|
|
||||||
System.out.println("ming3 : " + ming3 + ", 结果:" + ming3.equals(ming));
|
|
||||||
System.out.println("---------------------");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -9,10 +9,9 @@ import java.util.Objects;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
public enum StatusEnum {
|
public enum StatusEnum {
|
||||||
DISABLED((byte)2),
|
DISABLED((byte) 2),
|
||||||
ENABLE((byte)1),
|
ENABLE((byte) 1),
|
||||||
SET_PWD((byte)3),
|
SET_PWD((byte) 3);
|
||||||
;
|
|
||||||
|
|
||||||
private final int status;
|
private final int status;
|
||||||
|
|
||||||
|
@@ -9,8 +9,7 @@ public enum ErrorCode {
|
|||||||
JWT_CREATE("1000", "create token error"),
|
JWT_CREATE("1000", "create token error"),
|
||||||
JWT_ERROR("1000", "invalid token"),
|
JWT_ERROR("1000", "invalid token"),
|
||||||
JWT_EXPIRED("1000", "token expired"),
|
JWT_EXPIRED("1000", "token expired"),
|
||||||
SET_PASSWORD("2000", "set password"),
|
SET_PASSWORD("2000", "set password");
|
||||||
;
|
|
||||||
|
|
||||||
ErrorCode(String code, String msg) {
|
ErrorCode(String code, String msg) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
@@ -5,6 +5,7 @@ import lombok.Data;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param <T> 数据
|
||||||
* @author thc
|
* @author thc
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@@ -3,11 +3,9 @@ package com.gitee.sop.adminbackend.service.isv;
|
|||||||
import com.gitee.fastmybatis.core.PageInfo;
|
import com.gitee.fastmybatis.core.PageInfo;
|
||||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||||
import com.gitee.sop.adminbackend.common.SpringContext;
|
|
||||||
import com.gitee.sop.adminbackend.dao.entity.PermIsvGroup;
|
import com.gitee.sop.adminbackend.dao.entity.PermIsvGroup;
|
||||||
import com.gitee.sop.adminbackend.dao.mapper.PermIsvGroupMapper;
|
import com.gitee.sop.adminbackend.dao.mapper.PermIsvGroupMapper;
|
||||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvGroupSettingDTO;
|
import com.gitee.sop.adminbackend.service.isv.dto.IsvGroupSettingDTO;
|
||||||
import com.gitee.sop.adminbackend.service.isv.event.ChangeIsvPermEvent;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -15,7 +13,6 @@ import org.springframework.util.CollectionUtils;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@@ -54,11 +54,10 @@ public class LoginService {
|
|||||||
case LDAP:
|
case LDAP:
|
||||||
// LDAP登录
|
// LDAP登录
|
||||||
throw new UnsupportedOperationException("LDAP登录登录暂未支持");
|
throw new UnsupportedOperationException("LDAP登录登录暂未支持");
|
||||||
default: {
|
default:
|
||||||
// 默认注册账号登录
|
// 默认注册账号登录
|
||||||
userInfo = this.doDatabaseLogin(username, password);
|
userInfo = this.doDatabaseLogin(username, password);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
LoginUser loginUser = buildLoginUser(userInfo);
|
LoginUser loginUser = buildLoginUser(userInfo);
|
||||||
// 保存到缓存
|
// 保存到缓存
|
||||||
userCacheManager.saveUser(loginUser);
|
userCacheManager.saveUser(loginUser);
|
||||||
|
@@ -14,8 +14,7 @@ public enum RegTypeEnum {
|
|||||||
BACKEND("backend"),
|
BACKEND("backend"),
|
||||||
FORM("form"),
|
FORM("form"),
|
||||||
OAUTH("oauth"),
|
OAUTH("oauth"),
|
||||||
LDAP("ldap"),
|
LDAP("ldap");
|
||||||
;
|
|
||||||
|
|
||||||
public static RegTypeEnum of(String source) {
|
public static RegTypeEnum of(String source) {
|
||||||
for (RegTypeEnum value : RegTypeEnum.values()) {
|
for (RegTypeEnum value : RegTypeEnum.values()) {
|
||||||
|
@@ -4,14 +4,15 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class IdGen {
|
public class IdGen {
|
||||||
private static long workId = 0;
|
private static long workId = 0;
|
||||||
private static final SnowflakeIdWorker worker = new SnowflakeIdWorker(workId++, 0);
|
private static final SnowflakeIdWorker SNOWFLAKE_ID_WORKER = new SnowflakeIdWorker(workId++, 0);
|
||||||
|
|
||||||
public static long genId() {
|
public static long genId() {
|
||||||
return worker.nextId();
|
return SNOWFLAKE_ID_WORKER.nextId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成唯一id
|
* 生成唯一id
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String nextId() {
|
public static String nextId() {
|
||||||
@@ -37,51 +38,81 @@ public class IdGen {
|
|||||||
public static class SnowflakeIdWorker {
|
public static class SnowflakeIdWorker {
|
||||||
|
|
||||||
// ==============================Fields===========================================
|
// ==============================Fields===========================================
|
||||||
/** 开始时间截 (2015-01-01) */
|
/**
|
||||||
|
* 开始时间截 (2015-01-01)
|
||||||
|
*/
|
||||||
private final long twepoch = 1420041100000L;
|
private final long twepoch = 1420041100000L;
|
||||||
|
|
||||||
/** 机器id所占的位数 */
|
/**
|
||||||
|
* 机器id所占的位数
|
||||||
|
*/
|
||||||
private final long workerIdBits = 5L;
|
private final long workerIdBits = 5L;
|
||||||
|
|
||||||
/** 数据标识id所占的位数 */
|
/**
|
||||||
|
* 数据标识id所占的位数
|
||||||
|
*/
|
||||||
private final long datacenterIdBits = 5L;
|
private final long datacenterIdBits = 5L;
|
||||||
|
|
||||||
/** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
|
/**
|
||||||
|
* 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数)
|
||||||
|
*/
|
||||||
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||||
|
|
||||||
/** 支持的最大数据标识id,结果是31 */
|
/**
|
||||||
|
* 支持的最大数据标识id,结果是31
|
||||||
|
*/
|
||||||
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
||||||
|
|
||||||
/** 序列在id中占的位数 */
|
/**
|
||||||
|
* 序列在id中占的位数
|
||||||
|
*/
|
||||||
private final long sequenceBits = 12L;
|
private final long sequenceBits = 12L;
|
||||||
|
|
||||||
/** 机器ID向左移12位 */
|
/**
|
||||||
|
* 机器ID向左移12位
|
||||||
|
*/
|
||||||
private final long workerIdShift = sequenceBits;
|
private final long workerIdShift = sequenceBits;
|
||||||
|
|
||||||
/** 数据标识id向左移17位(12+5) */
|
/**
|
||||||
|
* 数据标识id向左移17位(12+5)
|
||||||
|
*/
|
||||||
private final long datacenterIdShift = sequenceBits + workerIdBits;
|
private final long datacenterIdShift = sequenceBits + workerIdBits;
|
||||||
|
|
||||||
/** 时间截向左移22位(5+5+12) */
|
/**
|
||||||
|
* 时间截向左移22位(5+5+12)
|
||||||
|
*/
|
||||||
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||||
|
|
||||||
/** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
|
/**
|
||||||
|
* 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095)
|
||||||
|
*/
|
||||||
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
|
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||||
|
|
||||||
/** 工作机器ID(0~31) */
|
/**
|
||||||
|
* 工作机器ID(0~31)
|
||||||
|
*/
|
||||||
private long workerId;
|
private long workerId;
|
||||||
|
|
||||||
/** 数据中心ID(0~31) */
|
/**
|
||||||
|
* 数据中心ID(0~31)
|
||||||
|
*/
|
||||||
private long datacenterId;
|
private long datacenterId;
|
||||||
|
|
||||||
/** 毫秒内序列(0~4095) */
|
/**
|
||||||
|
* 毫秒内序列(0~4095)
|
||||||
|
*/
|
||||||
private long sequence = 0L;
|
private long sequence = 0L;
|
||||||
|
|
||||||
/** 上次生成ID的时间截 */
|
/**
|
||||||
|
* 上次生成ID的时间截
|
||||||
|
*/
|
||||||
private long lastTimestamp = -1L;
|
private long lastTimestamp = -1L;
|
||||||
|
|
||||||
//==============================Constructors=====================================
|
//==============================Constructors=====================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造函数
|
* 构造函数
|
||||||
|
*
|
||||||
* @param workerId 工作ID (0~31)
|
* @param workerId 工作ID (0~31)
|
||||||
* @param datacenterId 数据中心ID (0~31)
|
* @param datacenterId 数据中心ID (0~31)
|
||||||
*/
|
*/
|
||||||
@@ -97,8 +128,10 @@ public class IdGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ==============================Methods==========================================
|
// ==============================Methods==========================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得下一个ID (该方法是线程安全的)
|
* 获得下一个ID (该方法是线程安全的)
|
||||||
|
*
|
||||||
* @return SnowflakeId
|
* @return SnowflakeId
|
||||||
*/
|
*/
|
||||||
public synchronized long nextId() {
|
public synchronized long nextId() {
|
||||||
@@ -118,9 +151,8 @@ public class IdGen {
|
|||||||
//阻塞到下一个毫秒,获得新的时间戳
|
//阻塞到下一个毫秒,获得新的时间戳
|
||||||
timestamp = tilNextMillis(lastTimestamp);
|
timestamp = tilNextMillis(lastTimestamp);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
//时间戳改变,毫秒内序列重置
|
//时间戳改变,毫秒内序列重置
|
||||||
else {
|
|
||||||
sequence = 0L;
|
sequence = 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +168,7 @@ public class IdGen {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 阻塞到下一个毫秒,直到获得新的时间戳
|
* 阻塞到下一个毫秒,直到获得新的时间戳
|
||||||
|
*
|
||||||
* @param lastTimestamp 上次生成ID的时间截
|
* @param lastTimestamp 上次生成ID的时间截
|
||||||
* @return 当前时间戳
|
* @return 当前时间戳
|
||||||
*/
|
*/
|
||||||
@@ -149,6 +182,7 @@ public class IdGen {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回以毫秒为单位的当前时间
|
* 返回以毫秒为单位的当前时间
|
||||||
|
*
|
||||||
* @return 当前时间(毫秒)
|
* @return 当前时间(毫秒)
|
||||||
*/
|
*/
|
||||||
protected long timeGen() {
|
protected long timeGen() {
|
||||||
@@ -156,16 +190,4 @@ public class IdGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*//==============================Test=============================================
|
|
||||||
*/
|
|
||||||
/** 测试
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
long id = idWorker.nextId();
|
|
||||||
System.out.println("id:" + id);
|
|
||||||
System.out.println("toBinaryString:" + Long.toBinaryString(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ import java.util.Set;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class JwtUtil {
|
public class JwtUtil {
|
||||||
|
|
||||||
private static final Map<String, Object> headerClaims = new HashMap<>();
|
private static final Map<String, Object> HEADER_CLAIMS = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录成功后跳转页面
|
* 登录成功后跳转页面
|
||||||
@@ -39,12 +39,12 @@ public class JwtUtil {
|
|||||||
));
|
));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
headerClaims.put("typ", "JWT");
|
HEADER_CLAIMS.put("typ", "JWT");
|
||||||
headerClaims.put("alg", "HS256");
|
HEADER_CLAIMS.put("alg", "HS256");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createJwt(Map<String, String> data, int timeoutDays, String secret) {
|
public static String createJwt(Map<String, String> data, int timeoutDays, String secret) {
|
||||||
JWTCreator.Builder builder = JWT.create().withHeader(headerClaims);
|
JWTCreator.Builder builder = JWT.create().withHeader(HEADER_CLAIMS);
|
||||||
Set<Map.Entry<String, String>> entrySet = data.entrySet();
|
Set<Map.Entry<String, String>> entrySet = data.entrySet();
|
||||||
for (Map.Entry<String, String> entry : entrySet) {
|
for (Map.Entry<String, String> entry : entrySet) {
|
||||||
builder.withClaim(entry.getKey(), entry.getValue());
|
builder.withClaim(entry.getKey(), entry.getValue());
|
||||||
|
@@ -25,13 +25,9 @@ public class PasswordUtil {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String password = getRandomPassword(32);
|
|
||||||
System.out.println(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 随机密码生成,仅字母数字
|
* 随机密码生成,仅字母数字
|
||||||
|
*
|
||||||
* @param len 密码长度,必须大于等于4
|
* @param len 密码长度,必须大于等于4
|
||||||
*/
|
*/
|
||||||
public static String getRandomSimplePassword(int len) {
|
public static String getRandomSimplePassword(int len) {
|
||||||
@@ -48,6 +44,7 @@ public class PasswordUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 随机密码生成
|
* 随机密码生成
|
||||||
|
*
|
||||||
* @param len 密码长度,必须大于等于6
|
* @param len 密码长度,必须大于等于6
|
||||||
*/
|
*/
|
||||||
public static String getRandomPassword(int len) {
|
public static String getRandomPassword(int len) {
|
||||||
|
129
sop-example/example-payment/pom.xml
Normal file
129
sop-example/example-payment/pom.xml
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
<?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>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.6.15</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>com.gitee.sop</groupId>
|
||||||
|
<artifactId>example-payment</artifactId>
|
||||||
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
|
<name>example-payment</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<!-- dubbo版本 -->
|
||||||
|
<dubbo.version>3.2.10</dubbo.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gitee.sop</groupId>
|
||||||
|
<artifactId>sop-spring-boot-starter</artifactId>
|
||||||
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dubbo</groupId>
|
||||||
|
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- nacos注册中心 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dubbo</groupId>
|
||||||
|
<artifactId>dubbo-nacos-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 仅在开发中使用 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dubbo</groupId>
|
||||||
|
<artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
|
||||||
|
<version>${dubbo.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>1.6.14</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.34</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dubbo</groupId>
|
||||||
|
<artifactId>dubbo-bom</artifactId>
|
||||||
|
<version>${dubbo.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<!-- 打包时跳过测试 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.12.4</version>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spring-milestones</id>
|
||||||
|
<name>Spring Milestones</name>
|
||||||
|
<url>https://repo.spring.io/milestone</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>maven_central</id>
|
||||||
|
<name>Maven Central</name>
|
||||||
|
<url>https://repo.maven.apache.org/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
</project>
|
@@ -0,0 +1,16 @@
|
|||||||
|
package com.gitee.sop.payment;
|
||||||
|
|
||||||
|
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableDubbo
|
||||||
|
public class ExamplePaymentApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ExamplePaymentApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,25 @@
|
|||||||
|
package com.gitee.sop.payment.open;
|
||||||
|
|
||||||
|
import com.gitee.sop.payment.open.req.AlipayTradeWapPayRequest;
|
||||||
|
import com.gitee.sop.payment.open.resp.AlipayTradeWapPayResponse;
|
||||||
|
import com.gitee.sop.support.annotation.Open;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付接口
|
||||||
|
*
|
||||||
|
* @author 六如
|
||||||
|
*/
|
||||||
|
public interface OpenPayment {
|
||||||
|
|
||||||
|
@ApiOperation(
|
||||||
|
value = "alipay.trade.wap.pay(手机网站支付接口2.0)",
|
||||||
|
notes = "该接口是页面跳转接口,用于生成用户访问支付宝的跳转链接。" +
|
||||||
|
"请在服务端执行支付宝SDK中pageExecute方法,读取响应中的body()结果。" +
|
||||||
|
"该结果用于跳转到支付宝页面,返回到用户浏览器渲染或重定向跳转到支付宝页面。" +
|
||||||
|
"具体使用方法请参考 <a href=\"https://torna.cn\" target=\"_blank\">接入指南</a>"
|
||||||
|
)
|
||||||
|
@Open(value = "alipay.trade.wap.pay", version = "2.0")
|
||||||
|
AlipayTradeWapPayResponse tradeWapPay(AlipayTradeWapPayRequest request);
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
package com.gitee.sop.payment.open.impl;
|
||||||
|
|
||||||
|
import com.gitee.sop.payment.open.OpenPayment;
|
||||||
|
import com.gitee.sop.payment.open.req.AlipayTradeWapPayRequest;
|
||||||
|
import com.gitee.sop.payment.open.resp.AlipayTradeWapPayResponse;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboService;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开放接口实现
|
||||||
|
*
|
||||||
|
* @author 六如
|
||||||
|
*/
|
||||||
|
@DubboService(validation = "true")
|
||||||
|
public class OpenPaymentImpl implements OpenPayment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlipayTradeWapPayResponse tradeWapPay(AlipayTradeWapPayRequest request) {
|
||||||
|
AlipayTradeWapPayResponse alipayTradeWapPayResponse = new AlipayTradeWapPayResponse();
|
||||||
|
alipayTradeWapPayResponse.setPageRedirectionData(UUID.randomUUID().toString());
|
||||||
|
return alipayTradeWapPayResponse;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,177 @@
|
|||||||
|
package com.gitee.sop.payment.open.req;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* alipay.trade.wap.pay(手机网站支付接口2.0)
|
||||||
|
*
|
||||||
|
* @author 六如
|
||||||
|
* https://opendocs.alipay.com/open/29ae8cb6_alipay.trade.wap.pay?pathHash=1ef587fd&ref=api&scene=21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AlipayTradeWapPayRequest {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "商户网站唯一订单号", required = true, example = "70501111111S001111119")
|
||||||
|
@Length(max = 64)
|
||||||
|
@NotBlank
|
||||||
|
private String out_trade_no;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "订单总金额.单位为元,精确到小数点后两位,取值范围:[0.01,100000000] ",
|
||||||
|
required = true, example = "9.00")
|
||||||
|
@NotNull
|
||||||
|
private BigDecimal total_amount;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "订单标题。注意:不可使用特殊字符,如 /,=,& 等。",
|
||||||
|
required = true,
|
||||||
|
example = "大乐透"
|
||||||
|
)
|
||||||
|
@Length(max = 256)
|
||||||
|
@NotBlank
|
||||||
|
private String subject;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "销售产品码,商家和支付宝签约的产品码。手机网站支付为:QUICK_WAP_WAY",
|
||||||
|
required = true,
|
||||||
|
example = "QUICK_WAP_WAY"
|
||||||
|
)
|
||||||
|
@NotBlank
|
||||||
|
@Length(max = 64)
|
||||||
|
private String product_code;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "针对用户授权接口,获取用户相关数据时,用于标识用户授权关系",
|
||||||
|
example = "appopenBb64d181d0146481ab6a762c00714cC27"
|
||||||
|
)
|
||||||
|
@Length(max = 40)
|
||||||
|
private String auth_token;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "用户付款中途退出返回商户网站的地址",
|
||||||
|
example = "http://www.taobao.com/product/113714.html"
|
||||||
|
)
|
||||||
|
@Length(max = 400)
|
||||||
|
private String quit_url;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "订单包含的商品列表信息,json格式,其它说明详见商品明细说明"
|
||||||
|
)
|
||||||
|
private List<GoodsDetail> goods_detail;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "绝对超时时间,格式为yyyy-MM-dd HH:mm:ss。超时时间范围:1m~15d。",
|
||||||
|
example = "2016-12-31 10:05:00"
|
||||||
|
)
|
||||||
|
@Length(max = 32)
|
||||||
|
private String time_expire;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商户传入业务信息,具体值要和支付宝约定,应用于安全,营销等参数直传场景,格式为json格式",
|
||||||
|
example = "{\"mc_create_trade_ip\":\"127.0.0.1\"}"
|
||||||
|
)
|
||||||
|
@Length(max = 512)
|
||||||
|
private String business_params;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "公用回传参数,如果请求时传递了该参数,则返回给商户时会回传该参数。支付宝只会在同步返回(包括跳转回商户网站)和异步通知时将该参数原样返回。本参数必须进行UrlEncode之后才可以发送给支付宝。",
|
||||||
|
example = "merchantBizType%3d3C%26merchantBizNo%3d2016010101111"
|
||||||
|
)
|
||||||
|
@Length(max = 512)
|
||||||
|
private String passback_params;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商户原始订单号,最大长度限制32位",
|
||||||
|
example = "{\"mc_create_trade_ip\":\"127.0.0.1\"}"
|
||||||
|
)
|
||||||
|
@Length(max = 32)
|
||||||
|
private String merchant_order_no;
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class GoodsDetail {
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商品的编号",
|
||||||
|
required = true,
|
||||||
|
example = "apple-01"
|
||||||
|
)
|
||||||
|
@NotBlank
|
||||||
|
@Length(max = 64)
|
||||||
|
private String goods_id;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商品名称",
|
||||||
|
required = true,
|
||||||
|
example = "ipad"
|
||||||
|
)
|
||||||
|
@NotBlank
|
||||||
|
@Length(max = 256)
|
||||||
|
private String goods_name;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商品数量",
|
||||||
|
required = true,
|
||||||
|
example = "1"
|
||||||
|
)
|
||||||
|
@NotNull
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商品单价,单位为元",
|
||||||
|
required = true,
|
||||||
|
example = "2000"
|
||||||
|
)
|
||||||
|
@NotNull
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "支付宝定义的统一商品编号",
|
||||||
|
example = "20010001"
|
||||||
|
)
|
||||||
|
@Length(max = 32)
|
||||||
|
private String alipay_goods_id;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商品类目",
|
||||||
|
example = "34543238"
|
||||||
|
)
|
||||||
|
@Length(max = 24)
|
||||||
|
private String goods_category;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商品类目树,从商品类目根节点到叶子节点的类目id组成,类目id值使用|分割",
|
||||||
|
example = "124868003|126232002|126252004"
|
||||||
|
)
|
||||||
|
@Length(max = 128)
|
||||||
|
private String categories_tree;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商品描述信息",
|
||||||
|
example = "特价手机"
|
||||||
|
)
|
||||||
|
@Length(max = 1000)
|
||||||
|
private String body;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "商品的展示地址",
|
||||||
|
example = "http://www.alipay.com/xxx.jpg"
|
||||||
|
)
|
||||||
|
@Length(max = 400)
|
||||||
|
private String show_url;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,19 @@
|
|||||||
|
package com.gitee.sop.payment.open.resp;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 六如
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AlipayTradeWapPayResponse {
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
value = "用于跳转支付宝页面的信息,POST和GET方法生成内容不同:使用POST方法执行,结果为html form表单,在浏览器渲染即可;使用GET方法会得到支付宝URL,需要打开或重定向到该URL。建议使用POST方式。具体使用方法请参考",
|
||||||
|
required = true,
|
||||||
|
example = "请参考响应示例"
|
||||||
|
)
|
||||||
|
private String pageRedirectionData;
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,9 @@
|
|||||||
|
spring.profiles.active=dev
|
||||||
|
|
||||||
|
server.port=7072
|
||||||
|
spring.application.name=example-payment
|
||||||
|
|
||||||
|
dubbo.protocol.name=dubbo
|
||||||
|
dubbo.protocol.port=-1
|
||||||
|
dubbo.application.qos-enable=false
|
||||||
|
dubbo.registry.address=zookeeper://localhost:2181
|
25
sop-example/example-story/.gitignore
vendored
Normal file
25
sop-example/example-story/.gitignore
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
nbproject/private/
|
||||||
|
build/
|
||||||
|
nbbuild/
|
||||||
|
dist/
|
||||||
|
nbdist/
|
||||||
|
.nb-gradle/
|
||||||
|
/local-config/
|
@@ -11,9 +11,9 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>com.gitee.sop</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-story</artifactId>
|
<artifactId>example-story</artifactId>
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
<name>sop-story</name>
|
<name>example-story</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
@@ -6,10 +6,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableDubbo
|
@EnableDubbo
|
||||||
public class SopStoryApplication {
|
public class ExampleStoryApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(SopStoryApplication.class, args);
|
SpringApplication.run(ExampleStoryApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -0,0 +1 @@
|
|||||||
|
dubbo.registry.address=zookeeper://localhost:2181
|
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
dubbo.registry.address=nacos://localhost:8848
|
@@ -0,0 +1 @@
|
|||||||
|
abc,你好~!@#
|
@@ -0,0 +1,10 @@
|
|||||||
|
# 错误配置
|
||||||
|
|
||||||
|
# 系统配置
|
||||||
|
isp.error_isv.common-error=The system is busy.
|
||||||
|
isp.error_isv.invalid-parameter=Invalid parameter, {0}
|
||||||
|
|
||||||
|
# ==== 参数配置 ====
|
||||||
|
|
||||||
|
goods.remark.notNull=The goods_remark can not be null
|
||||||
|
goods.comment.length=The goods_comment length must >= {0} and <= {1}
|
@@ -0,0 +1,14 @@
|
|||||||
|
# 错误配置
|
||||||
|
|
||||||
|
# 系统繁忙
|
||||||
|
isp.error_isv.common-error=\u7cfb\u7edf\u7e41\u5fd9
|
||||||
|
# 参数无效
|
||||||
|
isp.error_isv.invalid-parameter=\u53c2\u6570\u65e0\u6548, {0}
|
||||||
|
|
||||||
|
# ==== 参数配置 ====
|
||||||
|
|
||||||
|
# 商品备注不能为空
|
||||||
|
goods.remark.notNull=\u5546\u54c1\u5907\u6ce8\u4e0d\u80fd\u4e3a\u7a7a
|
||||||
|
# 商品评论长度必须在{0}和{1}之间
|
||||||
|
goods.comment.length=\u5546\u54c1\u8bc4\u8bba\u957f\u5ea6\u5fc5\u987b\u5728{0}\u548c{1}\u4e4b\u95f4
|
||||||
|
|
@@ -0,0 +1,2 @@
|
|||||||
|
isp.goods_error_100=the goods_name can NOT be null
|
||||||
|
isp.goods_error_101=the goods_name must bigger than {0}
|
@@ -0,0 +1,5 @@
|
|||||||
|
# 商品名字不能为空
|
||||||
|
isp.goods_error_100=\u5546\u54C1\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||||
|
|
||||||
|
# 商品名称太短,不能小于{0}个字
|
||||||
|
isp.goods_error_101=\u5546\u54C1\u540D\u79F0\u592A\u77ED\uFF0C\u4E0D\u80FD\u5C0F\u4E8E{0}\u4E2A\u5B57
|
@@ -3,13 +3,14 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<groupId>com.gitee.sop</groupId>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-example</artifactId>
|
<artifactId>sop-example</artifactId>
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>sop-story</module>
|
<module>example-story</module>
|
||||||
|
<module>example-payment</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -4,41 +4,17 @@
|
|||||||
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>sop-parent</artifactId>
|
||||||
<version>2.6.15</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>com.gitee.sop</groupId>
|
|
||||||
<artifactId>sop-gateway</artifactId>
|
<artifactId>sop-gateway</artifactId>
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
<!-- springboot 版本-->
|
|
||||||
<spring-boot.version>2.6.15</spring-boot.version>
|
|
||||||
<!-- spring cloud 版本 -->
|
|
||||||
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
|
||||||
<!-- spring cloud alibaba 版本 -->
|
|
||||||
<!-- 具体版本对应关系见:https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E -->
|
|
||||||
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
|
||||||
<!-- dubbo版本 -->
|
|
||||||
<dubbo.version>3.2.10</dubbo.version>
|
|
||||||
|
|
||||||
<junit.version>4.11</junit.version>
|
|
||||||
<commons-io.version>2.5</commons-io.version>
|
|
||||||
<commons-fileupload.version>1.3.3</commons-fileupload.version>
|
|
||||||
<commons-collection.version>3.2.2</commons-collection.version>
|
|
||||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
|
||||||
<commons-codec.version>1.11</commons-codec.version>
|
|
||||||
<commons-logging.version>1.2</commons-logging.version>
|
|
||||||
<validation-api.version>2.0.1.Final</validation-api.version>
|
|
||||||
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
|
|
||||||
<fastmybatis.version>3.0.12</fastmybatis.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -139,106 +115,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<!-- 加了这个就不需要加版本号了 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-dependencies</artifactId>
|
|
||||||
<version>${spring-cloud.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
|
||||||
<version>${spring-cloud-alibaba.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.dubbo</groupId>
|
|
||||||
<artifactId>dubbo-bom</artifactId>
|
|
||||||
<version>${dubbo.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.gitee.durcframework</groupId>
|
|
||||||
<artifactId>fastmybatis-spring-boot-starter</artifactId>
|
|
||||||
<version>${fastmybatis.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
<version>3.14.7</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.validation</groupId>
|
|
||||||
<artifactId>validation-api</artifactId>
|
|
||||||
<version>${validation-api.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-validator</artifactId>
|
|
||||||
<version>${hibernate-validator.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- commons -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>${commons-lang3.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-collections</groupId>
|
|
||||||
<artifactId>commons-collections</artifactId>
|
|
||||||
<version>${commons-collection.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
<version>${commons-io.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-codec</groupId>
|
|
||||||
<artifactId>commons-codec</artifactId>
|
|
||||||
<version>${commons-codec.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-fileupload</groupId>
|
|
||||||
<artifactId>commons-fileupload</artifactId>
|
|
||||||
<version>${commons-fileupload.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
<version>${commons-logging.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.34</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
<version>3.1.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>aliyun</id>
|
<id>aliyun</id>
|
||||||
|
@@ -72,12 +72,12 @@ public class ApiResponse {
|
|||||||
/**
|
/**
|
||||||
* 业务异常码
|
* 业务异常码
|
||||||
*/
|
*/
|
||||||
private String sub_code = "";
|
private String subCode = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务异常信息
|
* 业务异常信息
|
||||||
*/
|
*/
|
||||||
private String sub_msg = "";
|
private String subMsg = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回对象
|
* 返回对象
|
||||||
@@ -98,8 +98,8 @@ public class ApiResponse {
|
|||||||
IError error = e.getError();
|
IError error = e.getError();
|
||||||
apiResponse.setCode(error.getCode());
|
apiResponse.setCode(error.getCode());
|
||||||
apiResponse.setMsg(error.getMsg());
|
apiResponse.setMsg(error.getMsg());
|
||||||
apiResponse.setSub_code(error.getSubCode());
|
apiResponse.setSubCode(error.getSubCode());
|
||||||
apiResponse.setSub_msg(error.getSubMsg());
|
apiResponse.setSubMsg(error.getSubMsg());
|
||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +109,8 @@ public class ApiResponse {
|
|||||||
IError error = errorMeta.getError(locale);
|
IError error = errorMeta.getError(locale);
|
||||||
apiResponse.setCode(error.getCode());
|
apiResponse.setCode(error.getCode());
|
||||||
apiResponse.setMsg(error.getMsg());
|
apiResponse.setMsg(error.getMsg());
|
||||||
apiResponse.setSub_code(error.getSubCode());
|
apiResponse.setSubCode(error.getSubCode());
|
||||||
apiResponse.setSub_msg(subMsg);
|
apiResponse.setSubMsg(subMsg);
|
||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +120,8 @@ public class ApiResponse {
|
|||||||
IError error = errorMeta.getError(locale);
|
IError error = errorMeta.getError(locale);
|
||||||
apiResponse.setCode(error.getCode());
|
apiResponse.setCode(error.getCode());
|
||||||
apiResponse.setMsg(error.getMsg());
|
apiResponse.setMsg(error.getMsg());
|
||||||
apiResponse.setSub_code(error.getSubCode());
|
apiResponse.setSubCode(error.getSubCode());
|
||||||
apiResponse.setSub_msg(error.getSubMsg());
|
apiResponse.setSubMsg(error.getSubMsg());
|
||||||
return apiResponse;
|
return apiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,11 +8,13 @@ import com.gitee.sop.gateway.service.manager.ApiManager;
|
|||||||
import com.gitee.sop.gateway.util.CopyUtil;
|
import com.gitee.sop.gateway.util.CopyUtil;
|
||||||
import com.gitee.sop.support.service.ApiRegisterService;
|
import com.gitee.sop.support.service.ApiRegisterService;
|
||||||
import com.gitee.sop.support.service.dto.RegisterDTO;
|
import com.gitee.sop.support.service.dto.RegisterDTO;
|
||||||
|
import com.gitee.sop.support.service.dto.RegisterResult;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
import org.apache.dubbo.config.annotation.DubboService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 六如
|
* @author 六如
|
||||||
*/
|
*/
|
||||||
@@ -23,26 +25,44 @@ public class ApiRegisterServiceImpl implements ApiRegisterService {
|
|||||||
private static final int REG_SOURCE_SYS = 1;
|
private static final int REG_SOURCE_SYS = 1;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiManager apiCacheManager;
|
private ApiManager apiManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiInfoMapper apiInfoMapper;
|
private ApiInfoMapper apiInfoMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(RegisterDTO registerDTO) {
|
public RegisterResult register(RegisterDTO registerDTO) {
|
||||||
log.info("收到接口注册, registerDTO={}", registerDTO);
|
log.info("收到接口注册, registerDTO={}", registerDTO);
|
||||||
|
|
||||||
|
try {
|
||||||
ApiInfoDTO apiInfoDTO = CopyUtil.copyBean(registerDTO, ApiInfoDTO::new);
|
ApiInfoDTO apiInfoDTO = CopyUtil.copyBean(registerDTO, ApiInfoDTO::new);
|
||||||
apiInfoDTO.setStatus(StatusEnum.ENABLE.getValue());
|
apiInfoDTO.setStatus(StatusEnum.ENABLE.getValue());
|
||||||
|
|
||||||
ApiInfo apiInfo = apiInfoMapper.getByNameVersion(apiInfoDTO.getApiName(), apiInfoDTO.getApiVersion());
|
ApiInfo apiInfo = apiInfoMapper.getByNameVersion(apiInfoDTO.getApiName(), apiInfoDTO.getApiVersion());
|
||||||
|
|
||||||
if (apiInfo == null) {
|
if (apiInfo == null) {
|
||||||
apiInfo = new ApiInfo();
|
apiInfo = new ApiInfo();
|
||||||
|
} else {
|
||||||
|
check(apiInfo, registerDTO);
|
||||||
}
|
}
|
||||||
CopyUtil.copyPropertiesIgnoreNull(apiInfoDTO, apiInfo);
|
CopyUtil.copyPropertiesIgnoreNull(apiInfoDTO, apiInfo);
|
||||||
apiInfo.setRegSource(REG_SOURCE_SYS);
|
apiInfo.setRegSource(REG_SOURCE_SYS);
|
||||||
// 保存到数据库
|
// 保存到数据库
|
||||||
apiInfoMapper.saveOrUpdate(apiInfo);
|
apiInfoMapper.saveOrUpdate(apiInfo);
|
||||||
|
apiInfoDTO.setId(apiInfo.getId());
|
||||||
// 保存到缓存
|
// 保存到缓存
|
||||||
apiCacheManager.save(apiInfoDTO);
|
apiManager.save(apiInfoDTO);
|
||||||
|
return RegisterResult.success();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("接口注册失败, registerDTO={}", registerDTO, e);
|
||||||
|
return RegisterResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check(ApiInfo apiInfo, RegisterDTO registerDTO) {
|
||||||
|
if (!Objects.equals(apiInfo.getApplication(), registerDTO.getApplication())) {
|
||||||
|
throw new RuntimeException("接口[" + registerDTO + "]已存在于[" + apiInfo.getApplication() + "]应用中.必须保证接口全局唯一");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ public class ResultRouteInterceptor implements RouteInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result instanceof Map) {
|
if (result instanceof Map) {
|
||||||
Map<String, Object> map = (Map<String, Object>) result;
|
Map<?, ?> map = (Map<?, ?>) result;
|
||||||
Object className = map.get(CLASS);
|
Object className = map.get(CLASS);
|
||||||
// 处理文件下载
|
// 处理文件下载
|
||||||
if (Objects.equals(className, FileData.class.getName()) || Objects.equals(className, CommonFileData.class.getName())) {
|
if (Objects.equals(className, FileData.class.getName()) || Objects.equals(className, CommonFileData.class.getName())) {
|
||||||
|
@@ -62,7 +62,7 @@ public class ApiValidator implements Validator {
|
|||||||
private ApiConfig apiConfig;
|
private ApiConfig apiConfig;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiManager apiCacheManager;
|
private ApiManager apiManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IpBlacklistManager ipBlacklistManager;
|
private IpBlacklistManager ipBlacklistManager;
|
||||||
@@ -94,7 +94,7 @@ public class ApiValidator implements Validator {
|
|||||||
checkIP(apiRequestContext);
|
checkIP(apiRequestContext);
|
||||||
|
|
||||||
ApiRequest apiRequest = apiRequestContext.getApiRequest();
|
ApiRequest apiRequest = apiRequestContext.getApiRequest();
|
||||||
ApiInfoDTO apiInfo = apiCacheManager.get(apiRequest.getMethod(), apiRequest.getVersion());
|
ApiInfoDTO apiInfo = apiManager.get(apiRequest.getMethod(), apiRequest.getVersion());
|
||||||
// 检查接口信息
|
// 检查接口信息
|
||||||
checkApiInfo(apiRequestContext, apiInfo, isvDTO);
|
checkApiInfo(apiRequestContext, apiInfo, isvDTO);
|
||||||
|
|
||||||
|
@@ -3,15 +3,10 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.gitee.sop</groupId>
|
|
||||||
<artifactId>sop-parent</artifactId>
|
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.gitee.sop</groupId>
|
||||||
<artifactId>sop-sdk</artifactId>
|
<artifactId>sop-sdk</artifactId>
|
||||||
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
|
|||||||
import com.gitee.sop.support.annotation.Open;
|
import com.gitee.sop.support.annotation.Open;
|
||||||
import com.gitee.sop.support.service.ApiRegisterService;
|
import com.gitee.sop.support.service.ApiRegisterService;
|
||||||
import com.gitee.sop.support.service.dto.RegisterDTO;
|
import com.gitee.sop.support.service.dto.RegisterDTO;
|
||||||
|
import com.gitee.sop.support.service.dto.RegisterResult;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -109,10 +110,9 @@ public class ApiRegister {
|
|||||||
registerDTO.setIsPermission(parseBoolean(open.permission()));
|
registerDTO.setIsPermission(parseBoolean(open.permission()));
|
||||||
registerDTO.setIsNeedToken(parseBoolean(open.needToken()));
|
registerDTO.setIsNeedToken(parseBoolean(open.needToken()));
|
||||||
LOG.info("注册开放接口, apiInfo=" + registerDTO);
|
LOG.info("注册开放接口, apiInfo=" + registerDTO);
|
||||||
try {
|
RegisterResult result = apiRegisterService.register(registerDTO);
|
||||||
apiRegisterService.register(registerDTO);
|
if (!result.getSuccess()) {
|
||||||
} catch (Exception e) {
|
throw new RuntimeException(result.getMsg());
|
||||||
LOG.error("接口注册失败, registerDTO=" + registerDTO + ", method=" + method, e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package com.gitee.sop.support.service;
|
package com.gitee.sop.support.service;
|
||||||
|
|
||||||
import com.gitee.sop.support.service.dto.RegisterDTO;
|
import com.gitee.sop.support.service.dto.RegisterDTO;
|
||||||
|
import com.gitee.sop.support.service.dto.RegisterResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 六如
|
* @author 六如
|
||||||
@@ -11,5 +12,5 @@ public interface ApiRegisterService {
|
|||||||
*
|
*
|
||||||
* @param registerDTO 接口信息
|
* @param registerDTO 接口信息
|
||||||
*/
|
*/
|
||||||
void register(RegisterDTO registerDTO);
|
RegisterResult register(RegisterDTO registerDTO);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,31 @@
|
|||||||
|
package com.gitee.sop.support.service.dto;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 六如
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RegisterResult implements Serializable {
|
||||||
|
private static final long serialVersionUID = 4605838522659698419L;
|
||||||
|
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
public static RegisterResult success() {
|
||||||
|
RegisterResult registerResult = new RegisterResult();
|
||||||
|
registerResult.setSuccess(true);
|
||||||
|
return registerResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RegisterResult error(String msg) {
|
||||||
|
RegisterResult registerResult = new RegisterResult();
|
||||||
|
registerResult.setSuccess(false);
|
||||||
|
registerResult.setMsg(msg);
|
||||||
|
return registerResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -3,8 +3,12 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<groupId>com.gitee.sop</groupId>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.gitee.sop</groupId>
|
||||||
|
<artifactId>sop-parent</artifactId>
|
||||||
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
<artifactId>sop-test</artifactId>
|
<artifactId>sop-test</artifactId>
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
|
|
||||||
@@ -50,4 +54,52 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-parameters</arg>
|
||||||
|
</compilerArgs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -39,16 +39,19 @@ public class AlipayClientPostTest extends TestBase {
|
|||||||
// 公共请求参数
|
// 公共请求参数
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("app_id", appId);
|
params.put("app_id", appId);
|
||||||
params.put("method", "story.get");
|
params.put("method", "alipay.trade.wap.pay");
|
||||||
params.put("format", "json");
|
params.put("format", "json");
|
||||||
params.put("charset", "utf-8");
|
params.put("charset", "utf-8");
|
||||||
params.put("sign_type", "RSA2");
|
params.put("sign_type", "RSA2");
|
||||||
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||||
params.put("version", "1.0");
|
params.put("version", "2.0");
|
||||||
|
|
||||||
// 业务参数
|
// 业务参数
|
||||||
Map<String, Object> bizContent = new HashMap<>();
|
Map<String, Object> bizContent = new HashMap<>();
|
||||||
bizContent.put("id", "1");
|
bizContent.put("out_trade_no", "70501111111S001111119");
|
||||||
|
bizContent.put("total_amount", "9.00");
|
||||||
|
bizContent.put("subject", "衣服");
|
||||||
|
bizContent.put("product_code", "QUICK_WAP_WAY");
|
||||||
|
|
||||||
params.put("biz_content", JSON.toJSONString(bizContent));
|
params.put("biz_content", JSON.toJSONString(bizContent));
|
||||||
String content = AlipaySignature.getSignContent(params);
|
String content = AlipaySignature.getSignContent(params);
|
||||||
|
@@ -96,7 +96,7 @@ public class AllInOneTest extends TestBase {
|
|||||||
System.out.println(responseData);
|
System.out.println(responseData);
|
||||||
String node = requestInfo.getDataNode();
|
String node = requestInfo.getDataNode();
|
||||||
JSONObject jsonObject = JSON.parseObject(responseData).getJSONObject(node);
|
JSONObject jsonObject = JSON.parseObject(responseData).getJSONObject(node);
|
||||||
Assert.assertEquals("isv.route-no-permissions", jsonObject.getString("sub_code"));
|
Assert.assertEquals("isv.route-no-permissions", jsonObject.getString("subCode"));
|
||||||
});
|
});
|
||||||
|
|
||||||
//client.execute(requestBuilder);
|
//client.execute(requestBuilder);
|
||||||
@@ -182,7 +182,7 @@ public class AllInOneTest extends TestBase {
|
|||||||
.callback((requestInfo, responseData) -> {
|
.callback((requestInfo, responseData) -> {
|
||||||
System.out.println(responseData);
|
System.out.println(responseData);
|
||||||
JSONObject jsonObject = JSON.parseObject(responseData);
|
JSONObject jsonObject = JSON.parseObject(responseData);
|
||||||
Assert.assertEquals(jsonObject.getString("sub_code"), "isv.invalid-file-size");
|
Assert.assertEquals(jsonObject.getString("subCode"), "isv.invalid-file-size");
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ public class AllInOneTest extends TestBase {
|
|||||||
.callback((requestInfo, responseData) -> {
|
.callback((requestInfo, responseData) -> {
|
||||||
System.out.println(responseData);
|
System.out.println(responseData);
|
||||||
JSONObject jsonObject = JSON.parseObject(responseData);
|
JSONObject jsonObject = JSON.parseObject(responseData);
|
||||||
Assert.assertEquals(jsonObject.getString("sub_code"), "isv.invalid-file-size");
|
Assert.assertEquals(jsonObject.getString("subCode"), "isv.invalid-file-size");
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ public class AllInOneTest extends TestBase {
|
|||||||
.callback((requestInfo, responseData) -> {
|
.callback((requestInfo, responseData) -> {
|
||||||
System.out.println(responseData);
|
System.out.println(responseData);
|
||||||
JSONObject jsonObject = JSON.parseObject(responseData);
|
JSONObject jsonObject = JSON.parseObject(responseData);
|
||||||
Assert.assertEquals("Nonexistent method name", jsonObject.getString("sub_msg"));
|
Assert.assertEquals("Nonexistent method name", jsonObject.getString("subMsg"));
|
||||||
});
|
});
|
||||||
|
|
||||||
client.execute(requestBuilder);
|
client.execute(requestBuilder);
|
||||||
|
Reference in New Issue
Block a user