初始化
commit
03446dba26
|
@ -0,0 +1,39 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,46 @@
|
|||
<!-- 父工程 -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<!-- 默认关掉单元测试,不用手动关闭了 -->
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!-- 子工程,只包括有启动类的服务,公共模块无需打包,只需对父工程打包 -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- 指定该 Main Class 为全局的唯一入口 -->
|
||||
<mainClass>com.ysy.MqServiceApplication</mainClass>
|
||||
<layout>ZIP</layout>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<!-- 将依赖到的包都放进去 -->
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
|
@ -0,0 +1,57 @@
|
|||
<?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>
|
||||
|
||||
<groupId>com.ysy</groupId>
|
||||
<artifactId>ysy-springcloud-module</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>ysy-common</module>
|
||||
<module>ysy-gateway</module>
|
||||
<module>ysy-auth</module>
|
||||
<module>ysy-modules</module>
|
||||
<module>ysy-modules/ysy-system</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>2022.0.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>2022.0.0.0-RC2</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ysy</groupId>
|
||||
<artifactId>ysy-common</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</project>
|
|
@ -0,0 +1,41 @@
|
|||
<?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>com.ysy</groupId>
|
||||
<artifactId>ysy-springcloud-module</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ysy-auth</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 自定义公共模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ysy</groupId>
|
||||
<artifactId>ysy-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package com.ysy.auth;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients(basePackages = "com.ysy.common.remote")
|
||||
public class AuthApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.ysy.auth.controller;
|
||||
|
||||
import com.ysy.auth.service.AuthService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AuthController {
|
||||
private final AuthService authService;
|
||||
|
||||
public AuthController(AuthService authService) {
|
||||
this.authService = authService;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package com.ysy.auth.service;
|
||||
|
||||
public interface AuthService {
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.ysy.auth.service.impl;
|
||||
|
||||
import com.ysy.auth.service.AuthService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AuthServiceImpl implements AuthService {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
██ ██ ████████ ██ ██
|
||||
░░██ ██ ██░░░░░░ ░░██ ██
|
||||
░░████ ░██ ░░████
|
||||
░░██ ░█████████ ░░██
|
||||
░██ ░░░░░░░░██ ░██
|
||||
░██ ░██ ░██
|
||||
░██ ████████ ░██
|
||||
░░ ░░░░░░░░ ░░
|
||||
:: ysy boot :: version 1.0
|
|
@ -0,0 +1,39 @@
|
|||
server:
|
||||
#服务端口
|
||||
port: 10001
|
||||
|
||||
spring:
|
||||
application:
|
||||
#服务名称
|
||||
name: authService
|
||||
profiles:
|
||||
#配置文件生效环境
|
||||
active: dev
|
||||
|
||||
cloud:
|
||||
nacos:
|
||||
#nacos服务器地址
|
||||
server-addr: http://124.70.132.13:8848
|
||||
#nacos服务发现配置
|
||||
discovery:
|
||||
#nacos服务注册命名空间ID,默认为public
|
||||
namespace: 2e6a4975-46b3-4035-b77d-92b05ae48a66
|
||||
#cluster-name: SH #服务集群设置
|
||||
config:
|
||||
#指定读取命名空间配置,默认为public
|
||||
namespace: ${spring.cloud.nacos.discovery.namespace}
|
||||
#nacos配置文件类型
|
||||
file-extension: yaml
|
||||
#共享配置
|
||||
shared-configs:
|
||||
- data-id: common.yaml
|
||||
group: SPRING_CLOUD_COMMONS
|
||||
refresh: true
|
||||
|
||||
- data-id: common-mysql.yaml
|
||||
group: SPRING_CLOUD_COMMONS
|
||||
refresh: true
|
||||
|
||||
- data-id: common-redis.yaml
|
||||
group: SPRING_CLOUD_COMMONS
|
||||
refresh: true
|
|
@ -0,0 +1,202 @@
|
|||
<?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>com.ysy</groupId>
|
||||
<artifactId>ysy-springcloud-module</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ysy-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- nacos服务发现依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- loadbalancer负载均衡 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- nacos配置文件 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- bootstrap优先启动文件 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- feign客户端 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- feign的httpclient客户端 -->
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- amqp -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- javax.annotation -->
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- elasticsearch -->
|
||||
<dependency>
|
||||
<groupId>co.elastic.clients</groupId>
|
||||
<artifactId>elasticsearch-java</artifactId>
|
||||
<version>8.11.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jackson-databind -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.12.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jwt令牌校验 -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Hibernate Validator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mysql -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- druid连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.20</version>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatisPlus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redis连接池 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.42</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- hutool工具包 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.20</version>
|
||||
</dependency>
|
||||
|
||||
<!-- aliyun OOS -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.15.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- aliyun OOS JDK高于9版本需要的依赖 -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<!-- no more than 2.3.3-->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,29 @@
|
|||
package com.ysy.common.config.es;
|
||||
|
||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
||||
import co.elastic.clients.transport.rest_client.RestClientTransport;
|
||||
import lombok.Data;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "elasticsearch")
|
||||
@Data
|
||||
public class ElasticClient {
|
||||
private String protocol;
|
||||
|
||||
private String host;
|
||||
|
||||
private Integer port;
|
||||
|
||||
@Bean
|
||||
public ElasticsearchClient getElasticsearchClient() {
|
||||
RestClient restclient = RestClient.builder(new HttpHost(host, port, protocol)).build();
|
||||
RestClientTransport transport = new RestClientTransport(restclient, new JacksonJsonpMapper());
|
||||
return new ElasticsearchClient(transport);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.ysy.common.config.mp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
public MybatisPlusConfig () {
|
||||
System.out.println("MybatisPlusConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.ysy.common.config.rabbitmq;
|
||||
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.DirectExchange;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
|
||||
import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(name = "spring.rabbitmq.listener.simple.retry.enabled", havingValue = "true")
|
||||
public class ErrorMessageConfig {
|
||||
@Bean
|
||||
public DirectExchange errorMessageExchange(){
|
||||
return new DirectExchange("error.direct");
|
||||
}
|
||||
@Bean
|
||||
public Queue errorQueue(){
|
||||
return new Queue("error.queue", true);
|
||||
}
|
||||
@Bean
|
||||
public Binding errorBinding(Queue errorQueue, DirectExchange errorMessageExchange){
|
||||
return BindingBuilder.bind(errorQueue).to(errorMessageExchange).with("error");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageRecoverer republishMessageRecoverer(RabbitTemplate rabbitTemplate){
|
||||
return new RepublishMessageRecoverer(rabbitTemplate, "error.direct", "error");
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换默认JDK序列化,org.springframework.amqp.support.converter.MessageConverter
|
||||
* @return 用json格式替代默认格式
|
||||
*/
|
||||
@Bean
|
||||
public MessageConverter jsonConverter() {
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.ysy.common.config.rabbitmq;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.ReturnedMessage;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class RabbitPublisherConfig implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnsCallback {
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
//设置开启Mandatory,才能触发回调函数,无论消息推送结果怎么样都强制调用回调函数
|
||||
rabbitTemplate.setMandatory(true);
|
||||
rabbitTemplate.setConfirmCallback(this);
|
||||
rabbitTemplate.setReturnsCallback(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* confirm回调,(前提: 确认模式开启:publisher-confirm-type: correlated)
|
||||
* CorrelationData数据可以在rabbitTemplate.convertAndSend时传入,并这种CorrelationData的setId参数,回调时能取到
|
||||
* @param correlationData 相关数据,可以在发送消息时,进行设置该参数
|
||||
* @param ack 结果
|
||||
* @param cause 原因
|
||||
*/
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||
if (ack) {
|
||||
log.info("【ConfirmCallback】消息已经送达Exchange,ack已发");
|
||||
} else {
|
||||
log.warn("【ConfirmCallback】消息没有送达Exchange");
|
||||
// todo 做一些处理,让消息再次发送。 消息缓存或入库,邮件提醒运维
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return函数,(前提:退回模式开启:yml中publisher-returns: true)
|
||||
* @param returned 返回的信息
|
||||
*/
|
||||
@Override
|
||||
public void returnedMessage(ReturnedMessage returned) {
|
||||
log.debug("收到消息的return callback,exchange:{}, key:{}, msg:{}, code:{}, text:{}",
|
||||
returned.getExchange(), returned.getRoutingKey(), returned.getMessage(),
|
||||
returned.getReplyCode(), returned.getReplyText());
|
||||
// todo 处理 邮件发送,缓存或存到数据库
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.ysy.common.contant;
|
||||
|
||||
public class ResultConstants {
|
||||
public final static int SUCCESS_CODE = 200;
|
||||
public final static int FAIL_CODE = 300;
|
||||
public final static int ERROR_CODE = 500;
|
||||
public final static String SUCCESS_MSG = "success";
|
||||
public final static String FAIL_MSG = "fail";
|
||||
public final static String ERROR_MSG = "error";
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.ysy.common.contant;
|
||||
|
||||
public class TokenConstants {
|
||||
public final static String TOKEN = "token";
|
||||
public final static String TOKEN_LOGIN = "tokenLogin";
|
||||
public final static String TOKEN_KEY = "tokenKey";
|
||||
public final static String USER_ID = "userId";
|
||||
public final static String USER_NAME = "username";
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.ysy.common.domain.result;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PageResult<T> implements Serializable {
|
||||
|
||||
private long total;
|
||||
|
||||
private List<T> list;
|
||||
|
||||
public PageResult() {
|
||||
}
|
||||
|
||||
public PageResult(long total, List<T> list) {
|
||||
this.total = total;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public static <T> PageResult<T> toPageResult(long total, List<T> list){
|
||||
return new PageResult(total , list);
|
||||
}
|
||||
|
||||
public static <T> Result<PageResult<T>> toResult(long total, List<T> list){
|
||||
return Result.success(PageResult.toPageResult(total, list));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.ysy.common.domain.result;
|
||||
|
||||
import com.ysy.common.contant.ResultConstants;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class Result<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int SUCCESS = ResultConstants.SUCCESS_CODE;
|
||||
|
||||
public static final int FAIL = ResultConstants.FAIL_CODE;
|
||||
|
||||
public static final int ERROR = ResultConstants.ERROR_CODE;
|
||||
|
||||
public static final String SUCCESS_MSG = ResultConstants.SUCCESS_MSG;
|
||||
|
||||
public static final String FAIL_MSG = ResultConstants.FAIL_MSG;
|
||||
|
||||
public static final String ERROR_MSG = ResultConstants.ERROR_MSG;
|
||||
|
||||
//field
|
||||
private int code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
public static <T> Result<T> success() {
|
||||
return restResult(SUCCESS, SUCCESS_MSG, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(String msg) {
|
||||
return restResult(SUCCESS, msg, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data) {
|
||||
return restResult(SUCCESS, SUCCESS_MSG, data);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(String msg, T data) {
|
||||
return restResult(SUCCESS, msg, data);
|
||||
}
|
||||
|
||||
public static <T> Result<T> fail() {
|
||||
return restResult(FAIL, FAIL_MSG, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> fail(String msg) {
|
||||
return restResult(FAIL, msg, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error() {
|
||||
return restResult(ERROR, ERROR_MSG, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(String msg) {
|
||||
return restResult(ERROR, msg, null);
|
||||
}
|
||||
|
||||
private static <T> Result<T> restResult(int code, String msg, T data) {
|
||||
Result<T> apiResult = new Result<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setMsg(msg);
|
||||
apiResult.setData(data);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功
|
||||
* @return 成功:true
|
||||
*/
|
||||
public boolean isSuccess(){
|
||||
return this.code == SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
* @return 失败:false
|
||||
*/
|
||||
public boolean isError(){
|
||||
return !isSuccess();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.ysy.common.exception;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ysy.common.domain.result.Result;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public Result illegalArgumentExceptionHandler(IllegalArgumentException e) {
|
||||
log.error("服务端报错:[{}]", e.getMessage(), e.getLocalizedMessage(), e);
|
||||
return Result.fail(
|
||||
// JSON.toJSONString()
|
||||
);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public Result methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) {
|
||||
log.error("服务端报错:[{}]", e.getMessage(), e.getLocalizedMessage(), e);
|
||||
return Result.fail(JSON.toJSONString(e.getBindingResult()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.ysy.common.utils.gateway;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ysy.common.domain.result.Result;
|
||||
import com.ysy.common.utils.tools.StringUtils;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Log4j2
|
||||
public class GatewayUtils {
|
||||
/**
|
||||
* 添加请求头参数
|
||||
* @param mutate 修改对象
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
*/
|
||||
public static void addHeader(ServerHttpRequest.Builder mutate, String key, Object value) {
|
||||
if (StringUtils.isEmpty(key)){
|
||||
log.warn("添加请求头参数键不可以为空");
|
||||
return;
|
||||
}
|
||||
if (value == null) {
|
||||
log.warn("添加请求头参数:[{}]值为空",key);
|
||||
return;
|
||||
}
|
||||
String valueStr = value.toString();
|
||||
mutate.header(key, valueStr);
|
||||
log.info("添加请求头参数成功 - 键:[{}] , 值:[{}]", key , value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除请求头参数
|
||||
* @param mutate 修改对象
|
||||
* @param key 键
|
||||
*/
|
||||
public static void removeHeader(ServerHttpRequest.Builder mutate, String key) {
|
||||
if (StringUtils.isEmpty(key)){
|
||||
log.warn("删除请求头参数键不可以为空");
|
||||
return;
|
||||
}
|
||||
mutate.headers(httpHeaders -> httpHeaders.remove(key)).build();
|
||||
log.info("删除请求头参数 - 键:[{}]",key);
|
||||
}
|
||||
/**
|
||||
* 错误结果响应
|
||||
* @param exchange 响应上下文
|
||||
* @param msg 响应消息
|
||||
* @return
|
||||
*/
|
||||
public static Mono<Void> errorResponse(ServerWebExchange exchange, String msg) {
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
//设置HTTP响应头状态
|
||||
response.setStatusCode(HttpStatus.OK);
|
||||
//设置HTTP响应头文本格式
|
||||
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
|
||||
//定义响应内容
|
||||
Result result = Result.error(msg);
|
||||
String resultJson = JSONObject.toJSONString(result);
|
||||
log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
|
||||
DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
|
||||
//进行响应
|
||||
return response.writeWith(Mono.just(dataBuffer));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.ysy.common.utils.jwt;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.interfaces.Claim;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
public class JwtUtil {
|
||||
private final static Date EXPIRE_TIME = new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24L);
|
||||
private final static String SECRET = "qwertyuiopasdfghjkl";
|
||||
private final static String CLAIM_NAME = "claim_name";
|
||||
|
||||
public static String createToken(Map<String, Object> claim) {
|
||||
String token = JWT.create()
|
||||
.withClaim(CLAIM_NAME, claim)
|
||||
//.withExpiresAt(EXPIRE_TIME)
|
||||
.sign(Algorithm.HMAC256(SECRET));
|
||||
return token;
|
||||
}
|
||||
|
||||
public static DecodedJWT decodedJWT(String token) {
|
||||
JWTVerifier build = JWT.require(Algorithm.HMAC256(SECRET))
|
||||
.build();
|
||||
DecodedJWT decodedJWT = build.verify(token);
|
||||
return decodedJWT;
|
||||
}
|
||||
|
||||
public static Claim getClaim(String token) {
|
||||
DecodedJWT decodedJWT = decodedJWT(token);
|
||||
Map<String, Claim> claims = decodedJWT.getClaims();
|
||||
return claims.get(CLAIM_NAME);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.ysy.common.utils.jwt;
|
||||
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* 安全服务工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SecurityUtils {
|
||||
/**
|
||||
* 生成BCryptPasswordEncoder密码
|
||||
*
|
||||
* @param password 密码
|
||||
*
|
||||
* @return 加密字符串
|
||||
*/
|
||||
public static String encryptPassword (String password, String salt) {
|
||||
return encryptMD5(password, salt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断密码是否相同
|
||||
*
|
||||
* @param password 真实密码
|
||||
* @param encodedPassword 加密后字符
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean matchesPassword (String password, String salt, String encodedPassword) {
|
||||
return encryptMD5(password, salt).equals(encodedPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算字符串的MD5加密值,并返回Base64编码的字符串。
|
||||
* @param password 要加密的字符串
|
||||
* @return 加密后的Base64编码字符串
|
||||
*/
|
||||
public static String encryptMD5(String password, String salt) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update((password + salt).getBytes()); // 加盐处理
|
||||
byte[] digest = md.digest();
|
||||
String encodeToString = Base64.getEncoder().encodeToString(digest);
|
||||
return encodeToString;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.ysy.common.utils.oss;
|
||||
|
||||
import com.aliyun.oss.ClientException;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.OSSException;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import com.aliyun.oss.model.PutObjectResult;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class AliOssUtil {
|
||||
private final static String ENDPOINT = "https://oss-cn-beijing.aliyuncs.com";
|
||||
// 从环境变量中获取访问凭证。运行本代码示例之前,请确保已设置环境变量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
|
||||
// EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
|
||||
// 填写Bucket名称,例如examplebucket。
|
||||
private final static String ACCESS_KEY_ID = "LTAI5tLBQ6W5bZKvw34YX2i8";
|
||||
private final static String ACCESS_KEY_SECRET = "mHnzyqJv6CL3p0uy4xyhOvvA73sYOO";
|
||||
private final static String BUCKET_NAME = "ysy-bucket01";
|
||||
|
||||
public static String fileUpload(String objectName, InputStream inputStream) throws Exception {
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
|
||||
|
||||
// 返回url地址
|
||||
String url = "";
|
||||
|
||||
try {
|
||||
// 填写字符串。
|
||||
String content = "Hello OSS,你好世界";
|
||||
|
||||
// 创建PutObjectRequest对象。
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKET_NAME, objectName, inputStream);
|
||||
|
||||
// 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。
|
||||
// ObjectMetadata metadata = new ObjectMetadata();
|
||||
// metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString());
|
||||
// metadata.setObjectAcl(CannedAccessControlList.Private);
|
||||
// putObjectRequest.setMetadata(metadata);
|
||||
|
||||
// 上传字符串。
|
||||
PutObjectResult result = ossClient.putObject(putObjectRequest);
|
||||
|
||||
// 返回url地址
|
||||
url = "https://" + BUCKET_NAME + "." + ENDPOINT.substring(ENDPOINT.lastIndexOf("/") + 1) + "/" + objectName;
|
||||
} catch (OSSException oe) {
|
||||
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||
System.out.println("Error Code:" + oe.getErrorCode());
|
||||
System.out.println("Request ID:" + oe.getRequestId());
|
||||
System.out.println("Host ID:" + oe.getHostId());
|
||||
} catch (ClientException ce) {
|
||||
System.out.println("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
System.out.println("Error Message:" + ce.getMessage());
|
||||
} finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.ysy.common.utils.tools;
|
||||
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 字符串处理工具类
|
||||
*/
|
||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否为空
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isNull(Object object) {
|
||||
return object == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(Collection<?> coll) {
|
||||
return isNull(coll) || coll.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
|
||||
*
|
||||
* @param str 指定字符串
|
||||
* @param strs 需要检查的字符串数组
|
||||
* @return 是否匹配
|
||||
*/
|
||||
public static boolean matches(String str, List<String> strs) {
|
||||
if (isEmpty(str) || isEmpty(strs)) {
|
||||
return false;
|
||||
}
|
||||
for (String pattern : strs) {
|
||||
if (isMatch(pattern, str))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断url是否与规则配置:
|
||||
* ? 表示单个字符;
|
||||
* * 表示一层路径内的任意字符串,不可跨层级;
|
||||
* ** 表示任意层路径;
|
||||
*
|
||||
* @param pattern 匹配规则
|
||||
* @param url 需要匹配的url
|
||||
* @return
|
||||
*/
|
||||
public static boolean isMatch(String pattern, String url) {
|
||||
AntPathMatcher matcher = new AntPathMatcher();
|
||||
return matcher.match(pattern, url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?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>com.ysy</groupId>
|
||||
<artifactId>ysy-springcloud-module</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ysy-gateway</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ysy</groupId>
|
||||
<artifactId>ysy-common</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 网关依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
package com.ysy.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class GatewayApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GatewayApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.ysy.gateway.white;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "auth")
|
||||
@Component
|
||||
@RefreshScope
|
||||
public class AuthProperties {
|
||||
private List<String> excludePaths;
|
||||
private List<String> includePaths;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
██ ██ ████████ ██ ██
|
||||
░░██ ██ ██░░░░░░ ░░██ ██
|
||||
░░████ ░██ ░░████
|
||||
░░██ ░█████████ ░░██
|
||||
░██ ░░░░░░░░██ ░██
|
||||
░██ ░██ ░██
|
||||
░██ ████████ ░██
|
||||
░░ ░░░░░░░░ ░░
|
||||
:: ysy boot :: version 1.0
|
|
@ -0,0 +1,33 @@
|
|||
server:
|
||||
port: 10010
|
||||
spring:
|
||||
application:
|
||||
#服务名称
|
||||
name: gateway
|
||||
profiles:
|
||||
#配置文件生效环境
|
||||
active: dev
|
||||
|
||||
cloud:
|
||||
nacos:
|
||||
#nacos服务器地址
|
||||
server-addr: http://124.70.132.13:8848
|
||||
#nacos服务发现配置
|
||||
discovery:
|
||||
#nacos服务注册命名空间ID,默认为public
|
||||
namespace: 2e6a4975-46b3-4035-b77d-92b05ae48a66
|
||||
#nacos配置文件配置
|
||||
config:
|
||||
#指定读取命名空间配置,默认为public
|
||||
namespace: ${spring.cloud.nacos.discovery.namespace}
|
||||
#nacos配置文件类型
|
||||
file-extension: yaml
|
||||
#共享配置
|
||||
shared-configs:
|
||||
- data-id: common.yaml
|
||||
group: SPRING_CLOUD_COMMONS
|
||||
refresh: true
|
||||
|
||||
- data-id: common-redis.yaml
|
||||
group: SPRING_CLOUD_COMMONS
|
||||
refresh: true
|
|
@ -0,0 +1,20 @@
|
|||
<?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>com.ysy</groupId>
|
||||
<artifactId>ysy-springcloud-module</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ysy-modules</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,42 @@
|
|||
<?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>com.ysy</groupId>
|
||||
<artifactId>ysy-springcloud-module</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>ysy-system</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 自定义公共模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ysy</groupId>
|
||||
<artifactId>ysy-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package com.ysy.system;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients(basePackages = "com.ysy.common.remote")
|
||||
public class SystemApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SystemApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.ysy.system.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
██ ██ ████████ ██ ██
|
||||
░░██ ██ ██░░░░░░ ░░██ ██
|
||||
░░████ ░██ ░░████
|
||||
░░██ ░█████████ ░░██
|
||||
░██ ░░░░░░░░██ ░██
|
||||
░██ ░██ ░██
|
||||
░██ ████████ ░██
|
||||
░░ ░░░░░░░░ ░░
|
||||
:: ysy boot :: version 1.0
|
|
@ -0,0 +1,39 @@
|
|||
server:
|
||||
#服务端口
|
||||
port: 10002
|
||||
|
||||
spring:
|
||||
application:
|
||||
#服务名称
|
||||
name: systemService
|
||||
profiles:
|
||||
#配置文件生效环境
|
||||
active: dev
|
||||
|
||||
cloud:
|
||||
nacos:
|
||||
#nacos服务器地址
|
||||
server-addr: http://124.70.132.13:8848
|
||||
#nacos服务发现配置
|
||||
discovery:
|
||||
#nacos服务注册命名空间ID,默认为public
|
||||
namespace: 2e6a4975-46b3-4035-b77d-92b05ae48a66
|
||||
#cluster-name: SH #服务集群设置
|
||||
config:
|
||||
#指定读取命名空间配置,默认为public
|
||||
namespace: ${spring.cloud.nacos.discovery.namespace}
|
||||
#nacos配置文件类型
|
||||
file-extension: yaml
|
||||
#共享配置
|
||||
shared-configs:
|
||||
- data-id: common.yaml
|
||||
group: SPRING_CLOUD_COMMONS
|
||||
refresh: true
|
||||
|
||||
- data-id: common-mysql.yaml
|
||||
group: SPRING_CLOUD_COMMONS
|
||||
refresh: true
|
||||
|
||||
- data-id: common-redis.yaml
|
||||
group: SPRING_CLOUD_COMMONS
|
||||
refresh: true
|
Loading…
Reference in New Issue