Commit 335e8794 authored by 黄奎's avatar 黄奎

1111

parent ac3c4dff
......@@ -14,6 +14,14 @@ namespace EduSpider.IServices
public interface IAccountService : IDependency
{
List<rb_account_hk_Extend> GetAccountList(rb_account_hk_Extend demodel);
bool UpdateAccountUnionId(rb_account_hk_Extend model);
/// <summary>
/// 修改登录密码
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool UpdatePassword(rb_account_hk_Extend model);
}
}
......@@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using VTX.FW.Attr;
using VTX.FW.DB;
using VTX.FW.Helper;
namespace EduSpider.Services
{
......@@ -41,15 +42,41 @@ namespace EduSpider.Services
/// <returns></returns>
public bool UpdateAccountUnionId(rb_account_hk_Extend model)
{
Dictionary<string, object> keyValues = new() {
{ nameof(rb_account_hk_Extend.OpenId), model.OpenId},
{ nameof(rb_account_hk_Extend.UnionId), model.UnionId},
Dictionary<string, object> keyValues = new()
{
{ nameof(rb_account_hk_Extend.OpenId), model.OpenId },
{ nameof(rb_account_hk_Extend.UnionId), model.UnionId },
};
List<WhereHelper> wheres = new() {
new WhereHelper(){
FiledName = nameof(rb_account_hk_Extend.Id),
FiledValue = model.Id,
OperatorEnum = OperatorEnum.Equal
List<WhereHelper> wheres = new()
{
new WhereHelper()
{
FiledName = nameof(rb_account_hk_Extend.Id),
FiledValue = model.Id,
OperatorEnum = OperatorEnum.Equal
}
};
return accountRepository.Update(keyValues, wheres);
}
/// <summary>
/// 修改登录密码
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool UpdatePassword(rb_account_hk_Extend model)
{
Dictionary<string, object> keyValues = new()
{
{ nameof(rb_account_hk_Extend.Password), DESHepler.Encrypt(model.Password) },
};
List<WhereHelper> wheres = new()
{
new WhereHelper()
{
FiledName = nameof(rb_account_hk_Extend.Id),
FiledValue = model.Id,
OperatorEnum = OperatorEnum.Equal
}
};
return accountRepository.Update(keyValues, wheres);
......
......@@ -91,7 +91,7 @@ namespace EduSpider.WebApi.Controllers
#region 获取进阶思维小程序端token
BaseUserInfo UserInfo = new() { BaseUserId = model.UniqueId };
string token = JwtHelper.CreateToken(UserInfo, Config.JwtSecretKey, Config.JwtExpirTime);
string token = JwtHelper.CreateToken(UserInfo, Config.JwtSecretKey, Config.JwtExpirTime);
#endregion
Model.Cache.UserInfo obj = new()
......@@ -435,5 +435,60 @@ namespace EduSpider.WebApi.Controllers
return res;
}
#endregion
/// <summary>
/// 修改教师密码
/// </summary>
/// <returns></returns>
[HttpGet]
[HttpPost]
[AllowAnonymous]
public ApiResult UpdatePwd()
{
string account = base.ReqParameters.GetString("Account");
//原密码
string oldPassword = base.ReqParameters.GetString("OldPassword").Trim();
//新密码
string newPassword1 = base.ReqParameters.GetString("NewPassword1").Trim();
string newPassword2 = base.ReqParameters.GetString("NewPassword2").Trim();
var accountModel = AccountService.GetAccountList(new rb_account_hk_Extend()
{
AccountType = Utility.Enum.AccountTypeEnum.Teacher,
Account = account
}).FirstOrDefault();
if (accountModel == null)
{
return ApiResult.Failed(message: "未找到此用户");
}
if (string.IsNullOrWhiteSpace(oldPassword))
{
return ApiResult.Failed(message: "原密码不能为空!");
}
if (!string.IsNullOrWhiteSpace(oldPassword) && accountModel.Password != DESHepler.Encrypt(oldPassword))
{
return ApiResult.Failed(message: "原密码不正确!");
}
if (string.IsNullOrWhiteSpace(newPassword1) )
{
return ApiResult.Failed(message: "请填写新密码!");
}
if (string.IsNullOrWhiteSpace(newPassword2))
{
return ApiResult.Failed(message: "请再次输入新密码!");
}
if (newPassword1!=newPassword2)
{
return ApiResult.Failed(message: "两次密码填写不一致!");
}
var newModel = new rb_account_hk_Extend()
{
Id = accountModel.Id,
Account = account,
Password = newPassword1
};
bool flag = AccountService.UpdatePassword(newModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment