sysParam 获取值问题
This commit is contained in:
@@ -14,6 +14,8 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
@@ -94,18 +96,19 @@ public class VersionController {
|
||||
@GetMapping(value = "/getCredentials")
|
||||
public CzgResult<Object> getCredentials() {
|
||||
try {
|
||||
Map<String, String> ossKeyMap = paramsService.getParamsByMap("ossKeySet", ParamCodeCst.OSS_KEY_SET);
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
.setAccessKeyId(paramsService.getSysParamValue(ParamCodeCst.AliYun.ALI_OSS_ACCESS_KEY))
|
||||
.setAccessKeyId(ossKeyMap.get(ParamCodeCst.AliYun.ALI_OSS_ACCESS_KEY))
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret(paramsService.getSysParamValue(ParamCodeCst.AliYun.ALI_OSS_ACCESS_SECRET));
|
||||
.setAccessKeySecret(ossKeyMap.get(ParamCodeCst.AliYun.ALI_OSS_ACCESS_SECRET));
|
||||
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Sts
|
||||
config.endpoint = paramsService.getSysParamValue(ParamCodeCst.AliYun.ALI_OSS_ENDPOINT);
|
||||
config.endpoint = ossKeyMap.get(ParamCodeCst.AliYun.ALI_OSS_ENDPOINT);
|
||||
|
||||
com.aliyun.sts20150401.Client client = new com.aliyun.sts20150401.Client(config);
|
||||
com.aliyun.sts20150401.models.AssumeRoleRequest assumeRoleRequest = new com.aliyun.sts20150401.models.AssumeRoleRequest();
|
||||
assumeRoleRequest.setRoleArn(paramsService.getSysParamValue(ParamCodeCst.AliYun.ALI_OSS_ROLE_ARN));
|
||||
assumeRoleRequest.setRoleArn(ossKeyMap.get(ParamCodeCst.AliYun.ALI_OSS_ROLE_ARN));
|
||||
assumeRoleRequest.setRoleSessionName("test");
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.czg.constants;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 系统参数编码常量类
|
||||
*
|
||||
@@ -9,6 +11,65 @@ package com.czg.constants;
|
||||
*/
|
||||
public interface ParamCodeCst {
|
||||
|
||||
/**
|
||||
* 用户小程序参数
|
||||
*/
|
||||
Set<String> USER_MINI_KEY_SET = Set.of(Wechat.Mini.USER_WX_APP_ID, Wechat.Mini.USER_WX_SECRETE);
|
||||
|
||||
/**
|
||||
* 商家小程序参数
|
||||
*/
|
||||
Set<String> SHOP_MINI_KEY_SET = Set.of(Wechat.Mini.SHOP_WX_APP_ID, Wechat.Mini.SHOP_WX_SECRETE);
|
||||
|
||||
/**
|
||||
* 商家公众号参数 推送 库存不足等消息
|
||||
*/
|
||||
Set<String> SHOP_AC_KEY_SET = Set.of(Wechat.Ac.SHOP_WX_AC_APP_ID, Wechat.Ac.SHOP_WX_AC_SECRETE);
|
||||
/**
|
||||
* 用户公众号参数 推送商家模板消息
|
||||
*/
|
||||
Set<String> USER_AC_KEY_SET = Set.of(Wechat.Ac.USER_WX_AC_APP_ID, Wechat.Ac.USER_WX_AC_SECRETE);
|
||||
|
||||
/**
|
||||
* 微信支付参数KEY
|
||||
*/
|
||||
Set<String> PAY_KEY_SET = Set.of(
|
||||
Wechat.Pay.WX_PUB_KEY,
|
||||
Wechat.Pay.WX_API_CLIENT_KEY,
|
||||
Wechat.Pay.WX_API_CLIENT_CERT,
|
||||
Wechat.Pay.WX_MCH_ID,
|
||||
Wechat.Pay.WX_V3_KEY,
|
||||
System.NATIVE_NOTIFY_URL
|
||||
);
|
||||
|
||||
/**
|
||||
* 支付宝参数KEY
|
||||
*/
|
||||
Set<String> ALI_PAY_KEY_SET = Set.of(
|
||||
Alipay.Web.ALI_GATEWAY,
|
||||
Alipay.Mini.ALI_MINI_APP_ID,
|
||||
Alipay.Mini.ALI_MINI_PRIVATE_KEY,
|
||||
Alipay.Mini.ALI_MINI_PUBLIC_KEY,
|
||||
Alipay.Web.ALI_ACCOUNT_APP_ID,
|
||||
Alipay.Web.ALI_ACCOUNT_PRIVATE_KEY,
|
||||
Alipay.Web.ALI_ACCOUNT_PUBLIC_KEY
|
||||
);
|
||||
|
||||
/**
|
||||
* 阿里云OSS参数KEY
|
||||
*/
|
||||
Set<String> ALI_OSS_KEY_SET = Set.of(
|
||||
ParamCodeCst.AliYun.ALI_SMS_KEY,
|
||||
ParamCodeCst.AliYun.ALI_SMS_SECRET,
|
||||
ParamCodeCst.AliYun.ALI_SMS_TEMPLATE_CODE
|
||||
);
|
||||
|
||||
/**
|
||||
* 阿里云临时凭证
|
||||
*/
|
||||
Set<String> OSS_KEY_SET = Set.of(AliYun.ALI_OSS_ACCESS_KEY, AliYun.ALI_OSS_ACCESS_SECRET, AliYun.ALI_OSS_ENDPOINT, AliYun.ALI_OSS_ROLE_ARN);
|
||||
|
||||
|
||||
/**
|
||||
* 系统通用配置项
|
||||
* <p>存放跨业务模块的通用系统配置</p>
|
||||
|
||||
@@ -72,9 +72,7 @@ public interface SysParamsService extends IService<SysParams> {
|
||||
* dubbo 调用需要 显式抛出 异常类型
|
||||
*
|
||||
* @param type 参数类型
|
||||
* userMiniKeys 用户小程序参数 appId appSecret
|
||||
* shopMiniKeys 商家小程序参数 appId appSecret
|
||||
* payKeys 微信支付参数
|
||||
* @param keyList 内容为 {@link com.czg.constants.ParamCodeCst}的Set集合
|
||||
*/
|
||||
Map<String, String> getParamsByMap(String type, Set<String> keyList) throws CzgException;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信公众号
|
||||
@@ -90,8 +91,10 @@ public class AcAccountUtil {
|
||||
if (StrUtil.isNotEmpty(accessToken)) {
|
||||
return accessToken;
|
||||
}
|
||||
String acAppId = paramsService.getSysParamValue(ParamCodeCst.Wechat.Ac.USER_WX_AC_APP_ID);
|
||||
String acSecrete = paramsService.getSysParamValue(ParamCodeCst.Wechat.Ac.USER_WX_AC_SECRETE);
|
||||
Map<String, String> userAc = paramsService.getParamsByMap("user_ac_key_set", ParamCodeCst.USER_AC_KEY_SET);
|
||||
// 用户小程序参数
|
||||
String acAppId = userAc.get(ParamCodeCst.Wechat.Ac.USER_WX_AC_APP_ID);
|
||||
String acSecrete = userAc.get(ParamCodeCst.Wechat.Ac.USER_WX_AC_SECRETE);
|
||||
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", acAppId, acSecrete));
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
if (!respInfo.containsKey("access_token")) {
|
||||
@@ -103,26 +106,4 @@ public class AcAccountUtil {
|
||||
redisService.set("wx:ac:AccessToken", accessToken, expiresIn - 10);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", "wx1fb600d0f5ea6279", "b4c0534c9b5e6c84a7fe5c2078dff876"));
|
||||
// System.out.println(resp);
|
||||
// String accessToken = "97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR";
|
||||
// JSONObject bodyJson = new JSONObject();
|
||||
// //二维码有效时间(秒),最大2592000,仅临时二维码需要
|
||||
// bodyJson.put("expire_seconds", "2592000");
|
||||
// //二维码类型:QR_SCENE(临时整型)/QR_STR_SCENE(临时字符串)/QR_LIMIT_SCENE(永久整型)/QR_LIMIT_STR_SCENE(永久字符串)
|
||||
// bodyJson.put("action_name", "QR_STR_SCENE");
|
||||
// JSONObject actionInfo = new JSONObject();
|
||||
// JSONObject scene = new JSONObject();
|
||||
// scene.put("scene_str", "43525423");
|
||||
// actionInfo.put("scene", scene);
|
||||
// bodyJson.put("action_info", actionInfo);
|
||||
// System.out.println(bodyJson);
|
||||
//创建临时二维码失败,发送参数: {"action_info":{"scene":{"scene_id":36449}},"action_name":"QR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f5fa37-20fb3162-0f87b4f2"}
|
||||
//创建临时二维码失败,发送参数: {"action_info":{"scene":{"scene_id":36449}},"action_name":"QR_SCENE","expire_seconds":"2592000"}, 响应内容: {"errcode":40052,"errmsg":"invalid action name rid: 68f5f970-2a84749c-78e4d78f"}
|
||||
// String resps = HttpUtil.post(StrUtil.format("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={}", accessToken), JSONObject.toJSONString(bodyJson));
|
||||
// JSONObject respInfos = JSONObject.parseObject(resps);
|
||||
// System.out.println(respInfos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 支付宝通用SDK工具类
|
||||
*
|
||||
@@ -37,13 +40,15 @@ public class AlipayUtil {
|
||||
*/
|
||||
@SneakyThrows
|
||||
public AlipayClient createClient(boolean isAccount) {
|
||||
String serverUrl = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_GATEWAY);
|
||||
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Mini.ALI_MINI_APP_ID);
|
||||
String privateKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Mini.ALI_MINI_PRIVATE_KEY);
|
||||
String alipayPublicKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Mini.ALI_MINI_PUBLIC_KEY);
|
||||
String accountAppId = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_APP_ID);
|
||||
String accountPrivateKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_PRIVATE_KEY);
|
||||
String accountPublicKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_PUBLIC_KEY);
|
||||
Map<String, String> aliPayKeySet = sysParamsService.getParamsByMap("ali_pay_key_set", ParamCodeCst.ALI_PAY_KEY_SET);
|
||||
|
||||
String serverUrl = aliPayKeySet.get(ParamCodeCst.Alipay.Web.ALI_GATEWAY);
|
||||
String appId = aliPayKeySet.get(ParamCodeCst.Alipay.Mini.ALI_MINI_APP_ID);
|
||||
String privateKey = aliPayKeySet.get(ParamCodeCst.Alipay.Mini.ALI_MINI_PRIVATE_KEY);
|
||||
String alipayPublicKey = aliPayKeySet.get(ParamCodeCst.Alipay.Mini.ALI_MINI_PUBLIC_KEY);
|
||||
String accountAppId = aliPayKeySet.get(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_APP_ID);
|
||||
String accountPrivateKey = aliPayKeySet.get(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_PRIVATE_KEY);
|
||||
String accountPublicKey = aliPayKeySet.get(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_PUBLIC_KEY);
|
||||
AlipayConfig alipayConfig = new AlipayConfig();
|
||||
//设置网关地址
|
||||
alipayConfig.setServerUrl(serverUrl);
|
||||
|
||||
@@ -56,8 +56,9 @@ public class WechatAuthUtil {
|
||||
}
|
||||
|
||||
public String getAccountOpenId(String code) {
|
||||
String accountAppId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_APP_ID);
|
||||
String accountSecrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_SECRETE);
|
||||
Map<String, String> shopAc = sysParamsService.getParamsByMap("shop_ac_key_set", ParamCodeCst.SHOP_AC_KEY_SET);
|
||||
String accountAppId = shopAc.get(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_APP_ID);
|
||||
String accountSecrete = shopAc.get(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_SECRETE);
|
||||
String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?";
|
||||
Map<String, Object> requestUrlParam = new HashMap<>();
|
||||
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
|
||||
@@ -78,8 +79,10 @@ public class WechatAuthUtil {
|
||||
|
||||
//获取小程序token
|
||||
private String getAccessToken() {
|
||||
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
|
||||
String secrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_SECRETE);
|
||||
Map<String, String> userMini = sysParamsService.getParamsByMap("user_mini_key_set", ParamCodeCst.USER_MINI_KEY_SET);
|
||||
// 用户小程序参数
|
||||
String appId = userMini.get(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
|
||||
String secrete = userMini.get(ParamCodeCst.Wechat.Mini.USER_WX_SECRETE);
|
||||
String url = String.format("%s?grant_type=client_credential&appid=%s&secret=%s", TOKEN_URL, appId, secrete);
|
||||
String response = HttpUtil.get(url);
|
||||
com.alibaba.fastjson.JSONObject jsonResponse = com.alibaba.fastjson.JSONObject.parseObject(response);
|
||||
@@ -120,8 +123,11 @@ public class WechatAuthUtil {
|
||||
|
||||
|
||||
public JSONObject getSession(String code) {
|
||||
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
|
||||
String secrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_SECRETE);
|
||||
Map<String, String> userMini = sysParamsService.getParamsByMap("user_mini_key_set", ParamCodeCst.USER_MINI_KEY_SET);
|
||||
// 用户小程序参数
|
||||
String appId = userMini.get(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
|
||||
String secrete = userMini.get(ParamCodeCst.Wechat.Mini.USER_WX_SECRETE);
|
||||
|
||||
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
|
||||
Map<String, Object> requestUrlParam = new HashMap<>();
|
||||
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
|
||||
|
||||
@@ -139,8 +139,9 @@ public class WechatMiniMsgUtil {
|
||||
}
|
||||
|
||||
public String getAccountOpenId(String code) {
|
||||
String accountAppId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_APP_ID);
|
||||
String accountSecrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_SECRETE);
|
||||
Map<String, String> shopAc = sysParamsService.getParamsByMap("shop_ac_key_set", ParamCodeCst.SHOP_AC_KEY_SET);
|
||||
String accountAppId = shopAc.get(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_APP_ID);
|
||||
String accountSecrete = shopAc.get(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_SECRETE);
|
||||
String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?";
|
||||
Map<String, Object> requestUrlParam = new HashMap<>();
|
||||
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
|
||||
@@ -165,8 +166,10 @@ public class WechatMiniMsgUtil {
|
||||
if (StrUtil.isNotEmpty(accessToken)) {
|
||||
return accessToken;
|
||||
}
|
||||
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.SHOP_WX_APP_ID);
|
||||
String secrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
|
||||
// 商户小程序参数
|
||||
Map<String, String> shopMiniKeyMap = sysParamsService.getParamsByMap("shop_mini_key_set", ParamCodeCst.SHOP_MINI_KEY_SET);
|
||||
String appId = shopMiniKeyMap.get(ParamCodeCst.Wechat.Mini.SHOP_WX_APP_ID);
|
||||
String secrete = shopMiniKeyMap.get(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
|
||||
|
||||
String url = String.format("%s?grant_type=client_credential&appid=%s&secret=%s", TOKEN_URL, appId, secrete);
|
||||
String response = HttpUtil.get(url);
|
||||
@@ -211,8 +214,10 @@ public class WechatMiniMsgUtil {
|
||||
|
||||
|
||||
public JSONObject getSession(String code) {
|
||||
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
|
||||
String secrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_SECRETE);
|
||||
Map<String, String> userMini = sysParamsService.getParamsByMap("user_mini_key_set", ParamCodeCst.USER_MINI_KEY_SET);
|
||||
// 用户小程序参数
|
||||
String appId = userMini.get(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
|
||||
String secrete = userMini.get(ParamCodeCst.Wechat.Mini.USER_WX_SECRETE);
|
||||
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
|
||||
Map<String, Object> requestUrlParam = new HashMap<>();
|
||||
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
|
||||
|
||||
@@ -28,8 +28,6 @@ public class AppWxServiceImpl extends BaseWx {
|
||||
@DubboReference
|
||||
private SysParamsService paramsService;
|
||||
|
||||
private static final Set<String> USER_MINI_KEYS = Set.of(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID, ParamCodeCst.Wechat.Mini.USER_WX_SECRETE);
|
||||
|
||||
public AppWxServiceImpl(@Autowired RedisService autoRedisService) {
|
||||
this.redisService = autoRedisService;
|
||||
config = new Config();
|
||||
@@ -64,10 +62,10 @@ public class AppWxServiceImpl extends BaseWx {
|
||||
@Override
|
||||
public void init() throws CzgException {
|
||||
// 用户小程序参数
|
||||
Map<String, String> userMiniKeyMap = paramsService.getParamsByMap("userMiniKeys", USER_MINI_KEYS);
|
||||
Map<String, String> userMiniKeyMap = paramsService.getParamsByMap("user_mini_key_set", ParamCodeCst.USER_MINI_KEY_SET);
|
||||
|
||||
// 微信支付参数
|
||||
Map<String, String> payKeyMap = paramsService.getParamsByMap("payKeys", PAY_KEYS);
|
||||
Map<String, String> payKeyMap = paramsService.getParamsByMap("pay_key_set", ParamCodeCst.PAY_KEY_SET);
|
||||
|
||||
// 小程序id
|
||||
config.appId = userMiniKeyMap.get(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
|
||||
|
||||
@@ -59,18 +59,6 @@ public abstract class BaseWx {
|
||||
*/
|
||||
protected static final Long EXPIRES_OFFSET = 200L;
|
||||
|
||||
/**
|
||||
* 支付参数KEY
|
||||
*/
|
||||
protected static final Set<String> PAY_KEYS = Set.of(
|
||||
ParamCodeCst.Wechat.Pay.WX_PUB_KEY,
|
||||
ParamCodeCst.Wechat.Pay.WX_API_CLIENT_KEY,
|
||||
ParamCodeCst.Wechat.Pay.WX_API_CLIENT_CERT,
|
||||
ParamCodeCst.Wechat.Pay.WX_MCH_ID,
|
||||
ParamCodeCst.Wechat.Pay.WX_V3_KEY,
|
||||
ParamCodeCst.System.NATIVE_NOTIFY_URL
|
||||
);
|
||||
|
||||
/**
|
||||
* 初始化配置信息
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ public class WxServiceImpl extends BaseWx {
|
||||
@Override
|
||||
public void init() {
|
||||
// 商户小程序参数
|
||||
Map<String, String> shopMiniKeyMap = paramsService.getParamsByMap("shopMiniKeys", shopMiniKeys);
|
||||
Map<String, String> shopMiniKeyMap = paramsService.getParamsByMap("shop_mini_key_set", ParamCodeCst.SHOP_MINI_KEY_SET);
|
||||
|
||||
// 小程序id
|
||||
config.appId = shopMiniKeyMap.get(ParamCodeCst.Wechat.Mini.SHOP_WX_APP_ID);
|
||||
@@ -72,7 +72,7 @@ public class WxServiceImpl extends BaseWx {
|
||||
config.appSecret = shopMiniKeyMap.get(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
|
||||
|
||||
// 微信支付参数
|
||||
Map<String, String> payKeyMap = paramsService.getParamsByMap("payKeys", PAY_KEYS);
|
||||
Map<String, String> payKeyMap = paramsService.getParamsByMap("pay_key_set", ParamCodeCst.PAY_KEY_SET);
|
||||
config.certPath = "";
|
||||
// 微信支付公钥
|
||||
config.pubKey = payKeyMap.get(ParamCodeCst.Wechat.Pay.WX_PUB_KEY);
|
||||
|
||||
@@ -12,6 +12,9 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 验证码工具类
|
||||
*
|
||||
@@ -23,38 +26,24 @@ public class SmsServiceImpl implements SmsService {
|
||||
@Resource
|
||||
private SysParamsService sysParamsService;
|
||||
|
||||
/**
|
||||
* 阿里云key
|
||||
*/
|
||||
private String key;
|
||||
/**
|
||||
* 阿里云secret
|
||||
*/
|
||||
private String secret;
|
||||
/**
|
||||
* 短信模板id
|
||||
*/
|
||||
private String templateCode;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
key = sysParamsService.getSysParamValue(ParamCodeCst.AliYun.ALI_SMS_KEY);
|
||||
secret = sysParamsService.getSysParamValue(ParamCodeCst.AliYun.ALI_SMS_SECRET);
|
||||
templateCode = sysParamsService.getSysParamValue(ParamCodeCst.AliYun.ALI_SMS_TEMPLATE_CODE);
|
||||
log.info("短信工具类初始化完毕,key: {}, secret: {}, templateCode: {}", key, secret, templateCode);
|
||||
}
|
||||
|
||||
public Client createClient() throws Exception {
|
||||
public Client init() throws Exception {
|
||||
Config config = new Config();
|
||||
config.accessKeyId = key;
|
||||
config.accessKeySecret = secret;
|
||||
Map<String, String> aliOssKeys = sysParamsService.getParamsByMap("ali_oss_key_set", ParamCodeCst.ALI_OSS_KEY_SET);
|
||||
config.accessKeyId = aliOssKeys.get(ParamCodeCst.AliYun.ALI_SMS_KEY);
|
||||
config.accessKeySecret = aliOssKeys.get(ParamCodeCst.AliYun.ALI_SMS_SECRET);
|
||||
templateCode = aliOssKeys.get(ParamCodeCst.AliYun.ALI_SMS_TEMPLATE_CODE);
|
||||
return new Client(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCode(String phone, String checkCode) {
|
||||
try {
|
||||
Client client = createClient();
|
||||
Client client = init();
|
||||
// 1.发送短信
|
||||
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
|
||||
.setSignName("陕西超掌柜科技")
|
||||
@@ -67,7 +56,7 @@ public class SmsServiceImpl implements SmsService {
|
||||
if (sendSmsResponse.getStatusCode() != 200) {
|
||||
throw new CzgException("短信发送失败");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.info("发送短信失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,12 +140,12 @@ public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams
|
||||
|
||||
@Cacheable(cacheNames = "params:entity", key = "#type")
|
||||
@Override
|
||||
public Map<String, String> getParamsByMap(String type, Set<String> keyList) throws CzgException{
|
||||
public Map<String, String> getParamsByMap(String type, Set<String> keyList) throws CzgException {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (String key : keyList) {
|
||||
SysParams sysParam = getSysParam(key);
|
||||
if (sysParam == null || StrUtil.isBlank(sysParam.getParamValue())) {
|
||||
throw new CzgException(key + "参数不存在");
|
||||
throw new CzgException("sysParam的类型" + type + " 的 " + key + "参数不存在");
|
||||
}
|
||||
map.put(key, sysParam.getParamValue());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user