factor:租户信息服务类优化

This commit is contained in:
xiafang
2023-02-09 09:35:06 +08:00
parent 110b8b5cfc
commit bd782503ea
4 changed files with 12 additions and 7 deletions

View File

@@ -29,6 +29,8 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* 从配置文件中加载租户信息,默认实现,可被覆盖
*
* @author xiafang * @author xiafang
* @since 2023/2/3 11:40 * @since 2023/2/3 11:40
*/ */
@@ -37,7 +39,7 @@ public class InMemoryWechatTenantService implements WechatTenantService {
private final WechatPayProperties wechatPayProperties; private final WechatPayProperties wechatPayProperties;
@Override @Override
public Set<WechatMetaBean> getAllTenants() { public Set<WechatMetaBean> loadTenants() {
Map<String, WechatPayProperties.V3> v3Map = wechatPayProperties.getV3(); Map<String, WechatPayProperties.V3> v3Map = wechatPayProperties.getV3();
KeyPairFactory keyPairFactory = new KeyPairFactory(); KeyPairFactory keyPairFactory = new KeyPairFactory();
return v3Map.entrySet() return v3Map.entrySet()

View File

@@ -44,7 +44,7 @@ public class WechatPayConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
WechatMetaContainer wechatMetaContainer(WechatTenantService wechatTenantService) { WechatMetaContainer wechatMetaContainer(WechatTenantService wechatTenantService) {
WechatMetaContainer container = new WechatMetaContainer(); WechatMetaContainer container = new WechatMetaContainer();
container.addWechatMetas(wechatTenantService.getAllTenants()); container.addWechatMetas(wechatTenantService.loadTenants());
return container; return container;
} }

View File

@@ -22,9 +22,12 @@ import cn.felord.payment.wechat.v3.WechatMetaBean;
import java.util.Set; import java.util.Set;
/** /**
* @author xiafang * 加载租户信息服务
* @since 2023/2/3 11:37 *
* @author felord.cn
* @since 1.0.16.RELEASE
*/ */
@FunctionalInterface
public interface WechatTenantService { public interface WechatTenantService {
Set<WechatMetaBean> getAllTenants(); Set<WechatMetaBean> loadTenants();
} }

View File

@@ -26,8 +26,8 @@ import org.springframework.context.annotation.Configuration;
/** /**
* The type Wechat tenant service configuration. * The type Wechat tenant service configuration.
* *
* @author xiafang * @author felord.cn
* @since 2023 /2/3 12:32 * @since 1.0.16.RELEASE
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@Conditional(WechatPayConfiguredCondition.class) @Conditional(WechatPayConfiguredCondition.class)