Browse Source

配置化 腾讯云APPID 和 APPKEY

lifa 1 year ago
parent
commit
16032118b1

+ 5 - 0
src/hosts/DiTui.Host/Configs/appconfig.json

@@ -114,5 +114,10 @@
     "firstImg": "https://test-dt.zhongjie51.com/images/kuake.png",
     "signUrl": "https://broccoli.uc.cn/apps/dtEOu8NBM/routes/hZOc6scpp?uc_param_str=dsdnfrpfbivesscpgimibtbmnijblauputogpintnwktprchmt&uc_biz_str=S%3Acustom%7CC%3Atitlebar_hover_2",
     "industry": "[{\"label\":\"资料软件\",\"value\":\"资料软件\"},{\"label\":\"视频\",\"value\":\"视频\"},{\"label\":\"搜索\",\"value\":\"搜索\"},{\"label\":\"壁纸\",\"value\":\"壁纸\"},{\"label\":\"小说\",\"value\":\"小说\"},{\"label\":\"抖快\",\"value\":\"抖快\"},{\"label\":\"软件\",\"value\":\"软件\"},{\"label\":\"教育\",\"value\":\"教育\"},{\"label\":\"视频(QQ群)\",\"value\":\"视频(QQ群)\"},{\"label\":\"代运营\",\"value\":\"代运营\"},{\"label\":\"垂直资料\",\"value\":\"垂直资料\"},{\"label\":\"其他\",\"value\":\"其他\"}]"
+  },
+  // 腾讯云短信相关配置
+  "qCloudSet": {
+    "appId": 1400153514,
+    "appKey": "fe967a103fcfac54b41bddf50a2863b8"
   }
 }

+ 8 - 0
src/platform/ZhonTai.Admin/Core/Configs/AppConfig.cs

@@ -109,6 +109,8 @@ public class AppConfig
     /// 夸克相关配置
     /// </summary>
     public KuaKeConfig KuaKeSet { get; set; } = new KuaKeConfig();
+
+    public QCloud QCloudSet { get; set; } = new QCloud();
     
 }
 
@@ -354,6 +356,12 @@ public class KuaKeConfig
     public string Industry { get; set; }
 }
 
+public class QCloud
+{
+    public int AppId { get; set; }
+    public string AppKey { get; set; }
+}
+
 /// <summary>
 /// 应用程序类型
 /// </summary>

+ 10 - 2
src/platform/ZhonTai.Admin/Core/Helpers/QCloudSmsHelper.cs

@@ -13,14 +13,22 @@ using System.Security.Cryptography;
 
 namespace ZhonTai.Admin.Core.Helpers
 {
+    
     public class QCloudSmsHelper
     {
+        private readonly AppConfig _appConfig;
+
+        public QCloudSmsHelper (AppConfig appConfig)
+        {
+            _appConfig = appConfig;
+        }
+
         public string QcloudSendNotification(string mobile, string content)
         {
             // 请根据实际 appid 和 appkey 进行开发,以下只作为演示 sdk 使用
             // appid,appkey,templId申请方式可参考接入指南 https://www.qcloud.com/document/product/382/3785#5-.E7.9F.AD.E4.BF.A1.E5.86.85.E5.AE.B9.E9.85.8D.E7.BD.AE
-            int sdkappid = 1400153514;//1400153514
-            string appkey = "fe967a103fcfac54b41bddf50a2863b8"; //"fe967a103fcfac54b41bddf50a2863b8";
+            int sdkappid = _appConfig.QCloudSet.AppId; // 1400153514
+            string appkey = _appConfig.QCloudSet.AppKey; //"fe967a103fcfac54b41bddf50a2863b8";
             try
             {
                 SmsSingleSenderResult singleResult;

+ 1 - 1
src/platform/ZhonTai.Admin/Services/DiTuiAPI/DiTuiAPIService.cs

@@ -375,7 +375,7 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
             string racode = "您的验证码是:{0}。请不要把验证码泄露给其他人。";
             string vCode = this.GenerateRandom(6);
             racode = string.Format(racode, vCode);
-            var obj = new QCloudSmsHelper().QcloudSendNotification(phone, racode);
+            var obj = new QCloudSmsHelper(_appConfig).QcloudSendNotification(phone, racode);
             var smsEntity = new SmsEntity();
             smsEntity.Mobile = phone;
             smsEntity.Vcode = vCode;