|
|
@@ -12,6 +12,7 @@ using System.Net; |
|
|
|
using Learun.Cache.Base; |
|
|
|
using Learun.Cache.Factory; |
|
|
|
using Nancy.Responses; |
|
|
|
using Quanjiang.DigitalScholl.SendSms; |
|
|
|
|
|
|
|
namespace Learun.Application.WebApi |
|
|
|
{ |
|
|
@@ -27,6 +28,7 @@ namespace Learun.Application.WebApi |
|
|
|
private SunshineEducationIBLL sunshineEducationIBLL = new SunshineEducationBLL(); |
|
|
|
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); |
|
|
|
private ICache redisCache = CacheFactory.CaChe(); |
|
|
|
private readonly ISms yixintongSms = new YixintongSms(); |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 阳光教育 |
|
|
@@ -56,11 +58,58 @@ namespace Learun.Application.WebApi |
|
|
|
public Response CheckVerifyCode(dynamic _) |
|
|
|
{ |
|
|
|
MobileVerify mobileVerify = this.GetReqData<MobileVerify>(); |
|
|
|
var code = redisCache.Read<string>("sunshineimgvcode" + mobileVerify.pagecode); |
|
|
|
var code = redisCache.Read<string>("sunshineimgvcode_" + mobileVerify.pagecode); |
|
|
|
LogEntity logEntity = null; |
|
|
|
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode) |
|
|
|
{ |
|
|
|
//发送短信 |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
//学生增加短信发送验证 |
|
|
|
string raRndNum = Learun.Util.CommonHelper.RndNum(6); |
|
|
|
var listStr = new List<string>(); |
|
|
|
var str1 = $"您本次提交的验证码是" + raRndNum + "。"; |
|
|
|
listStr.Add(str1); |
|
|
|
var result = yixintongSms.SendSmsToSingle(mobileVerify.mobile, SmsType.LoginBind, listStr); |
|
|
|
if (result.Result.code == "0") |
|
|
|
{ |
|
|
|
redisCache.Write<string>("sunshinesmscode_"+mobileVerify.pagecode +"_"+ mobileVerify.mobile, raRndNum, new TimeSpan(0, 5, 0)); |
|
|
|
//日志 |
|
|
|
logEntity = new LogEntity(); |
|
|
|
logEntity.F_CategoryId = 3; |
|
|
|
logEntity.F_OperateTypeId = "sms"; |
|
|
|
logEntity.F_OperateType = "sms"; |
|
|
|
logEntity.F_OperateAccount = "system"; |
|
|
|
logEntity.F_ExecuteResult = 200; |
|
|
|
logEntity.F_ExecuteResultJson = "短信发送成功:" + result.Result.message; |
|
|
|
logEntity.F_Description = "短信发送:" + mobileVerify.mobile; |
|
|
|
logEntity.WriteLog(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
logEntity = new LogEntity(); |
|
|
|
logEntity.F_CategoryId = 4; |
|
|
|
logEntity.F_OperateTypeId = "sms"; |
|
|
|
logEntity.F_OperateType = "sms"; |
|
|
|
logEntity.F_OperateAccount = "system"; |
|
|
|
logEntity.F_ExecuteResult = 400; |
|
|
|
logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType; |
|
|
|
logEntity.F_Description = "短信发送:" + mobileVerify.mobile; |
|
|
|
logEntity.WriteLog(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
logEntity = new LogEntity(); |
|
|
|
logEntity.F_CategoryId = 4; |
|
|
|
logEntity.F_OperateTypeId = "sms"; |
|
|
|
logEntity.F_OperateType = "sms"; |
|
|
|
logEntity.F_OperateAccount = "system"; |
|
|
|
logEntity.F_ExecuteResult = 400; |
|
|
|
logEntity.F_ExecuteResultJson = "短信发送失败:" + e.Message; |
|
|
|
logEntity.F_Description = "短信发送:" + mobileVerify.mobile; |
|
|
|
logEntity.WriteLog(); |
|
|
|
} |
|
|
|
return Success("短信验证码已成功发送。"); |
|
|
|
} |
|
|
|
else |
|
|
@@ -86,7 +135,7 @@ namespace Learun.Application.WebApi |
|
|
|
try |
|
|
|
{ |
|
|
|
(byte[] buffer,string code) = new VerifyCode().GetVerifyCodeForMobileApi(); |
|
|
|
redisCache.Write<string>("sunshineimgvcode" + pagecode, code, new TimeSpan(0, 5, 0)); |
|
|
|
redisCache.Write<string>("sunshineimgvcode_" + pagecode, code, new TimeSpan(0, 5, 0)); |
|
|
|
ms = new MemoryStream(buffer); |
|
|
|
return ms; |
|
|
|
} |
|
|
@@ -194,13 +243,23 @@ namespace Learun.Application.WebApi |
|
|
|
return Fail("评论失败,受理单号不正确"); |
|
|
|
} |
|
|
|
entity.Contents = data.Contents; |
|
|
|
sunshineEducationIBLL.SaveEntity(parameter.keyValue, entity); |
|
|
|
return Success("提交成功!"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
entity.Contents = WebHelper.HtmlEncode(entity.Contents); |
|
|
|
var code = redisCache.Read<string>("sunshinesmscode_" +entity.pagecode+"_" + entity.mobile); |
|
|
|
if (entity.smscode== code) |
|
|
|
{ |
|
|
|
sunshineEducationIBLL.SaveEntity(parameter.keyValue, entity); |
|
|
|
return Success("提交成功!"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return Fail("验证失败,验证码错误或已失效。"); |
|
|
|
} |
|
|
|
} |
|
|
|
sunshineEducationIBLL.SaveEntity(parameter.keyValue, entity); |
|
|
|
return Success("保存成功!"); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|