.netCore(登录)
程序员文章站
2022-03-09 10:44:54
...
public BaseModelOut<CourierLoginOutDto> JDLogin(CourierLoginInDto para)
{
BaseModelOut<CourierLoginOutDto> ret = new BaseModelOut<CourierLoginOutDto>();
var user = new KernelAccount();
user = _loginCourierService.QueryAccountByMobile(para.AccountMobile); //判断用户是否存在
//用户不存在
if (user == null)
{
ret.Code = (int)ResponseCode.Fail;
ret.Data = null;
ret.IsSuccess = false;
ret.Message = "登录失败 用户名或密码错误";
return ret;
}
var decryptPwd = EncryptUtil.DesDecrypt(para.AccountPwd, para.AccountMobile); //DES解密密码
var shardId = GetShardID(user.TenantId); //获取分库编号
//MD5加密密码
var encryptPwd = EncryptUtil.StandMD5Encrypt(decryptPwd + user.PasswordSalt);
//账户名或密码错误
if (!user.AccountPwd.Equals(encryptPwd))
{
ret.Code = (int)ResponseCode.Fail;
ret.Data = null;
ret.IsSuccess = false;
ret.Message = "登录失败 用户名或密码错误";
return ret;
}
//判断用户类别是否可以登录智能柜
if (!_loginCourierService.IsLoginVerticalTank(user.AccountType))
{
ret.Code = (int)ResponseCode.Fail;
ret.Data = null;
ret.IsSuccess = false;
ret.Message = "登录失败 该用户无权限登录" + user.AccountType;
return ret;
}
//判断用户状态
if (user.AccountStatus == 2 || user.IsActive == 0)
{
ret.Code = (int)ResponseCode.Fail;
ret.Data = null;
ret.IsSuccess = false;
ret.Message = "登录失败 该用户状态异常";
return ret;
}
CourierLoginOutDto outDto = new CourierLoginOutDto()
{
TenantId = user.TenantId,
AccountId = user.AccountId,
AccountName = user.AccountName,
AccountMobile = user.AccountMobile
};
ret.Code = (int)ResponseCode.Success;
ret.Data = outDto;
ret.IsSuccess = true;
ret.Message = "登录成功";
return ret;
}