diff --git a/yudao-gateway/src/main/resources/application.yaml b/yudao-gateway/src/main/resources/application.yaml index 4f75ea202..3ccb05120 100644 --- a/yudao-gateway/src/main/resources/application.yaml +++ b/yudao-gateway/src/main/resources/application.yaml @@ -84,7 +84,7 @@ spring: - Path=/admin-api/mp/** filters: - RewritePath=/admin-api/mp/v3/api-docs, /v3/api-docs - ## member-server 服务 + ## product-server 服务 - id: product-admin-api # 路由的编号 uri: grayLb://product-server predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组 @@ -97,6 +97,19 @@ spring: - Path=/app-api/product/** filters: - RewritePath=/app-api/product/v3/api-docs, /v3/api-docs + ## promotion-server 服务 + - id: promotion-admin-api # 路由的编号 + uri: grayLb://promotion-server + predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组 + - Path=/admin-api/promotion/** + filters: + - RewritePath=/admin-api/promotion/v3/api-docs, /v3/api-docs # 配置,保证转发到 /v3/api-docs + - id: promotion-app-api # 路由的编号 + uri: grayLb://promotion-server + predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组 + - Path=/app-api/promotion/** + filters: + - RewritePath=/app-api/promotion/v3/api-docs, /v3/api-docs x-forwarded: prefix-enabled: false # 避免 Swagger 重复带上额外的 /admin-api/system 前缀 @@ -123,6 +136,9 @@ knife4j: - name: mp-server service-name: mp-server url: /admin-api/mp/v3/api-docs - - name: member-server - service-name: member-server - url: /admin-api/member/v3/api-docs + - name: product-server + service-name: product-server + url: /admin-api/product/v3/api-docs + - name: promotion-server + service-name: promotion-server + url: /admin-api/promotion/v3/api-docs diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java new file mode 100644 index 000000000..2de4351cf --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ApiConstants.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.promotion.enums; + +import cn.iocoder.yudao.framework.common.enums.RpcConstants; + +/** + * API 相关的枚举 + * + * @author 芋道源码 + */ +public class ApiConstants { + + /** + * 服务名 + * + * 注意,需要保证和 spring.application.name 保持一致 + */ + public static final String NAME = "promotion-server"; + + public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/promotion"; + + public static final String VERSION = "1.0.0"; + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/pom.xml b/yudao-module-mall/yudao-module-promotion-biz/pom.xml index da2c98736..0e90502d4 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/pom.xml +++ b/yudao-module-mall/yudao-module-promotion-biz/pom.xml @@ -61,10 +61,6 @@ cn.iocoder.cloud yudao-spring-boot-starter-biz-tenant - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-weixin - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java new file mode 100644 index 000000000..33c4be85b --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/config/RpcConfiguration.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.promotion.framework.rpc.config; + +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; +import cn.iocoder.yudao.module.product.api.category.ProductCategoryApi; +import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; +import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; +import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +@EnableFeignClients(clients = {ProductSkuApi.class, ProductSpuApi.class, ProductCategoryApi.class, + MemberUserApi.class, TradeOrderApi.class}) +public class RpcConfiguration { +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java new file mode 100644 index 000000000..2484c83e1 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/rpc/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.promotion.framework.rpc; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java new file mode 100644 index 000000000..3dbee4f06 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/config/SecurityConfiguration.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.promotion.framework.security.config; + +import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; +import cn.iocoder.yudao.module.promotion.enums.ApiConstants; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; + +/** + * Member 模块的 Security 配置 + */ +@Configuration("memberSecurityConfiguration") +public class SecurityConfiguration { + + @Bean("memberAuthorizeRequestsCustomizer") + public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { + return new AuthorizeRequestsCustomizer() { + + @Override + public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { + // Swagger 接口文档 + registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 + .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI + // Spring Boot Actuator 的安全配置 + registry.antMatchers("/actuator").anonymous() + .antMatchers("/actuator/**").anonymous(); + // Druid 监控 + registry.antMatchers("/druid/**").anonymous(); + // RPC 服务的安全配置 + registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); + } + + }; + } + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java new file mode 100644 index 000000000..72b196292 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/framework/security/core/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.promotion.framework.security.core; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml index 4f11769a5..05266e5f4 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/bootstrap.yaml @@ -1,6 +1,6 @@ spring: application: - name: promtoion-server + name: promotion-server profiles: active: local