Commit 2775a7d5 authored by fangxinjiang's avatar fangxinjiang

init

parent 6f43d9c5
...@@ -14,26 +14,6 @@ management: ...@@ -14,26 +14,6 @@ management:
health: health:
show-details: ALWAYS show-details: ALWAYS
# feign 配置
feign:
sentinel:
enabled: true
okhttp:
enabled: true
httpclient:
enabled: false
client:
config:
default:
connectTimeout: 10000
readTimeout: 10000
compression:
request:
enabled: true
response:
enabled: true
# mybaits-plus配置 # mybaits-plus配置
mybatis-plus: mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml mapper-locations: classpath:/mapper/*Mapper.xml
...@@ -50,6 +30,10 @@ mybatis-plus: ...@@ -50,6 +30,10 @@ mybatis-plus:
# spring security 配置 # spring security 配置
security: security:
oauth2: oauth2:
client:
client-id: ENC(27v1agvAug87ANOVnbKdsw==)
client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)
scope: server
resource: resource:
loadBalanced: true loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token token-info-uri: http://yifu-auth/oauth/check_token
...@@ -59,15 +43,7 @@ security: ...@@ -59,15 +43,7 @@ security:
- /v3/api-docs - /v3/api-docs
- /actuator/** - /actuator/**
# swagger 配置
swagger:
enabled: true
title: Yifu Swagger API
gateway: http://${GATEWAY_HOST:yifu-gateway}:${GATEWAY-PORT:9999}
token-url: ${swagger.gateway}/auth/oauth/token
services:
yifu-upms-biz: admin
yifu-codegen: gen
# Spring 相关 # Spring 相关
spring: spring:
application: application:
......
...@@ -22,16 +22,16 @@ ...@@ -22,16 +22,16 @@
<artifactId>yifu-common-core</artifactId> <artifactId>yifu-common-core</artifactId>
</dependency> </dependency>
<!--swagger 注解--> <!--swagger 注解-->
<dependency> <!--<dependency>
<groupId>io.swagger.core.v3</groupId> <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
</dependency> </dependency>-->
<!--feign 注解依赖--> <!--feign 注解依赖-->
<dependency> <!--<dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId> <artifactId>spring-cloud-openfeign-core</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>-->
<!--mybatis 依赖--> <!--mybatis 依赖-->
<dependency> <dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
......
package com.yifu.cloud.plus.v1.yifu.consumer.feign;
\ No newline at end of file
...@@ -43,30 +43,30 @@ ...@@ -43,30 +43,30 @@
<artifactId>yifu-common-security</artifactId> <artifactId>yifu-common-security</artifactId>
</dependency> </dependency>
<!--必备:服务处理--> <!--必备:服务处理-->
<dependency> <!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-feign</artifactId> <artifactId>yifu-common-feign</artifactId>
</dependency> </dependency>-->
<!--必备:日志处理--> <!--必备:日志处理-->
<dependency> <dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-log</artifactId> <artifactId>yifu-common-log</artifactId>
</dependency> </dependency>
<!--必备:swagger--> <!--必备:swagger-->
<dependency> <!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId> <artifactId>yifu-common-swagger</artifactId>
</dependency> </dependency>-->
<!--必备: 注册中心客户端--> <!--必备: 注册中心客户端-->
<dependency> <!-- <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency> </dependency>-->
<!--必备: 配置中心客户端--> <!--必备: 配置中心客户端-->
<dependency> <!--<dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency> </dependency>-->
<!--必备:undertow容器--> <!--必备:undertow容器-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
package com.yifu.cloud.plus.v1.consumer; package com.yifu.cloud.plus.v1.consumer;
import com.yifu.cloud.plus.v1.yifu.common.feign.annotation.EnableYifuFeignClients;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer; import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer;
import com.yifu.cloud.plus.v1.yifu.common.swagger.annotation.EnableYifuDoc;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/** /**
* @author pig archetype * @author pig archetype
* <p> * <p>
* 项目启动类 * 项目启动类
*/ */
@EnableYifuDoc
@EnableYifuFeignClients
@EnableYifuResourceServer @EnableYifuResourceServer
@EnableDiscoveryClient
@SpringBootApplication @SpringBootApplication
public class ConsumerApplication { public class ConsumerApplication {
......
...@@ -21,8 +21,6 @@ import com.yifu.cloud.plus.v1.consumer.entity.Consumer; ...@@ -21,8 +21,6 @@ import com.yifu.cloud.plus.v1.consumer.entity.Consumer;
import com.yifu.cloud.plus.v1.consumer.mapper.ConsumerMapper; import com.yifu.cloud.plus.v1.consumer.mapper.ConsumerMapper;
import com.yifu.cloud.plus.v1.consumer.service.ConsumerService; import com.yifu.cloud.plus.v1.consumer.service.ConsumerService;
import com.yifu.cloud.plus.v1.provider.entity.Provider; import com.yifu.cloud.plus.v1.provider.entity.Provider;
import com.yifu.cloud.plus.v1.provider.feign.RemoteProviderService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import io.seata.spring.annotation.GlobalTransactional; import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -38,7 +36,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -38,7 +36,6 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class ConsumerServiceImpl extends ServiceImpl<ConsumerMapper, Consumer> implements ConsumerService { public class ConsumerServiceImpl extends ServiceImpl<ConsumerMapper, Consumer> implements ConsumerService {
private final RemoteProviderService remoteProviderService;
@GlobalTransactional // 分布式seata事务 @GlobalTransactional // 分布式seata事务
...@@ -52,7 +49,7 @@ public class ConsumerServiceImpl extends ServiceImpl<ConsumerMapper, Consumer> i ...@@ -52,7 +49,7 @@ public class ConsumerServiceImpl extends ServiceImpl<ConsumerMapper, Consumer> i
provider.setCreateTime(consumer.getCreateTime()); provider.setCreateTime(consumer.getCreateTime());
provider.setUpdateBy(consumer.getUpdateBy()); provider.setUpdateBy(consumer.getUpdateBy());
provider.setUpdateTime(consumer.getUpdateTime()); provider.setUpdateTime(consumer.getUpdateTime());
remoteProviderService.testSeata(provider, SecurityConstants.FROM_IN); //remoteProviderService.testSeata(provider, SecurityConstants.FROM_IN);
baseMapper.insert(consumer); baseMapper.insert(consumer);
return true; return true;
} }
......
server: server:
port: 7002 port: 7002
# 加解密根密码
jasypt:
encryptor:
password: pig #根密码
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
## spring security 配置
security:
oauth2:
client:
client-id: ENC(27v1agvAug87ANOVnbKdsw==)
client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)
scope: server
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
global-config:
banner: false
db-config:
id-type: auto
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
configuration:
map-underscore-to-camel-case: true
# 直接放行URL
ignore:
urls:
- /v2/api-docs
- /actuator/**
spring: spring:
application: application:
name: @artifactId@ name: @artifactId@
cloud:
nacos: ---
discovery: # 数据源配置
server-addr: ${NACOS_HOST:yifu-register}:${NACOS_PORT:8848} spring:
config: redis:
server-addr: ${spring.cloud.nacos.discovery.server-addr} host: yifu-redis
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/consumer?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
config:
activate:
on-profile: test
---
# 数据源配置
spring:
redis:
host: yifu-redis
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/consumer?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
config: config:
import: activate:
- nacos:application-@profiles.active@.yml on-profile: dev
- nacos:${spring.application.name}-@profiles.active@.yml
...@@ -2,9 +2,7 @@ package com.yifu.cloud.plus.v1.provider.feign; ...@@ -2,9 +2,7 @@ package com.yifu.cloud.plus.v1.provider.feign;
import com.yifu.cloud.plus.v1.provider.entity.Provider; import com.yifu.cloud.plus.v1.provider.entity.Provider;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ServiceNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
...@@ -13,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestHeader; ...@@ -13,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
* @author fxj * @author fxj
* @Date 2022-05-14 * @Date 2022-05-14
*/ */
@FeignClient(contextId="remoteProviderService",value = ServiceNameConstants.PROVIDER_SERVICE) //@FeignClient(contextId="remoteProviderService",value = ServiceNameConstants.PROVIDER_SERVICE)
public interface RemoteProviderService { public interface RemoteProviderService {
@PostMapping("/provider/inner/save") @PostMapping("/provider/inner/save")
R<Boolean> testSeata(@RequestBody Provider provider, @RequestHeader(SecurityConstants.FROM) String from); R<Boolean> testSeata(@RequestBody Provider provider, @RequestHeader(SecurityConstants.FROM) String from);
......
package com.yifu.cloud.plus.v1.provider.feign.factory;
import com.yifu.cloud.plus.v1.provider.feign.RemoteProviderService;
import com.yifu.cloud.plus.v1.provider.feign.fallback.RemoteProviderServiceFallbackImpl;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
//异常回调工厂
@Component
public class RemoteProviderServiceFallbackFactory implements FallbackFactory<RemoteProviderService> {
@Override
public RemoteProviderService create(Throwable cause) {
RemoteProviderServiceFallbackImpl remoteProviderServiceFallback = new RemoteProviderServiceFallbackImpl();
remoteProviderServiceFallback.setCause(cause);
return remoteProviderServiceFallback;
}
}
package com.yifu.cloud.plus.v1.provider.feign.fallback;
import com.yifu.cloud.plus.v1.provider.entity.Provider;
import com.yifu.cloud.plus.v1.provider.feign.RemoteProviderService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
@Log4j2
@Component
public class RemoteProviderServiceFallbackImpl implements RemoteProviderService {
@Setter
private Throwable cause;
@Override
public R<Boolean> testSeata(Provider provider, String from) {
log.error("测试seata异常",provider,cause);
return null;
}
}
package com.yifu.cloud.plus.v1.provider.feign;
\ No newline at end of file
...@@ -43,30 +43,30 @@ ...@@ -43,30 +43,30 @@
<artifactId>yifu-common-security</artifactId> <artifactId>yifu-common-security</artifactId>
</dependency> </dependency>
<!--必备:服务处理--> <!--必备:服务处理-->
<dependency> <!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-feign</artifactId> <artifactId>yifu-common-feign</artifactId>
</dependency> </dependency>-->
<!--必备:日志处理--> <!--必备:日志处理-->
<dependency> <dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-log</artifactId> <artifactId>yifu-common-log</artifactId>
</dependency> </dependency>
<!--必备:swagger--> <!--必备:swagger-->
<dependency> <!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId> <artifactId>yifu-common-swagger</artifactId>
</dependency> </dependency>-->
<!--必备: 注册中心客户端--> <!--必备: 注册中心客户端-->
<dependency> <!--<dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency> </dependency>-->
<!--必备: 配置中心客户端--> <!--必备: 配置中心客户端-->
<dependency> <!--<dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency> </dependency>-->
<!--必备:undertow容器--> <!--必备:undertow容器-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
package com.yifu.cloud.plus.v1.provider; package com.yifu.cloud.plus.v1.provider;
import com.yifu.cloud.plus.v1.yifu.common.feign.annotation.EnableYifuFeignClients;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer; import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer;
import com.yifu.cloud.plus.v1.yifu.common.swagger.annotation.EnableYifuDoc;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
/** /**
* @author pig archetype * @author pig archetype
* <p> * <p>
* 项目启动类 * 项目启动类
*/ */
@EnableYifuDoc
@EnableYifuFeignClients
@EnableYifuResourceServer @EnableYifuResourceServer
@EnableDiscoveryClient
//@ComponentScan(basePackages = {"com.yifu.cloud.plus.v1"})
@SpringBootApplication @SpringBootApplication
public class ProviderApplication { public class ProviderApplication {
......
server: server:
port: 7001 port: 7001
# 加解密根密码
jasypt:
encryptor:
password: pig #根密码
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
security:
oauth2:
client:
client-id: ENC(27v1agvAug87ANOVnbKdsw==)
client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)
scope: server
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
global-config:
banner: false
db-config:
id-type: auto
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
configuration:
map-underscore-to-camel-case: true
# 直接放行URL
ignore:
urls:
- /v2/api-docs
- /actuator/**
#spring 配置
spring: spring:
application: application:
name: @artifactId@ name: @artifactId@
cloud: ---
nacos: # 数据源配置
discovery: spring:
server-addr: ${NACOS_HOST:yifu-register}:${NACOS_PORT:8848} redis:
config: host: yifu-redis
server-addr: ${spring.cloud.nacos.discovery.server-addr} password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/provider?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
config:
activate:
on-profile: test
---
# 数据源配置
spring:
redis:
host: yifu-redis
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/provider?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
config: config:
import: activate:
- nacos:application-@profiles.active@.yml on-profile: dev
- nacos:${spring.application.name}-@profiles.active@.yml
...@@ -37,10 +37,10 @@ ...@@ -37,10 +37,10 @@
<artifactId>yifu-common-core</artifactId> <artifactId>yifu-common-core</artifactId>
</dependency> </dependency>
<!--swagger--> <!--swagger-->
<dependency> <!--<dependency>
<groupId>io.swagger.core.v3</groupId> <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
</dependency> </dependency>-->
<!--feign 注解依赖--> <!--feign 注解依赖-->
<!--<dependency> <!--<dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
......
...@@ -14,26 +14,6 @@ management: ...@@ -14,26 +14,6 @@ management:
health: health:
show-details: ALWAYS show-details: ALWAYS
# feign 配置
feign:
sentinel:
enabled: true
okhttp:
enabled: true
httpclient:
enabled: false
client:
config:
default:
connectTimeout: 10000
readTimeout: 10000
compression:
request:
enabled: true
response:
enabled: true
# mybaits-plus配置 # mybaits-plus配置
mybatis-plus: mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml mapper-locations: classpath:/mapper/*Mapper.xml
...@@ -53,11 +33,11 @@ security: ...@@ -53,11 +33,11 @@ security:
resource: resource:
loadBalanced: true loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token token-info-uri: http://yifu-auth/oauth/check_token
# 通用放行URL,服务个性化,请在对应配置文件覆盖 # 通用放行URL,服务个性化,请在对应配置文件覆盖
ignore: ignore:
urls: urls:
- /v3/api-docs - /v3/api-docs
- /actuator/** - /actuator/**
# 文件上传相关 支持阿里云、华为云、腾讯、minio # 文件上传相关 支持阿里云、华为云、腾讯、minio
oss: oss:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment