Merge remote-tracking branch 'origin/master' into dev
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
<property name="LOG_PATTERN" value="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx" />
|
<property name="LOG_PATTERN" value="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx" />
|
||||||
<!-- 定义日志存储的路径 -->
|
<!-- 定义日志存储的路径 -->
|
||||||
<property name="FILE_PATH" value="../log" />
|
<property name="FILE_PATH" value="../log" />
|
||||||
<property name="FILE_NAME" value="schisandra-cloud-storage.log" />
|
<property name="FILE_NAME" value="schisandra-cloud-storage-auth.log" />
|
||||||
</Properties>
|
</Properties>
|
||||||
|
|
||||||
<!--https://logging.apache.org/log4j/2.x/manual/appenders.html-->
|
<!--https://logging.apache.org/log4j/2.x/manual/appenders.html-->
|
||||||
|
@@ -7,6 +7,14 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>schisandra-cloud-storage-oss</name>
|
<name>schisandra-cloud-storage-oss</name>
|
||||||
|
<modules>
|
||||||
|
<module>schisandra-cloud-storage-oss-starter</module>
|
||||||
|
<module>schisandra-cloud-storage-oss-infra</module>
|
||||||
|
<module>schisandra-cloud-storage-oss-domain</module>
|
||||||
|
<module>schisandra-cloud-storage-oss-common</module>
|
||||||
|
<module>schisandra-cloud-storage-oss-api</module>
|
||||||
|
<module>schisandra-cloud-storage-oss-application</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
@@ -22,87 +30,13 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<exclusions>
|
<version>2.4.2</version>
|
||||||
<exclusion>
|
<type>pom</type>
|
||||||
<artifactId>spring-boot-starter-logging</artifactId>
|
<scope>import</scope>
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.minio</groupId>
|
|
||||||
<artifactId>minio</artifactId>
|
|
||||||
<version>8.2.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.24</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<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>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>${spring-boot.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>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
<!--打包成jar包时的名字-->
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>2.3.0.RELEASE</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>central</id>
|
<id>central</id>
|
||||||
|
@@ -0,0 +1,39 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-api</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-api</name>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
<version>3.0.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||||
|
<version>3.0.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.24</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@@ -0,0 +1 @@
|
|||||||
|
api 对外接口
|
@@ -0,0 +1 @@
|
|||||||
|
api 实体
|
@@ -0,0 +1,27 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-application</name>
|
||||||
|
<modules>
|
||||||
|
<module>schisandra-cloud-storage-oss-application-controller</module>
|
||||||
|
<module>schisandra-cloud-storage-oss-application-job</module>
|
||||||
|
<module>schisandra-cloud-storage-oss-application-mq</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@@ -0,0 +1,73 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application-controller</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-application-controller</name>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.24</version>
|
||||||
|
</path>
|
||||||
|
<!-- 必须要加, 否则生成不了 MapperImpl 实现类 -->
|
||||||
|
<path>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>1.4.2.Final</version>
|
||||||
|
</path>
|
||||||
|
<!-- 如果是 0.1.0 有可能出现生成了maptruct的实现类, 但该类只创建了对象, 没有进行赋值 -->
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||||
|
<version>0.2.0</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<version>2.4.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-domain</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@@ -0,0 +1,25 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application-job</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-application-job</name>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@@ -0,0 +1,25 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application-mq</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-application-mq</name>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@@ -0,0 +1,100 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-common</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-common</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>2.12.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.12.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.24</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct</artifactId>
|
||||||
|
<version>1.4.2.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>1.4.2.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||||
|
<version>2.4.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.79</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>19.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.11</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 提供Redis连接池 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-pool2</artifactId>
|
||||||
|
<version>2.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
<version>2.5.15</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-extra</artifactId>
|
||||||
|
<version>5.8.27</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.directory.studio</groupId>
|
||||||
|
<artifactId>org.apache.commons.codec</artifactId>
|
||||||
|
<version>1.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@@ -0,0 +1,29 @@
|
|||||||
|
package com.schisandra.oss.common.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页请求实体
|
||||||
|
*
|
||||||
|
* @author: landaiqing
|
||||||
|
*/
|
||||||
|
public class PageInfo {
|
||||||
|
|
||||||
|
private Integer pageNo = 1;
|
||||||
|
|
||||||
|
private Integer pageSize = 20;
|
||||||
|
|
||||||
|
public Integer getPageNo() {
|
||||||
|
if (pageNo == null || pageNo < 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return pageNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPageSize() {
|
||||||
|
if (pageSize == null || pageSize < 1 || pageSize > Integer.MAX_VALUE) {
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
return pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,57 @@
|
|||||||
|
package com.schisandra.oss.common.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页返回实体
|
||||||
|
*
|
||||||
|
* @author: landaiqing
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PageResult<T> implements Serializable {
|
||||||
|
|
||||||
|
private Integer pageNo = 1;
|
||||||
|
|
||||||
|
private Integer pageSize = 20;
|
||||||
|
|
||||||
|
private Integer total = 0;
|
||||||
|
|
||||||
|
private Integer totalPages = 0;
|
||||||
|
|
||||||
|
private List<T> result = Collections.emptyList();
|
||||||
|
|
||||||
|
private Integer start = 1;
|
||||||
|
|
||||||
|
private Integer end = 0;
|
||||||
|
|
||||||
|
public void setRecords(List<T> result) {
|
||||||
|
this.result = result;
|
||||||
|
if (result != null && result.size() > 0) {
|
||||||
|
setTotal(result.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(Integer total) {
|
||||||
|
this.total = total;
|
||||||
|
if (this.pageSize > 0) {
|
||||||
|
this.totalPages = (total / this.pageSize) + (total % this.pageSize == 0 ? 0 : 1);
|
||||||
|
} else {
|
||||||
|
this.totalPages = 0;
|
||||||
|
}
|
||||||
|
this.start = (this.pageSize > 0 ? (this.pageNo - 1) * this.pageSize : 0) + 1;
|
||||||
|
this.end = (this.start - 1 + this.pageSize * (this.pageNo > 0 ? 1 : 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageSize(Integer pageSize) {
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageNo(Integer pageNo) {
|
||||||
|
this.pageNo = pageNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,56 @@
|
|||||||
|
package com.schisandra.oss.common.entity;
|
||||||
|
|
||||||
|
import com.schisandra.oss.common.enums.ResultCodeEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 返回结果泛型类
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/3/22 13:09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Result<T> {
|
||||||
|
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
public static Result ok() {
|
||||||
|
Result result = new Result();
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setCode(ResultCodeEnum.SUCCESS.getCode());
|
||||||
|
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Result ok(T data) {
|
||||||
|
Result result = new Result();
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setCode(ResultCodeEnum.SUCCESS.getCode());
|
||||||
|
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
|
||||||
|
result.setData(data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Result fail() {
|
||||||
|
Result result = new Result();
|
||||||
|
result.setSuccess(false);
|
||||||
|
result.setCode(ResultCodeEnum.FAIL.getCode());
|
||||||
|
result.setMessage(ResultCodeEnum.FAIL.getDesc());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Result fail(T data) {
|
||||||
|
Result result = new Result();
|
||||||
|
result.setSuccess(false);
|
||||||
|
result.setCode(ResultCodeEnum.FAIL.getCode());
|
||||||
|
result.setMessage(ResultCodeEnum.FAIL.getDesc());
|
||||||
|
result.setData(data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,34 @@
|
|||||||
|
package com.schisandra.oss.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除状态枚举
|
||||||
|
*
|
||||||
|
* @author: landaiqing
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum IsDeletedFlagEnum {
|
||||||
|
|
||||||
|
DELETED(1,"已删除"),
|
||||||
|
UN_DELETED(0,"未删除");
|
||||||
|
|
||||||
|
public int code;
|
||||||
|
|
||||||
|
public String desc;
|
||||||
|
|
||||||
|
IsDeletedFlagEnum(int code, String desc){
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IsDeletedFlagEnum getByCode(int codeVal){
|
||||||
|
for(IsDeletedFlagEnum resultCodeEnum : IsDeletedFlagEnum.values()){
|
||||||
|
if(resultCodeEnum.code == codeVal){
|
||||||
|
return resultCodeEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,34 @@
|
|||||||
|
package com.schisandra.oss.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户状态枚举
|
||||||
|
*
|
||||||
|
* @author: landaiqing
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum OssStatusEnum {
|
||||||
|
|
||||||
|
OPEN(0,"启用"),
|
||||||
|
CLOSE(1,"禁用");
|
||||||
|
|
||||||
|
public int code;
|
||||||
|
|
||||||
|
public String desc;
|
||||||
|
|
||||||
|
OssStatusEnum(int code, String desc){
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OssStatusEnum getByCode(int codeVal){
|
||||||
|
for(OssStatusEnum resultCodeEnum : OssStatusEnum.values()){
|
||||||
|
if(resultCodeEnum.code == codeVal){
|
||||||
|
return resultCodeEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,34 @@
|
|||||||
|
package com.schisandra.oss.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 返回结果状态枚举
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/3/22 13:10
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum ResultCodeEnum {
|
||||||
|
|
||||||
|
SUCCESS(200, "成功"),
|
||||||
|
FAIL(500, "失败");
|
||||||
|
|
||||||
|
public int code;
|
||||||
|
|
||||||
|
public String desc;
|
||||||
|
|
||||||
|
ResultCodeEnum(int code, String desc) {
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResultCodeEnum getByCode(int codeVal) {
|
||||||
|
for (ResultCodeEnum resultCodeEnum : ResultCodeEnum.values()) {
|
||||||
|
if (resultCodeEnum.code == codeVal) {
|
||||||
|
return resultCodeEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,46 @@
|
|||||||
|
package com.schisandra.oss.common.redis;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis的config处理
|
||||||
|
*
|
||||||
|
* @author: landaiqing
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RedisConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||||
|
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||||
|
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
|
||||||
|
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||||
|
redisTemplate.setKeySerializer(redisSerializer);
|
||||||
|
redisTemplate.setHashKeySerializer(redisSerializer);
|
||||||
|
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer());
|
||||||
|
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer());
|
||||||
|
return redisTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer() {
|
||||||
|
Jackson2JsonRedisSerializer<Object> jsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||||
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||||
|
jsonRedisSerializer.setObjectMapper(objectMapper);
|
||||||
|
return jsonRedisSerializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,107 @@
|
|||||||
|
package com.schisandra.oss.common.redis;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RedisUtil工具类
|
||||||
|
*
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/2/19
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class RedisUtil {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
private static final String CACHE_KEY_SEPARATOR = ".";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建缓存key
|
||||||
|
*/
|
||||||
|
public String buildKey(String... strObjs) {
|
||||||
|
return Stream.of(strObjs).collect(Collectors.joining(CACHE_KEY_SEPARATOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否存在key
|
||||||
|
*/
|
||||||
|
public boolean exist(String key) {
|
||||||
|
return redisTemplate.hasKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除key
|
||||||
|
*/
|
||||||
|
public boolean del(String key) {
|
||||||
|
return redisTemplate.delete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set(不带过期)
|
||||||
|
*/
|
||||||
|
public void set(String key, String value) {
|
||||||
|
redisTemplate.opsForValue().set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set(带过期)
|
||||||
|
*/
|
||||||
|
public boolean setNx(String key, String value, Long time, TimeUnit timeUnit) {
|
||||||
|
return redisTemplate.opsForValue().setIfAbsent(key, value, time, timeUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取string类型缓存
|
||||||
|
*/
|
||||||
|
public String get(String key) {
|
||||||
|
return (String) redisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean zAdd(String key, String value, Long score) {
|
||||||
|
return redisTemplate.opsForZSet().add(key, value, Double.valueOf(String.valueOf(score)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long countZset(String key) {
|
||||||
|
return redisTemplate.opsForZSet().size(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> rangeZset(String key, long start, long end) {
|
||||||
|
return redisTemplate.opsForZSet().range(key, start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long removeZset(String key, Object value) {
|
||||||
|
return redisTemplate.opsForZSet().remove(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeZsetList(String key, Set<String> value) {
|
||||||
|
value.stream().forEach((val) -> redisTemplate.opsForZSet().remove(key, val));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double score(String key, Object value) {
|
||||||
|
return redisTemplate.opsForZSet().score(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> rangeByScore(String key, long start, long end) {
|
||||||
|
return redisTemplate.opsForZSet().rangeByScore(key, Double.valueOf(String.valueOf(start)), Double.valueOf(String.valueOf(end)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object addScore(String key, Object obj, double score) {
|
||||||
|
return redisTemplate.opsForZSet().incrementScore(key, obj, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object rank(String key, Object obj) {
|
||||||
|
return redisTemplate.opsForZSet().rank(key, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,110 @@
|
|||||||
|
package com.schisandra.oss.common.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName AESUtils 一定要选择16位密钥长度,也就是KEY_LENGTH=16*8,36的话就需要修改环境的jar包。
|
||||||
|
* @Description TODO
|
||||||
|
* @Author L
|
||||||
|
* @Date 2024/1/26 17:27
|
||||||
|
*/
|
||||||
|
public class AESUtils {
|
||||||
|
/**
|
||||||
|
* 加密算法AES
|
||||||
|
*/
|
||||||
|
private static final String KEY_ALGORITHM = "AES";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* key的长度,Wrong key size: must be equal to 128, 192 or 256
|
||||||
|
* 传入时需要16、24、36
|
||||||
|
*/
|
||||||
|
private static final int KEY_LENGTH = 16 * 8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 算法名称/加密模式/数据填充方式
|
||||||
|
* 默认:AES/ECB/PKCS5Padding
|
||||||
|
*/
|
||||||
|
private static final String ALGORITHMS = "AES/ECB/PKCS5Padding";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后端AES的key,由静态代码块赋值
|
||||||
|
*/
|
||||||
|
public static String key;
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
key = getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取key
|
||||||
|
*/
|
||||||
|
public static String getKey() {
|
||||||
|
int length = KEY_LENGTH / 8;
|
||||||
|
StringBuilder uid = new StringBuilder(length);
|
||||||
|
//产生32位的强随机数
|
||||||
|
Random rd = new SecureRandom();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
//产生0-2的3位随机数
|
||||||
|
switch (rd.nextInt(3)) {
|
||||||
|
case 0:
|
||||||
|
//0-9的随机数
|
||||||
|
uid.append(rd.nextInt(10));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
//ASCII在65-90之间为大写,获取大写随机
|
||||||
|
uid.append((char) (rd.nextInt(26) + 65));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//ASCII在97-122之间为小写,获取小写随机
|
||||||
|
uid.append((char) (rd.nextInt(26) + 97));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uid.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AES 加密
|
||||||
|
*
|
||||||
|
* @param content 加密的字符串
|
||||||
|
* @param encryptKey key值
|
||||||
|
*/
|
||||||
|
public static String encrypt(String content, String encryptKey) throws Exception {
|
||||||
|
//设置Cipher对象
|
||||||
|
Cipher cipher = Cipher.getInstance(ALGORITHMS);
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), KEY_ALGORITHM));
|
||||||
|
|
||||||
|
//调用doFinal
|
||||||
|
// 转base64
|
||||||
|
return Base64.encodeBase64String(cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AES 解密
|
||||||
|
*
|
||||||
|
* @param encryptStr 解密的字符串
|
||||||
|
* @param decryptKey 解密的key值
|
||||||
|
*/
|
||||||
|
public static String decrypt(String encryptStr, String decryptKey) throws Exception {
|
||||||
|
//base64格式的key字符串转byte
|
||||||
|
byte[] decodeBase64 = Base64.decodeBase64(encryptStr);
|
||||||
|
|
||||||
|
|
||||||
|
//设置Cipher对象
|
||||||
|
Cipher cipher = Cipher.getInstance(ALGORITHMS);
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decryptKey.getBytes(), KEY_ALGORITHM));
|
||||||
|
//调用doFinal解密
|
||||||
|
return new String(cipher.doFinal(decodeBase64));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,61 @@
|
|||||||
|
package com.schisandra.oss.common.utils;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
|
public class MD5Util {
|
||||||
|
//十六进制下数字到字符的映射数组
|
||||||
|
private final static String[] hexDigits = {"0", "1", "2", "3", "4",
|
||||||
|
"5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把inputString加密
|
||||||
|
*/
|
||||||
|
public static String md5(String inputString) {
|
||||||
|
return encodeByMD5(inputString);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 对字符串进行MD5加密
|
||||||
|
*/
|
||||||
|
private static String encodeByMD5(String originString) {
|
||||||
|
if (originString != null) {
|
||||||
|
try {
|
||||||
|
//创建具有指定算法名称的信息摘要
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
//使用指定的字节数组对摘要进行最后更新,然后完成摘要计算
|
||||||
|
byte[] results = md.digest(originString.getBytes("utf-8"));
|
||||||
|
//将得到的字节数组变成字符串返回
|
||||||
|
String resultString = byteArrayToHexString(results);
|
||||||
|
return resultString.toUpperCase();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 转换字节数组为十六进制字符串
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return 十六进制字符串
|
||||||
|
*/
|
||||||
|
private static String byteArrayToHexString(byte[] b) {
|
||||||
|
StringBuffer resultSb = new StringBuffer();
|
||||||
|
for (int i = 0; i < b.length; i++) {
|
||||||
|
resultSb.append(byteToHexString(b[i]));
|
||||||
|
}
|
||||||
|
return resultSb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String byteToHexString(byte b) {
|
||||||
|
int n = b;
|
||||||
|
if (n < 0) {
|
||||||
|
n += 256;
|
||||||
|
}
|
||||||
|
int d1 = n / 16;
|
||||||
|
int d2 = n % 16;
|
||||||
|
return hexDigits[d1] + hexDigits[d2];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,172 @@
|
|||||||
|
package com.schisandra.oss.common.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.security.Key;
|
||||||
|
import java.security.KeyFactory;
|
||||||
|
import java.security.KeyPair;
|
||||||
|
import java.security.KeyPairGenerator;
|
||||||
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RSAUtils
|
||||||
|
* @Description TODO
|
||||||
|
* @Author L
|
||||||
|
* @Date 2024/1/26 17:28
|
||||||
|
*/
|
||||||
|
public class RSAUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密算法RSA
|
||||||
|
*/
|
||||||
|
private static final String KEY_ALGORITHM = "RSA";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 算法名称/加密模式/数据填充方式
|
||||||
|
* 默认:RSA/ECB/PKCS1Padding
|
||||||
|
*/
|
||||||
|
private static final String ALGORITHMS = "RSA/ECB/PKCS1Padding";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA最大加密明文大小
|
||||||
|
*/
|
||||||
|
private static final int MAX_ENCRYPT_BLOCK = 245;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA最大解密密文大小
|
||||||
|
*/
|
||||||
|
private static final int MAX_DECRYPT_BLOCK = 256;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA 位数 如果采用2048 上面最大加密和最大解密则须填写: 245 256
|
||||||
|
*/
|
||||||
|
private static final int INITIALIZE_LENGTH = 2048;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后端RSA的密钥对(公钥和私钥)Map,由静态代码块赋值
|
||||||
|
*/
|
||||||
|
private static final Map<String, String> map = new LinkedHashMap<>(2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成密钥对(公钥和私钥)
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static Map<String,String> genKeyPair() throws Exception {
|
||||||
|
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
|
||||||
|
keyPairGen.initialize(INITIALIZE_LENGTH);
|
||||||
|
KeyPair keyPair = keyPairGen.generateKeyPair();
|
||||||
|
// 获取公钥
|
||||||
|
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
|
||||||
|
// 获取私钥
|
||||||
|
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
|
||||||
|
// 得到公钥字符串
|
||||||
|
String publicKeyString = Base64.encodeBase64String(publicKey.getEncoded());
|
||||||
|
// 得到私钥字符串
|
||||||
|
String privateKeyString = Base64.encodeBase64String((privateKey.getEncoded()));
|
||||||
|
map.put("publicKey",publicKeyString);
|
||||||
|
map.put("privateKey",privateKeyString);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
public static String getPrivateKey(){
|
||||||
|
return map.get("privateKey");
|
||||||
|
}
|
||||||
|
public static String getPublicKey(){
|
||||||
|
return map.get("publicKey");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* RSA私钥解密
|
||||||
|
* @param data BASE64编码过的密文
|
||||||
|
* @param privateKey 私钥(BASE64编码)
|
||||||
|
* @return utf-8编码的明文
|
||||||
|
*/
|
||||||
|
public static byte[] decryptByPrivateKey(byte[] data, String privateKey) throws Exception {
|
||||||
|
//base64格式的key字符串转Key对象
|
||||||
|
Key privateK = KeyFactory.getInstance(KEY_ALGORITHM).generatePrivate(new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey)));
|
||||||
|
Cipher cipher = Cipher.getInstance(ALGORITHMS);
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, privateK);
|
||||||
|
|
||||||
|
//分段进行解密操作
|
||||||
|
return encryptAndDecryptOfSubsection(data, cipher, MAX_DECRYPT_BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA公钥加密
|
||||||
|
* @param data BASE64编码过的密文
|
||||||
|
* @param publicKey 公钥(BASE64编码)
|
||||||
|
* @return utf-8编码的明文
|
||||||
|
*/
|
||||||
|
public static byte[] encryptByPublicKey(byte[] data, String publicKey) throws Exception {
|
||||||
|
//base64格式的key字符串转Key对象
|
||||||
|
Key publicK = KeyFactory.getInstance(KEY_ALGORITHM).generatePublic(new X509EncodedKeySpec(Base64.decodeBase64(publicKey)));
|
||||||
|
Cipher cipher = Cipher.getInstance(ALGORITHMS);
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, publicK);
|
||||||
|
//分段进行加密操作
|
||||||
|
return encryptAndDecryptOfSubsection(data, cipher, MAX_ENCRYPT_BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA公钥解密
|
||||||
|
* @param data BASE64编码过的密文
|
||||||
|
* @param publicKey RSA公钥
|
||||||
|
* @return utf-8编码的明文
|
||||||
|
*/
|
||||||
|
public static byte[] pubKeyDec(byte[] data, String publicKey) throws Exception {
|
||||||
|
//base64格式的key字符串转Key对象
|
||||||
|
Key privateK = KeyFactory.getInstance(KEY_ALGORITHM).generatePublic(new X509EncodedKeySpec(Base64.decodeBase64(publicKey)));
|
||||||
|
Cipher cipher = Cipher.getInstance(ALGORITHMS);
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, privateK);
|
||||||
|
|
||||||
|
//分段进行解密操作
|
||||||
|
return encryptAndDecryptOfSubsection(data, cipher, MAX_DECRYPT_BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA私钥加密
|
||||||
|
* @param data 待加密的明文
|
||||||
|
* @param privateKey RSA私钥
|
||||||
|
* @return 经BASE64编码后的密文
|
||||||
|
*/
|
||||||
|
public static byte[] privKeyEnc(byte[] data, String privateKey) throws Exception {
|
||||||
|
|
||||||
|
//base64格式的key字符串转Key对象
|
||||||
|
Key publicK = KeyFactory.getInstance(KEY_ALGORITHM).generatePrivate(new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey)));
|
||||||
|
Cipher cipher = Cipher.getInstance(ALGORITHMS);
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, publicK);
|
||||||
|
|
||||||
|
//分段进行加密操作
|
||||||
|
return encryptAndDecryptOfSubsection(data, cipher, MAX_ENCRYPT_BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分段进行加密、解密操作
|
||||||
|
*/
|
||||||
|
private static byte[] encryptAndDecryptOfSubsection(byte[] data, Cipher cipher, int encryptBlock) throws Exception {
|
||||||
|
int inputLen = data.length;
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
int offSet = 0;
|
||||||
|
byte[] cache;
|
||||||
|
int i = 0;
|
||||||
|
// 对数据分段加密
|
||||||
|
while (inputLen - offSet > 0) {
|
||||||
|
if (inputLen - offSet > encryptBlock) {
|
||||||
|
cache = cipher.doFinal(data, offSet, encryptBlock);
|
||||||
|
} else {
|
||||||
|
cache = cipher.doFinal(data, offSet, inputLen - offSet);
|
||||||
|
}
|
||||||
|
out.write(cache, 0, cache.length);
|
||||||
|
i++;
|
||||||
|
offSet = i * encryptBlock;
|
||||||
|
}
|
||||||
|
out.close();
|
||||||
|
return out.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,68 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-domain</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-domain</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.24</version>
|
||||||
|
</path>
|
||||||
|
<!-- 必须要加, 否则生成不了 MapperImpl 实现类 -->
|
||||||
|
<path>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>1.4.2.Final</version>
|
||||||
|
</path>
|
||||||
|
<!-- 如果是 0.1.0 有可能出现生成了maptruct的实现类, 但该类只创建了对象, 没有进行赋值 -->
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||||
|
<version>0.2.0</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-infra</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@@ -0,0 +1,53 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-infra</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-infra</name>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!--jdbcStarter-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
<version>2.4.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!--druid连接池-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>1.1.21</version>
|
||||||
|
</dependency>
|
||||||
|
<!--mysql-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.33</version>
|
||||||
|
</dependency>
|
||||||
|
<!--mybatis plus-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@@ -0,0 +1,51 @@
|
|||||||
|
package com.schisandra.oss.infra.basic.utils;
|
||||||
|
|
||||||
|
import com.alibaba.druid.filter.config.ConfigTools;
|
||||||
|
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.NoSuchProviderException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库加密util
|
||||||
|
*
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/3/21
|
||||||
|
*/
|
||||||
|
public class DruidEncryptUtil {
|
||||||
|
|
||||||
|
private static String publicKey;
|
||||||
|
|
||||||
|
private static String privateKey;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
String[] keyPair = ConfigTools.genKeyPair(512);
|
||||||
|
privateKey = keyPair[0];
|
||||||
|
System.out.println("privateKey:" + privateKey);
|
||||||
|
publicKey = keyPair[1];
|
||||||
|
System.out.println("publicKey:" + publicKey);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchProviderException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String encrypt(String plainText) throws Exception {
|
||||||
|
String encrypt = ConfigTools.encrypt(privateKey, plainText);
|
||||||
|
System.out.println("encrypt:" + encrypt);
|
||||||
|
return encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String decrypt(String encryptText) throws Exception {
|
||||||
|
String decrypt = ConfigTools.decrypt(publicKey, encryptText);
|
||||||
|
System.out.println("decrypt:" + decrypt);
|
||||||
|
return decrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
String encrypt = encrypt("");
|
||||||
|
System.out.println("encrypt:" + encrypt);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,137 @@
|
|||||||
|
<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>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-starter</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>schisandra-cloud-storage-oss-starter</name>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<spring-boot.version>2.4.2</spring-boot.version>
|
||||||
|
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
||||||
|
<spring-cloud.version>2020.0.6</spring-cloud.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<version>2.4.2</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application-controller</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-infra</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<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>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring-boot.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>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<!--打包成jar包时的名字-->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>2.3.0.RELEASE</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<!-- 打包的时候忽略lombok,因为lombok值在编译器起作用 -->
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.24</version>
|
||||||
|
</path>
|
||||||
|
<!-- 必须要加, 否则生成不了 MapperImpl 实现类 -->
|
||||||
|
<path>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>1.4.2.Final</version>
|
||||||
|
</path>
|
||||||
|
<!-- 如果是 0.1.0 有可能出现生成了maptruct的实现类, 但该类只创建了对象, 没有进行赋值 -->
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||||
|
<version>0.2.0</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@@ -0,0 +1,20 @@
|
|||||||
|
package com.schisandra.oss;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储微服务启动类
|
||||||
|
*
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/3/21
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
@ComponentScan("com.schisandra")
|
||||||
|
public class OssApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(OssApplication.class);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,59 @@
|
|||||||
|
server:
|
||||||
|
port: 4000
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
username: root
|
||||||
|
password: BZbVbGDBePiA2q8/mt0eMxKNpHniDzxBtOxFadQiAOTDzCDlopC4qOKwwBEi9CAZcuFsCrRJdwn0wP6jwsnzxw==
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://1.95.0.111:3306/schisandra-cloud-storage?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=true
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
druid:
|
||||||
|
initial-size: 20
|
||||||
|
min-idle: 20
|
||||||
|
max-active: 100
|
||||||
|
max-wait: 60000
|
||||||
|
connectionProperties: config.decrypt=true;config.decrypt.key=${publicKey};
|
||||||
|
stat-view-servlet:
|
||||||
|
enabled: true
|
||||||
|
url-pattern: /druid/*
|
||||||
|
login-username: admin
|
||||||
|
login-password: 123456
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
enabled: true
|
||||||
|
slow-sql-millis: 2000
|
||||||
|
log-slow-sql: true
|
||||||
|
wall:
|
||||||
|
enabled: true
|
||||||
|
config:
|
||||||
|
enabled: true
|
||||||
|
# redis配置
|
||||||
|
redis:
|
||||||
|
# Redis数据库索引(默认为0)
|
||||||
|
database: 1
|
||||||
|
# Redis服务器地址
|
||||||
|
host: 1.95.0.111
|
||||||
|
# Redis服务器连接端口
|
||||||
|
port: 6379
|
||||||
|
# Redis服务器连接密码(默认为空)
|
||||||
|
password: LDQ20020618xxx
|
||||||
|
# 连接超时时间
|
||||||
|
timeout: 2s
|
||||||
|
lettuce:
|
||||||
|
pool:
|
||||||
|
# 连接池最大连接数
|
||||||
|
max-active: 200
|
||||||
|
# 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
max-wait: -1ms
|
||||||
|
# 连接池中的最大空闲连接
|
||||||
|
max-idle: 10
|
||||||
|
# 连接池中的最小空闲连接
|
||||||
|
min-idle: 0
|
||||||
|
publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANUVxjcrVoirBZaNmDrUqatHEW4FOHbO5ynW6zvhIbRMo6hEFGgglbURkjuHOlgEduxJVz6Xa+sG+FMrxTguOJECAwEAAQ==
|
||||||
|
logging:
|
||||||
|
config: classpath:log4j2-spring.xml
|
||||||
|
# mybatis-plus日志
|
||||||
|
mybatis-plus:
|
||||||
|
global-config:
|
||||||
|
banner: false
|
||||||
|
|
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
,---,
|
||||||
|
,--.' | ,--, ,---,
|
||||||
|
| | : ,--.'| ,---, ,---.'| __ ,-.
|
||||||
|
.--.--. : : : | |, .--.--. ,-+-. / | | | :,' ,'/ /|
|
||||||
|
/ / ' ,---. : | |,--.`--'_ / / ' ,--.--. ,--.'|' | | | |' | |' | ,--.--.
|
||||||
|
| : /`./ / \ | : ' |,' ,'| | : /`./ / \ | | ,"' | ,--.__| || | ,'/ \
|
||||||
|
| : ;_ / / ' | | /' :' | | | : ;_ .--. .-. | | | / | | / ,' |' : / .--. .-. |
|
||||||
|
\ \ `. . ' / ' : | | || | : \ \ `. \__\/: . . | | | | |. ' / || | ' \__\/: . .
|
||||||
|
`----. \' ; :__ | | ' | :' : |__ `----. \ ," .--.; | | | | |/ ' ; |: |; : | ," .--.; |
|
||||||
|
/ /`--' /' | '.'|| : :_:,'| | '.'| / /`--' // / ,. | | | |--' | | '/ '| , ; / / ,. |
|
||||||
|
'--'. / | : :| | ,' ; : ;'--'. /; : .' \| |/ | : :| ---' ; : .' \
|
||||||
|
`--'---' \ \ / `--'' | , / `--'---' | , .-./'---' \ \ / | , .-./
|
||||||
|
`----' ---`-' `--`---' `----' `--`---'
|
||||||
|
|
||||||
|
Spring Boot: ${spring-boot.formatted-version}
|
||||||
|
五味子云存储
|
@@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出-->
|
||||||
|
<!--monitorInterval:Log4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数-->
|
||||||
|
<configuration status="INFO" monitorInterval="5">
|
||||||
|
<!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL -->
|
||||||
|
<!--变量配置-->
|
||||||
|
<Properties>
|
||||||
|
<!-- 格式化输出:%date表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %msg:日志消息,%n是换行符-->
|
||||||
|
<!-- %logger{36} 表示 Logger 名字最长36个字符 -->
|
||||||
|
<property name="LOG_PATTERN" value="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx" />
|
||||||
|
<!-- 定义日志存储的路径 -->
|
||||||
|
<property name="FILE_PATH" value="../log" />
|
||||||
|
<property name="FILE_NAME" value="schisandra-cloud-storage-oss.log" />
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
<!--https://logging.apache.org/log4j/2.x/manual/appenders.html-->
|
||||||
|
<appenders>
|
||||||
|
|
||||||
|
<console name="Console" target="SYSTEM_OUT">
|
||||||
|
<!--输出日志的格式-->
|
||||||
|
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||||
|
<!--控制台只输出level及其以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||||
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
</console>
|
||||||
|
|
||||||
|
<!--文件会打印出所有信息,这个log每次运行程序会自动清空,由append属性决定,适合临时测试用-->
|
||||||
|
<File name="fileLog" fileName="${FILE_PATH}/temp.log" append="false">
|
||||||
|
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||||
|
</File>
|
||||||
|
|
||||||
|
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||||
|
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz">
|
||||||
|
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||||
|
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||||
|
<Policies>
|
||||||
|
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||||
|
<TimeBasedTriggeringPolicy interval="1"/>
|
||||||
|
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||||
|
<DefaultRolloverStrategy max="15"/>
|
||||||
|
</RollingFile>
|
||||||
|
|
||||||
|
<!-- 这个会打印出所有的warn及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||||
|
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz">
|
||||||
|
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||||
|
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||||
|
<Policies>
|
||||||
|
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||||
|
<TimeBasedTriggeringPolicy interval="1"/>
|
||||||
|
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||||
|
<DefaultRolloverStrategy max="15"/>
|
||||||
|
</RollingFile>
|
||||||
|
|
||||||
|
<!-- 这个会打印出所有的error及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||||
|
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz">
|
||||||
|
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||||
|
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||||
|
<Policies>
|
||||||
|
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||||
|
<TimeBasedTriggeringPolicy interval="1"/>
|
||||||
|
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||||
|
<DefaultRolloverStrategy max="15"/>
|
||||||
|
</RollingFile>
|
||||||
|
|
||||||
|
</appenders>
|
||||||
|
|
||||||
|
<!--Logger节点用来单独指定日志的形式,比如要为指定包下的class指定不同的日志级别等。-->
|
||||||
|
<!--然后定义loggers,只有定义了logger并引入的appender,appender才会生效-->
|
||||||
|
<loggers>
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="Console"/>
|
||||||
|
<appender-ref ref="RollingFileInfo"/>
|
||||||
|
<appender-ref ref="RollingFileWarn"/>
|
||||||
|
<appender-ref ref="RollingFileError"/>
|
||||||
|
<appender-ref ref="fileLog"/>
|
||||||
|
</root>
|
||||||
|
</loggers>
|
||||||
|
|
||||||
|
</configuration>
|
@@ -1,6 +0,0 @@
|
|||||||
server:
|
|
||||||
port: 4000
|
|
||||||
minio:
|
|
||||||
url: http://1.95.0.111:9000/
|
|
||||||
accessKey: landaiqing
|
|
||||||
secretKey: LDQ20020618xxx
|
|
Reference in New Issue
Block a user