Переглянути джерело

【修改】阿里云短信配置;发送短信功能对接短信接口;

西昌分支
dyy 4 місяці тому
джерело
коміт
dd4ce931fe
6 змінених файлів з 47 додано та 76 видалено
  1. +12
    -17
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
  2. +11
    -18
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs
  3. +11
    -18
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs
  4. +10
    -17
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs
  5. +2
    -5
      Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/AliyunSms.cs
  6. +1
    -1
      Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/App.config

+ 12
- 17
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs Переглянути файл

@@ -18,6 +18,7 @@ using Learun.Application.TwoDevelopment.LR_Desktop;
using Learun.Application.TwoDevelopment.Permission;
using Learun.Application.WorkFlow;
using Learun.Application.OA.Email.EmailSend;
using Quanjiang.DigitalScholl.SendSms;

namespace Learun.Application.Web.Controllers
{
@@ -60,6 +61,7 @@ namespace Learun.Application.Web.Controllers
private ICache redisCache = CacheFactory.CaChe();
private Sys_DefaultPwdConfigIBLL sys_DefaultPwdConfigIBLL = new Sys_DefaultPwdConfigBLL();
private EmailSendIBLL emailSendIBLL = new EmailSendBLL();
private readonly ISms aliyunSms = new AliyunSms();
#region 视图功能

public ActionResult FirstChangePwd()
@@ -764,18 +766,11 @@ namespace Learun.Application.Web.Controllers
{
return Fail("手机号格式不正确!");
}
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
var listStr = new List<string>();
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
listStr.Add(str1);
//todo:待开发短信平台
//var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
//if (result.Result.code == "0")
if (true)
var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
if (result.Result.code == "OK")
{
redisCache.Write<string>("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms);
redisCache.Write<string>("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms);
//日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
@@ -784,10 +779,10 @@ namespace Learun.Application.Web.Controllers
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 200;
logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum;
logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + result.Result.randomNum;
logEntity.WriteLog();
return Success("短信发送成功:");// + result.Result.message);
return Success("短信发送成功:" + result.Result.message);
}
else
{
@@ -798,10 +793,10 @@ namespace Learun.Application.Web.Controllers
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 400;
//logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
//logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
//logEntity.WriteLog();
//return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
logEntity.WriteLog();
return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
}
}



+ 11
- 18
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs Переглянути файл

@@ -1254,18 +1254,11 @@ namespace Learun.Application.Web.Controllers
{
return Fail("当前用户非首次登录,请使用账号密码进行登录!");
}
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
var listStr = new List<string>();
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
listStr.Add(str1);
//todo:待开发短信平台
//var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
//if (result.Result.code == "0")
if (true)
{
redisCache.Write<string>("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms);
var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
if (result.Result.code == "OK")
{
redisCache.Write<string>("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms);
//日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
@@ -1274,10 +1267,10 @@ namespace Learun.Application.Web.Controllers
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 200;
logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum;
logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + result.Result.randomNum;
logEntity.WriteLog();
return Success("短信发送成功:");// + result.Result.message);
return Success("短信发送成功:" + result.Result.message);
}
else
{
@@ -1288,10 +1281,10 @@ namespace Learun.Application.Web.Controllers
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 400;
//logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
//logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
//logEntity.WriteLog();
//return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
logEntity.WriteLog();
return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
}
}
/// <summary>


+ 11
- 18
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs Переглянути файл

@@ -117,18 +117,11 @@ namespace Learun.Application.WebApi
{
return Fail("手机号格式不正确!");
}
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
var listStr = new List<string>();
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
listStr.Add(str1);
//todo:待开发短信平台
//var result = aliyunSms.SendSmsToSingle(loginModel.username, SmsType.LoginBind, listStr);
//if (result.Result.code == "0")
if (true)
{
redisCache.Write<string>("sendcodeinapp_" + loginModel.codeType + "_" + loginModel.username, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms);
var result = aliyunSms.SendSmsToSingle(loginModel.username, SmsType.LoginBind, listStr);
if (result.Result.code == "OK")
{
redisCache.Write<string>("sendcodeinapp_" + loginModel.codeType + "_" + loginModel.username, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms);
//日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
@@ -137,10 +130,10 @@ namespace Learun.Application.WebApi
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 200;
logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message;
logEntity.F_Description = "短信发送:" + loginModel.username + " 验证码:" + raRndNum;
logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message;
logEntity.F_Description = "短信发送:" + loginModel.username + " 验证码:" + result.Result.randomNum;
logEntity.WriteLog();
return Success("短信发送成功:");// + result.Result.message);
return Success("短信发送成功:" + result.Result.message);
}
else
{
@@ -151,10 +144,10 @@ namespace Learun.Application.WebApi
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 400;
//logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
//logEntity.F_Description = "短信发送:" + loginModel.username;
//logEntity.WriteLog();
//return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
logEntity.F_Description = "短信发送:" + loginModel.username;
logEntity.WriteLog();
return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
}
}



+ 10
- 17
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs Переглянути файл

@@ -112,18 +112,11 @@ namespace Learun.Application.WebApi
{
return Fail("当前用户非首次登录,请使用账号密码进行登录!");
}
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
var listStr = new List<string>();
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
listStr.Add(str1);
//todo:待开发短信平台
//var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
//if (result.Result.code == "0")
if (true)
var result = aliyunSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
if (result.Result.code == "OK")
{
redisCache.Write<string>("sendcodeinapp_" + loginModel.codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0), CacheId.sms);
redisCache.Write<string>("sendcodeinapp_" + loginModel.codeType + "_" + userEntity.F_Mobile, result.Result.randomNum, new TimeSpan(0, 5, 0), CacheId.sms);
//日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
@@ -132,10 +125,10 @@ namespace Learun.Application.WebApi
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 200;
logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum;
logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + result.Result.randomNum;
logEntity.WriteLog();
return Success("短信发送成功:");// + result.Result.message);
return Success("短信发送成功:" + result.Result.message);
}
else
{
@@ -146,10 +139,10 @@ namespace Learun.Application.WebApi
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 400;
//logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
//logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
//logEntity.WriteLog();
//return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
logEntity.WriteLog();
return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
}
}
/// <summary>


+ 2
- 5
Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/AliyunSms.cs Переглянути файл

@@ -70,14 +70,11 @@ namespace Quanjiang.DigitalScholl.SendSms
var randomNum = CommonHelper.RandNum(6);
switch (st)
{
case SmsType.Register:
result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum);
break;
case SmsType.LoginBind:
result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum);
result = ("SMS_468910589", JsonConvert.SerializeObject(new { code = randomNum }), randomNum);
break;
case SmsType.ForgetPassWord:
result = ("SMS_137485060", JsonConvert.SerializeObject(new { code = randomNum }), randomNum);
result = ("SMS_468910589", JsonConvert.SerializeObject(new { code = randomNum }), randomNum);
break;
default:
throw new ArgumentOutOfRangeException(nameof(st), st, null);


+ 1
- 1
Learun.Framework.Ultimate V7/Quanjiang.DigitalScholl.SendSms/App.config Переглянути файл

@@ -7,7 +7,7 @@
<add key="accessId" value="LTAI5tN7Ho7CDCofubXpnBV5" />
<add key="accessSecret" value="U3wm0BhY6S3x4bPcCOWrjUz6tDTo6H" />
<add key="regionIdForPop" value="cn-hangzhou" />
<add key="SignName" value="阿里云短信测试专用" />
<add key="SignName" value="西昌民族幼专" />
<!--斑羚短信平台-->
<add key="sdkappid" value="140009369387" />
<add key="appkey" value="4d2743a4233e5d8625eefa31f876721b" />


Завантаження…
Відмінити
Зберегти