From 9b7fa58fcfa4915c1dc4eb583f671ebb199fe716 Mon Sep 17 00:00:00 2001 From: Iamasoldier <1272745473@qq.com> Date: Fri, 30 May 2025 15:55:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=B1=BB=EF=BC=8C=E5=AE=9E=E7=8E=B0=E5=8A=A8=E6=80=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=AE=A1=E7=90=86=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +++ .../controller/SysWechatConfigController.java | 20 +++--- .../user}/mapper/WechatConfigMapper.java | 2 +- .../user}/service/PrivateKeyService.java | 10 +-- .../user/service/SysWechatConfigService.java | 55 ----------------- .../user}/service/WechatConfigService.java | 2 +- .../user}/service/WechatPayService.java | 2 +- .../service/impl/PrivateKeyServiceImpl.java | 14 ++--- .../impl/SysWechatConfigServiceImpl.java | 61 ------------------- .../service/impl/WechatConfigServiceImpl.java | 8 ++- .../service/impl/WechatPayServiceImpl.java | 2 +- zlt-commons/pom.xml | 3 +- .../zlt/wechat/feign/PrivateKeyService.java | 25 ++++++++ .../zlt/wechat/feign/WechatConfigService.java | 29 +++++++++ .../PrivateKeyServiceFallbackFactory.java | 25 ++++++++ .../WechatConfigServiceFallbackFactory.java | 33 ++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 4 ++ .../config/WechatAutoConfiguration.java | 5 +- .../main/resources/META-INF/spring.factories | 2 +- zlt-uaa/pom.xml | 9 ++- .../main/java/com/central/UaaServerApp.java | 2 +- .../config/AuthorizationServerConfig.java | 1 - .../service/impl/UserDetailServiceImpl.java | 5 +- .../src/main/frontend/config/proxy.ts | 32 +++++----- 24 files changed, 191 insertions(+), 170 deletions(-) rename {zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat => zlt-business/user-center/src/main/java/com/central/user}/mapper/WechatConfigMapper.java (97%) rename {zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat => zlt-business/user-center/src/main/java/com/central/user}/service/PrivateKeyService.java (94%) delete mode 100644 zlt-business/user-center/src/main/java/com/central/user/service/SysWechatConfigService.java rename {zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat => zlt-business/user-center/src/main/java/com/central/user}/service/WechatConfigService.java (97%) rename {zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat => zlt-business/user-center/src/main/java/com/central/user}/service/WechatPayService.java (98%) rename {zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat => zlt-business/user-center/src/main/java/com/central/user}/service/impl/PrivateKeyServiceImpl.java (93%) delete mode 100644 zlt-business/user-center/src/main/java/com/central/user/service/impl/SysWechatConfigServiceImpl.java rename {zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat => zlt-business/user-center/src/main/java/com/central/user}/service/impl/WechatConfigServiceImpl.java (92%) rename {zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat => zlt-business/user-center/src/main/java/com/central/user}/service/impl/WechatPayServiceImpl.java (98%) create mode 100644 zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/PrivateKeyService.java create mode 100644 zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/WechatConfigService.java create mode 100644 zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/fallback/PrivateKeyServiceFallbackFactory.java create mode 100644 zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/fallback/WechatConfigServiceFallbackFactory.java create mode 100644 zlt-commons/zlt-wechat-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/pom.xml b/pom.xml index 843d1c65..aa79d001 100644 --- a/pom.xml +++ b/pom.xml @@ -403,6 +403,16 @@ oauth2-oidc-sdk ${oauth2-oidc-sdk.version} + + com.zlt + zlt-wechat-common-core + ${project.version} + + + com.zlt + zlt-wechat-spring-boot-starter + ${project.version} + diff --git a/zlt-business/user-center/src/main/java/com/central/user/controller/SysWechatConfigController.java b/zlt-business/user-center/src/main/java/com/central/user/controller/SysWechatConfigController.java index fd0d81dd..a0b10cc8 100644 --- a/zlt-business/user-center/src/main/java/com/central/user/controller/SysWechatConfigController.java +++ b/zlt-business/user-center/src/main/java/com/central/user/controller/SysWechatConfigController.java @@ -3,10 +3,10 @@ package com.central.user.controller; import com.central.common.context.TenantContextHolder; import com.central.common.model.PageResult; import com.central.common.model.Result; +import com.central.user.service.PrivateKeyService; +import com.central.user.service.WechatConfigService; +import com.central.user.service.WechatPayService; import com.zlt.wechat.entity.WechatConfig; -import com.zlt.wechat.service.PrivateKeyService; -import com.zlt.wechat.service.WechatConfigService; -import com.zlt.wechat.service.WechatPayService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -14,10 +14,10 @@ import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; import java.util.Map; @Slf4j @@ -27,13 +27,13 @@ import java.util.Map; @RequestMapping("/wechat/config") public class SysWechatConfigController { - @Autowired + @Resource private WechatConfigService wechatConfigService; - @Autowired + @Resource private WechatPayService wechatPayService; - @Autowired + @Resource private PrivateKeyService privateKeyService; @Operation(summary = "查询列表") @@ -109,4 +109,10 @@ public class SysWechatConfigController { public Result getCurrentConfig(@PathVariable String type) { return Result.succeed(wechatConfigService.getConfig(type, TenantContextHolder.getTenant())); } + + @Operation(summary = "获取租户密钥") + @GetMapping("/tenant/private-key") + public String getPrivateKey(@RequestParam("tenantId")String tenantId,@RequestParam String type) { + return privateKeyService.getPrivateKey(tenantId, type); + } } diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/mapper/WechatConfigMapper.java b/zlt-business/user-center/src/main/java/com/central/user/mapper/WechatConfigMapper.java similarity index 97% rename from zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/mapper/WechatConfigMapper.java rename to zlt-business/user-center/src/main/java/com/central/user/mapper/WechatConfigMapper.java index 96e0fb45..b79ab274 100644 --- a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/mapper/WechatConfigMapper.java +++ b/zlt-business/user-center/src/main/java/com/central/user/mapper/WechatConfigMapper.java @@ -1,4 +1,4 @@ -package com.zlt.wechat.mapper; +package com.central.user.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/PrivateKeyService.java b/zlt-business/user-center/src/main/java/com/central/user/service/PrivateKeyService.java similarity index 94% rename from zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/PrivateKeyService.java rename to zlt-business/user-center/src/main/java/com/central/user/service/PrivateKeyService.java index 1c2931a6..ecdd63b8 100644 --- a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/PrivateKeyService.java +++ b/zlt-business/user-center/src/main/java/com/central/user/service/PrivateKeyService.java @@ -1,4 +1,4 @@ -package com.zlt.wechat.service; +package com.central.user.service; import java.io.InputStream; @@ -6,7 +6,7 @@ import java.io.InputStream; * 私钥文件管理服务 */ public interface PrivateKeyService { - + /** * 上传私钥文件 * @@ -16,7 +16,7 @@ public interface PrivateKeyService { * @return 文件访问路径 */ String uploadPrivateKey(String tenantId, String type, InputStream inputStream); - + /** * 获取私钥文件 * @@ -25,7 +25,7 @@ public interface PrivateKeyService { * @return 私钥文件内容 */ String getPrivateKey(String tenantId, String type); - + /** * 删除私钥文件 * @@ -34,4 +34,4 @@ public interface PrivateKeyService { * @return 是否成功 */ boolean deletePrivateKey(String tenantId, String type); -} \ No newline at end of file +} diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/SysWechatConfigService.java b/zlt-business/user-center/src/main/java/com/central/user/service/SysWechatConfigService.java deleted file mode 100644 index a8aef0c2..00000000 --- a/zlt-business/user-center/src/main/java/com/central/user/service/SysWechatConfigService.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.central.user.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.central.user.model.SysWechatConfig; - -public interface SysWechatConfigService extends IService { - - /** - * 获取微信配置 - * - * @param type 配置类型 - * @return 微信配置 - */ - SysWechatConfig getConfig(String type); - - /** - * 保存微信配置 - * - * @param config 微信配置 - * @return 是否成功 - */ - boolean saveConfig(SysWechatConfig config); - - /** - * 更新微信配置 - * - * @param config 微信配置 - * @return 是否成功 - */ - boolean updateConfig(SysWechatConfig config); - - /** - * 删除微信配置 - * - * @param id 配置ID - * @return 是否成功 - */ - boolean deleteConfig(Long id); - - /** - * 切换当前使用的微信配置 - * - * @param type 配置类型 - * @return 是否成功 - */ - boolean switchConfig(String type); - - /** - * 获取当前使用的微信配置 - * - * @param type 配置类型 - * @return 微信配置 - */ - SysWechatConfig getCurrentConfig(String type); -} \ No newline at end of file diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/WechatConfigService.java b/zlt-business/user-center/src/main/java/com/central/user/service/WechatConfigService.java similarity index 97% rename from zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/WechatConfigService.java rename to zlt-business/user-center/src/main/java/com/central/user/service/WechatConfigService.java index 938e879a..4bd802ca 100644 --- a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/WechatConfigService.java +++ b/zlt-business/user-center/src/main/java/com/central/user/service/WechatConfigService.java @@ -1,4 +1,4 @@ -package com.zlt.wechat.service; +package com.central.user.service; import com.baomidou.mybatisplus.extension.service.IService; import com.central.common.model.PageResult; diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/WechatPayService.java b/zlt-business/user-center/src/main/java/com/central/user/service/WechatPayService.java similarity index 98% rename from zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/WechatPayService.java rename to zlt-business/user-center/src/main/java/com/central/user/service/WechatPayService.java index ab575dde..c31efdf2 100644 --- a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/WechatPayService.java +++ b/zlt-business/user-center/src/main/java/com/central/user/service/WechatPayService.java @@ -1,4 +1,4 @@ -package com.zlt.wechat.service; +package com.central.user.service; import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse; import com.wechat.pay.java.service.payments.model.Transaction; diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/PrivateKeyServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/PrivateKeyServiceImpl.java similarity index 93% rename from zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/PrivateKeyServiceImpl.java rename to zlt-business/user-center/src/main/java/com/central/user/service/impl/PrivateKeyServiceImpl.java index 842ac7fb..a81447e6 100644 --- a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/PrivateKeyServiceImpl.java +++ b/zlt-business/user-center/src/main/java/com/central/user/service/impl/PrivateKeyServiceImpl.java @@ -1,6 +1,6 @@ -package com.zlt.wechat.service.impl; +package com.central.user.service.impl; -import com.zlt.wechat.service.PrivateKeyService; +import com.central.user.service.PrivateKeyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; @@ -30,11 +30,11 @@ public class PrivateKeyServiceImpl implements PrivateKeyService { while ((line = reader.readLine()) != null) { content.append(line).append("\n"); } - + // 缓存私钥内容 String cacheKey = String.format(CACHE_KEY_PATTERN, tenantId, type); redisTemplate.opsForValue().set(cacheKey, content.toString(), CACHE_EXPIRE_DAYS, TimeUnit.DAYS); - + return cacheKey; } catch (Exception e) { throw new RuntimeException("上传私钥文件失败", e); @@ -45,11 +45,11 @@ public class PrivateKeyServiceImpl implements PrivateKeyService { public String getPrivateKey(String tenantId, String type) { String cacheKey = String.format(CACHE_KEY_PATTERN, tenantId, type); String privateKey = redisTemplate.opsForValue().get(cacheKey); - + if (!StringUtils.hasText(privateKey)) { throw new RuntimeException("私钥文件不存在"); } - + return privateKey; } @@ -58,4 +58,4 @@ public class PrivateKeyServiceImpl implements PrivateKeyService { String cacheKey = String.format(CACHE_KEY_PATTERN, tenantId, type); return redisTemplate.delete(cacheKey); } -} \ No newline at end of file +} diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysWechatConfigServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysWechatConfigServiceImpl.java deleted file mode 100644 index 59807f3e..00000000 --- a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysWechatConfigServiceImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.central.user.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.central.common.context.TenantContextHolder; -import com.central.user.mapper.SysWechatConfigMapper; -import com.central.user.model.SysWechatConfig; -import com.central.user.service.SysWechatConfigService; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -@Service -public class SysWechatConfigServiceImpl extends ServiceImpl - implements SysWechatConfigService { - - private static final String CACHE_NAME = "wechat:config"; - private static final String CACHE_KEY_PATTERN = "#type"; - - @Override - @Cacheable(value = CACHE_NAME, key = CACHE_KEY_PATTERN, unless = "#result == null") - public SysWechatConfig getConfig(String type) { - return getOne(new LambdaQueryWrapper() - .eq(SysWechatConfig::getType, type) - .eq(SysWechatConfig::getTenantId, TenantContextHolder.getTenant()) - .eq(SysWechatConfig::getStatus, 1)); - } - - @Override - @CacheEvict(value = CACHE_NAME, key = CACHE_KEY_PATTERN) - public boolean saveConfig(SysWechatConfig config) { - config.setTenantId(TenantContextHolder.getTenant()); - return save(config); - } - - @Override - @CacheEvict(value = CACHE_NAME, key = CACHE_KEY_PATTERN) - public boolean updateConfig(SysWechatConfig config) { - config.setTenantId(TenantContextHolder.getTenant()); - return updateById(config); - } - - @Override - @CacheEvict(value = CACHE_NAME, allEntries = true) - public boolean deleteConfig(Long id) { - return removeById(id); - } - - @Override - @CacheEvict(value = CACHE_NAME, key = CACHE_KEY_PATTERN) - public boolean switchConfig(String type) { - // 这里可以添加切换配置的具体逻辑 - return true; - } - - @Override - @Cacheable(value = CACHE_NAME, key = "'current:' + #type", unless = "#result == null") - public SysWechatConfig getCurrentConfig(String type) { - return getConfig(type); - } -} \ No newline at end of file diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/WechatConfigServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/WechatConfigServiceImpl.java similarity index 92% rename from zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/WechatConfigServiceImpl.java rename to zlt-business/user-center/src/main/java/com/central/user/service/impl/WechatConfigServiceImpl.java index 74424971..cfdf4f93 100644 --- a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/WechatConfigServiceImpl.java +++ b/zlt-business/user-center/src/main/java/com/central/user/service/impl/WechatConfigServiceImpl.java @@ -1,12 +1,13 @@ -package com.zlt.wechat.service.impl; +package com.central.user.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.central.common.model.PageResult; +import com.central.user.mapper.WechatConfigMapper; +import com.central.user.service.WechatConfigService; import com.zlt.wechat.entity.WechatConfig; -import com.zlt.wechat.mapper.WechatConfigMapper; -import com.zlt.wechat.service.WechatConfigService; +import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.MapUtils; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; @@ -15,6 +16,7 @@ import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; +@RequiredArgsConstructor @Service public class WechatConfigServiceImpl extends ServiceImpl implements WechatConfigService { diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/WechatPayServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/WechatPayServiceImpl.java similarity index 98% rename from zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/WechatPayServiceImpl.java rename to zlt-business/user-center/src/main/java/com/central/user/service/impl/WechatPayServiceImpl.java index f2ac569b..3b79591b 100644 --- a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/service/impl/WechatPayServiceImpl.java +++ b/zlt-business/user-center/src/main/java/com/central/user/service/impl/WechatPayServiceImpl.java @@ -1,4 +1,4 @@ -//package com.zlt.wechat.service.impl; +package com.central.user.service.impl;//package com.zlt.wechat.service.impl; // //import com.wechat.pay.java.core.Config; //import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension; diff --git a/zlt-commons/pom.xml b/zlt-commons/pom.xml index 68c1e62c..fa2d2adf 100644 --- a/zlt-commons/pom.xml +++ b/zlt-commons/pom.xml @@ -22,6 +22,7 @@ zlt-elasticsearch-spring-boot-starter zlt-oss-spring-boot-starter zlt-zookeeper-spring-boot-starter - + zlt-wechat-common-core + zlt-wechat-spring-boot-starter diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/PrivateKeyService.java b/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/PrivateKeyService.java new file mode 100644 index 00000000..16d60787 --- /dev/null +++ b/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/PrivateKeyService.java @@ -0,0 +1,25 @@ +package com.zlt.wechat.feign; + +import com.central.common.constant.ServiceNameConstants; +import com.zlt.wechat.feign.fallback.PrivateKeyServiceFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author zlt + */ +@FeignClient(name = ServiceNameConstants.USER_SERVICE, fallbackFactory = PrivateKeyServiceFallbackFactory.class, dismiss404 = true) +public interface PrivateKeyService { + /** + * feign rpc访问远程/wechat/config/{type}接口 + * 查询微信配置对象WechatConfig + * + * @param type + * @return + */ + @GetMapping(value = "/wechat/config/{type}") + String getPrivateKey(@PathVariable("type") String type, @RequestParam("tenantId") String tenantId); + +} diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/WechatConfigService.java b/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/WechatConfigService.java new file mode 100644 index 00000000..97d5faac --- /dev/null +++ b/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/WechatConfigService.java @@ -0,0 +1,29 @@ +package com.zlt.wechat.feign; + +import com.central.common.constant.ServiceNameConstants; +import com.zlt.wechat.entity.WechatConfig; +import com.zlt.wechat.feign.fallback.WechatConfigServiceFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +/** + * @author zlt + */ +@FeignClient(name = ServiceNameConstants.USER_SERVICE, fallbackFactory = WechatConfigServiceFallbackFactory.class, dismiss404 = true) +public interface WechatConfigService { + /** + * feign rpc访问远程/wechat/config/{type}接口 + * 查询微信配置对象WechatConfig + * + * @param type + * @return + */ + @GetMapping(value = "/wechat/config/{type}") + WechatConfig getConfig(@PathVariable("type") String type,String tenantId); + + @GetMapping(value = "/app/{id}") + WechatConfig getConfig(String appId); + + +} diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/fallback/PrivateKeyServiceFallbackFactory.java b/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/fallback/PrivateKeyServiceFallbackFactory.java new file mode 100644 index 00000000..81e7868e --- /dev/null +++ b/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/fallback/PrivateKeyServiceFallbackFactory.java @@ -0,0 +1,25 @@ +package com.zlt.wechat.feign.fallback; + +import com.zlt.wechat.feign.PrivateKeyService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; + +/** + * userService降级工场 + * + * @author zlt + * @date 2019/1/18 + */ +@Slf4j +public class PrivateKeyServiceFallbackFactory implements FallbackFactory { + @Override + public PrivateKeyService create(Throwable throwable) { + return new PrivateKeyService() { + @Override + public String getPrivateKey(String tenantId,String type) { + + return ""; + } + }; + } +} diff --git a/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/fallback/WechatConfigServiceFallbackFactory.java b/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/fallback/WechatConfigServiceFallbackFactory.java new file mode 100644 index 00000000..f004c24f --- /dev/null +++ b/zlt-commons/zlt-wechat-common-core/src/main/java/com/zlt/wechat/feign/fallback/WechatConfigServiceFallbackFactory.java @@ -0,0 +1,33 @@ +package com.zlt.wechat.feign.fallback; + +import com.zlt.wechat.entity.WechatConfig; +import com.zlt.wechat.feign.WechatConfigService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; + +/** + * userService降级工场 + * + * @author zlt + * @date 2019/1/18 + */ +@Slf4j +public class WechatConfigServiceFallbackFactory implements FallbackFactory { + @Override + public WechatConfigService create(Throwable throwable) { + return new WechatConfigService() { + @Override + public WechatConfig getConfig(String type,String tenantId) { + + return new WechatConfig(); + } + + @Override + public WechatConfig getConfig(String appId) { + return null; + } + + + }; + } +} diff --git a/zlt-commons/zlt-wechat-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/zlt-commons/zlt-wechat-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..ea304947 --- /dev/null +++ b/zlt-commons/zlt-wechat-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,4 @@ +com.zlt.wechat.feign.fallback.PrivateKeyServiceFallbackFactory +com.zlt.wechat.feign.fallback.WechatConfigServiceFallbackFactory + + diff --git a/zlt-commons/zlt-wechat-spring-boot-starter/src/main/java/com/zlt/wechat/config/WechatAutoConfiguration.java b/zlt-commons/zlt-wechat-spring-boot-starter/src/main/java/com/zlt/wechat/config/WechatAutoConfiguration.java index e1e559e2..530efd58 100644 --- a/zlt-commons/zlt-wechat-spring-boot-starter/src/main/java/com/zlt/wechat/config/WechatAutoConfiguration.java +++ b/zlt-commons/zlt-wechat-spring-boot-starter/src/main/java/com/zlt/wechat/config/WechatAutoConfiguration.java @@ -13,8 +13,8 @@ import com.wechat.pay.java.service.payments.jsapi.model.SettleInfo; import com.wechat.pay.java.service.profitsharing.ProfitsharingService; import com.wechat.pay.java.service.refund.RefundService; import com.zlt.wechat.entity.WechatConfig; -import com.zlt.wechat.service.WechatConfigService; -import com.zlt.wechat.service.PrivateKeyService; +import com.zlt.wechat.feign.PrivateKeyService; +import com.zlt.wechat.feign.WechatConfigService; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; @@ -161,7 +161,6 @@ public class WechatAutoConfiguration { executor.initialize(); return executor; } - /** * 获取当前商户ID * 这里需要根据实际业务场景实现,可以从ThreadLocal、请求上下文等获取 diff --git a/zlt-commons/zlt-wechat-spring-boot-starter/src/main/resources/META-INF/spring.factories b/zlt-commons/zlt-wechat-spring-boot-starter/src/main/resources/META-INF/spring.factories index f50d440d..1ec45a7f 100644 --- a/zlt-commons/zlt-wechat-spring-boot-starter/src/main/resources/META-INF/spring.factories +++ b/zlt-commons/zlt-wechat-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -1,2 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.zlt.wechat.config.WechatAutoConfiguration \ No newline at end of file +com.zlt.wechat.config.WechatAutoConfiguration diff --git a/zlt-uaa/pom.xml b/zlt-uaa/pom.xml index d177709c..17381e3c 100644 --- a/zlt-uaa/pom.xml +++ b/zlt-uaa/pom.xml @@ -46,6 +46,11 @@ zlt-redis-spring-boot-starter + + com.zlt + zlt-wechat-common-core + + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery @@ -94,9 +99,7 @@ com.zlt - zlt-wechat-common-core - 6.0.0 - compile + zlt-wechat-spring-boot-starter diff --git a/zlt-uaa/src/main/java/com/central/UaaServerApp.java b/zlt-uaa/src/main/java/com/central/UaaServerApp.java index 04738baf..53d2f47e 100644 --- a/zlt-uaa/src/main/java/com/central/UaaServerApp.java +++ b/zlt-uaa/src/main/java/com/central/UaaServerApp.java @@ -10,7 +10,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; /** * @author zlt */ -@EnableFeignClients +@EnableFeignClients(basePackages = {"com.central", "com.zlt.wechat.feign"}) @MapperScan(basePackages = "com.central.oauth.mapper") @EnableFeignInterceptor @EnableDiscoveryClient diff --git a/zlt-uaa/src/main/java/com/central/oauth/config/AuthorizationServerConfig.java b/zlt-uaa/src/main/java/com/central/oauth/config/AuthorizationServerConfig.java index e6f6d529..e71fbd5f 100644 --- a/zlt-uaa/src/main/java/com/central/oauth/config/AuthorizationServerConfig.java +++ b/zlt-uaa/src/main/java/com/central/oauth/config/AuthorizationServerConfig.java @@ -74,7 +74,6 @@ public class AuthorizationServerConfig { private final RegisteredClientService registeredClientService; private final RedisSecurityContextRepository securityContextRepository; private final AuthenticationSuccessHandler authenticationSuccessHandler; - /** * spring security 默认的安全策略 */ diff --git a/zlt-uaa/src/main/java/com/central/oauth/service/impl/UserDetailServiceImpl.java b/zlt-uaa/src/main/java/com/central/oauth/service/impl/UserDetailServiceImpl.java index 9338be84..478b15ae 100644 --- a/zlt-uaa/src/main/java/com/central/oauth/service/impl/UserDetailServiceImpl.java +++ b/zlt-uaa/src/main/java/com/central/oauth/service/impl/UserDetailServiceImpl.java @@ -6,7 +6,7 @@ import com.central.common.model.SysUser; import com.central.common.utils.LoginUserUtils; import com.central.oauth.service.ZltUserDetailsService; import com.zlt.wechat.entity.WechatConfig; -import com.zlt.wechat.service.WechatConfigService; +import com.zlt.wechat.feign.WechatConfigService; import lombok.extern.slf4j.Slf4j; import org.springframework.security.authentication.DisabledException; import org.springframework.security.authentication.InternalAuthenticationServiceException; @@ -64,7 +64,8 @@ public class UserDetailServiceImpl implements ZltUserDetailsService { @Override public WechatConfig loadMiniAppConfig(String appId) { - return wechatConfigService.getConfig(appId); +// return wechatConfigService.getConfig(appId); + return null; } @Override diff --git a/zlt-web/react-web/src/main/frontend/config/proxy.ts b/zlt-web/react-web/src/main/frontend/config/proxy.ts index 0f074612..61b5280f 100644 --- a/zlt-web/react-web/src/main/frontend/config/proxy.ts +++ b/zlt-web/react-web/src/main/frontend/config/proxy.ts @@ -9,43 +9,43 @@ export default { dev: { '/api-uaa/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-user/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-log/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-search/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-generator/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-file/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-order/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-device/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, },