Browse Source

缓存修复

master
wxd 2 years ago
parent
commit
91f81a8933
  1. 18
      src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs
  2. 8
      src/Shentun.Peis.Application/DeviceTypes/DeviceTypeAppService.cs
  3. 2
      src/Shentun.Peis.Application/ForSexs/ForSexAppService.cs
  4. 4
      src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs
  5. 584
      src/Shentun.Peis.Application/MyUser/MyUserAppService.cs
  6. 4
      src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs
  7. 8
      src/Shentun.Peis.Application/Sexs/SexAppService.cs

18
src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs

@ -207,7 +207,7 @@ namespace Shentun.Peis.Asbitems
var createEntity = ObjectMapper.Map<CreateAsbitemDto, Asbitem>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
await _asbitemCache.SetAsync(entity.Id, entity);
_asbitemCache.Set(entity.Id, entity);
var dto = ObjectMapper.Map<Asbitem, AsbitemDto>(entity);
return dto;
}
@ -223,7 +223,7 @@ namespace Shentun.Peis.Asbitems
var sourceEntity = ObjectMapper.Map<UpdateAsbitemDto, Asbitem>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
await _asbitemCache.SetAsync(entity.Id, entity);
_asbitemCache.Set(entity.Id, entity);
return ObjectMapper.Map<Asbitem, AsbitemDto>(entity);
}
/// <summary>
@ -288,5 +288,19 @@ namespace Shentun.Peis.Asbitems
return result;
}
/// <summary>
/// 获取组合项目的缓存信息
/// </summary>
/// <param name="AsbitemId"></param>
/// <returns></returns>
[HttpPost("api/app/Asbitem/GetAsbitemCacheByAsbitemId")]
public async Task<Asbitem> GetAsbitemCacheByAsbitemIdAsync(Guid AsbitemId)
{
//var asbitemEnt = await _cacheService.GetAsbitemAsync(AsbitemId);
var asbitemEnt = await _asbitemCache.GetAsync(AsbitemId);
return asbitemEnt;
}
}
}

8
src/Shentun.Peis.Application/DeviceTypes/DeviceTypeAppService.cs

@ -99,7 +99,7 @@ namespace Shentun.Peis.DeviceTypes
Id = s.Id,
LastModificationTime = s.LastModificationTime,
LastModifierId = s.LastModifierId,
SimpleCode = s.SimpleCode,
SimpleCode = s.SimpleCode,
CheckTypeFlag = s.CheckTypeFlag,
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result
@ -121,7 +121,7 @@ namespace Shentun.Peis.DeviceTypes
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
var dto = ObjectMapper.Map<DeviceType, DeviceTypeDto>(entity);
await _deviceTypeCache.SetAsync(entity.Id, entity);
_deviceTypeCache.Set(entity.Id, entity);
return dto;
}
/// <summary>
@ -136,7 +136,7 @@ namespace Shentun.Peis.DeviceTypes
var sourceEntity = ObjectMapper.Map<UpdateDeviceTypeDto, DeviceType>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
await _deviceTypeCache.SetAsync(entity.Id, entity);
_deviceTypeCache.Set(entity.Id, entity);
return ObjectMapper.Map<DeviceType, DeviceTypeDto>(entity);
}
/// <summary>
@ -150,7 +150,7 @@ namespace Shentun.Peis.DeviceTypes
await _manager.CheckAndDeleteAsync(entity);
}
/// <summary>
/// 修改排序 置顶,置底

2
src/Shentun.Peis.Application/ForSexs/ForSexAppService.cs

@ -48,7 +48,7 @@ namespace Shentun.Peis.ForSexs
var sourceEntity = ObjectMapper.Map<UpdateForSexDto, ForSex>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await _forSexRepository.UpdateAsync(entity);
await _forSexCache.SetAsync(entity.Id, entity);
_forSexCache.Set(entity.Id, entity);
return ObjectMapper.Map<ForSex, ForSexDto>(entity);
}

4
src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs

@ -78,7 +78,7 @@ namespace Shentun.Peis.ItemTypes
var createEntity = ObjectMapper.Map<CreateItemTypeDto, ItemType>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
await _itemTypeCache.SetAsync(entity.Id, entity);
_itemTypeCache.Set(entity.Id, entity);
await _manager.UpdateDisplayOrder(); //全局更新
var dto = ObjectMapper.Map<ItemType, ItemTypeDto>(entity);
return dto;
@ -95,7 +95,7 @@ namespace Shentun.Peis.ItemTypes
var sourceEntity = ObjectMapper.Map<UpdateItemTypeDto, ItemType>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
await _itemTypeCache.SetAsync(entity.Id, entity);
_itemTypeCache.Set(entity.Id, entity);
return ObjectMapper.Map<ItemType, ItemTypeDto>(entity);
}
/// <summary>

584
src/Shentun.Peis.Application/MyUser/MyUserAppService.cs

@ -233,7 +233,7 @@ namespace Shentun.Peis.MyUser
var entity = await _identityUserRepository.GetAsync(entityDto.Id);
await _userCache.SetAsync(entityDto.Id, entity);
_userCache.Set(entityDto.Id, entity);
return entityDto;
}
@ -318,358 +318,358 @@ namespace Shentun.Peis.MyUser
}
/// <summary>
/// 获取列表 根据用户类别
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[HttpPost("api/identity/users/GetListByOperatorType")]
public async Task<List<ListByOperatorTypeDto>> GetListByOperatorTypeAsync(OperatorTypeIuputDto input)
{
var entlist = await _identityUserRepository.GetListAsync(m => m.IsDeleted == false);
var entlistDto = entlist.Where(m => input.OperatorTypes.Contains(m.GetProperty<char>("operator_type"))).Select(s => new ListByOperatorTypeDto
/// <summary>
/// 获取列表 根据用户类别
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[HttpPost("api/identity/users/GetListByOperatorType")]
public async Task<List<ListByOperatorTypeDto>> GetListByOperatorTypeAsync(OperatorTypeIuputDto input)
{
Id = s.Id,
SimpleCode = LanguageConverter.GetPYSimpleCode(s.Surname),
Surname = s.Surname,
UserName = s.UserName
}).ToList();
return entlistDto;
}
var entlist = await _identityUserRepository.GetListAsync(m => m.IsDeleted == false);
var entlistDto = entlist.Where(m => input.OperatorTypes.Contains(m.GetProperty<char>("operator_type"))).Select(s => new ListByOperatorTypeDto
{
Id = s.Id,
SimpleCode = LanguageConverter.GetPYSimpleCode(s.Surname),
Surname = s.Surname,
UserName = s.UserName
}).ToList();
/// <summary>
/// 修改用户信息
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
//[Authorize(PeisPermissions.Users.Edit)]
//[HttpPost("api/identity/users/update")]
[RemoteService(false)]
public override async Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input)
{
var entityDto = await base.UpdateAsync(id, input);
return entlistDto;
}
var entity = await _identityUserRepository.GetAsync(id);
await _userCache.SetAsync(id, entity);
return entityDto;
/// <summary>
/// 修改用户信息
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
//[Authorize(PeisPermissions.Users.Edit)]
//[HttpPost("api/identity/users/update")]
[RemoteService(false)]
public override async Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input)
{
var entityDto = await base.UpdateAsync(id, input);
}
var entity = await _identityUserRepository.GetAsync(id);
_userCache.Set(id, entity);
return entityDto;
/// <summary>
/// 修改
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Edit)]
[HttpPost("api/identity/users/update")]
public async Task<IdentityUserDto> UpdateIdentityUserAsync(Guid id, IdentityUserUpdateInputDto input)
{
}
#region 上传图片
string userPhoto = UploadUserPhotoAsync(new UploadUserPhotoInputDto
{
PictureBaseStr = input.UserPhoto,
UserId = id
});
string userSign = UploadUserSignAsync(new UploadUserPhotoInputDto
/// <summary>
/// 修改
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Edit)]
[HttpPost("api/identity/users/update")]
public async Task<IdentityUserDto> UpdateIdentityUserAsync(Guid id, IdentityUserUpdateInputDto input)
{
PictureBaseStr = input.UserSign,
UserId = id
});
#endregion
input.Email = input.UserName + "@qq.com";
await IdentityOptions.SetAsync();
#region 上传图片
string userPhoto = UploadUserPhotoAsync(new UploadUserPhotoInputDto
{
PictureBaseStr = input.UserPhoto,
UserId = id
});
string userSign = UploadUserSignAsync(new UploadUserPhotoInputDto
{
PictureBaseStr = input.UserSign,
UserId = id
});
#endregion
var user = await UserManager.GetByIdAsync(id);
input.Email = input.UserName + "@qq.com";
user.SetProperty("user_sign", userSign);
user.SetProperty("user_photo", userPhoto);
user.SetProperty("operator_type", input.OperatorType);
user.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
(await UserManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
await IdentityOptions.SetAsync();
await UpdateUserByInput(user, input);
input.MapExtraPropertiesTo(user);
var user = await UserManager.GetByIdAsync(id);
(await UserManager.UpdateAsync(user)).CheckErrors();
user.SetProperty("user_sign", userSign);
user.SetProperty("user_photo", userPhoto);
user.SetProperty("operator_type", input.OperatorType);
user.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
if (!input.Password.IsNullOrEmpty())
{
(await UserManager.RemovePasswordAsync(user)).CheckErrors();
(await UserManager.AddPasswordAsync(user, input.Password)).CheckErrors();
}
(await UserManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
await UpdateUserByInput(user, input);
input.MapExtraPropertiesTo(user);
var entityDto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
(await UserManager.UpdateAsync(user)).CheckErrors();
if (!input.Password.IsNullOrEmpty())
{
(await UserManager.RemovePasswordAsync(user)).CheckErrors();
(await UserManager.AddPasswordAsync(user, input.Password)).CheckErrors();
}
var entity = await _identityUserRepository.GetAsync(id);
await _userCache.SetAsync(id, entity);
return entityDto;
}
await CurrentUnitOfWork.SaveChangesAsync();
/// <summary>
/// 获取用户信息 根据ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
//[Authorize(PeisPermissions.Users.Default)]
//[HttpGet("api/identity/users/getinfo")]
[RemoteService(false)]
public override Task<IdentityUserDto> GetAsync(Guid id)
{
return base.GetAsync(id);
}
var entityDto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
/// <summary>
///上传用户照片 图片base64
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
private string UploadUserPhotoAsync(UploadUserPhotoInputDto input)
{
string fileName = "";
if (input.UserId != null)
{
fileName = input.UserId.ToString();
var entity = await _identityUserRepository.GetAsync(id);
_userCache.Set(id, entity);
return entityDto;
}
else
/// <summary>
/// 获取用户信息 根据ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
//[Authorize(PeisPermissions.Users.Default)]
//[HttpGet("api/identity/users/getinfo")]
[RemoteService(false)]
public override Task<IdentityUserDto> GetAsync(Guid id)
{
fileName = Guid.NewGuid().ToString();
return base.GetAsync(id);
}
string imgurl = $"UserPhoto/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{fileName}";
var isupload = ImageHelper.Base64StrToImage(input.PictureBaseStr, imgurl);
if (!string.IsNullOrEmpty(isupload))
return isupload;
else
return "";
}
/// <summary>
/// 上传用户签名 图片base64
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
private string UploadUserSignAsync(UploadUserPhotoInputDto input)
{
string fileName = "";
if (input.UserId != null)
{
fileName = input.UserId.ToString();
}
else
/// <summary>
///上传用户照片 图片base64
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
private string UploadUserPhotoAsync(UploadUserPhotoInputDto input)
{
fileName = Guid.NewGuid().ToString();
string fileName = "";
if (input.UserId != null)
{
fileName = input.UserId.ToString();
}
else
{
fileName = Guid.NewGuid().ToString();
}
string imgurl = $"UserPhoto/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{fileName}";
var isupload = ImageHelper.Base64StrToImage(input.PictureBaseStr, imgurl);
if (!string.IsNullOrEmpty(isupload))
return isupload;
else
return "";
}
string imgurl = $"UserSign/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{fileName}";
var isupload = ImageHelper.Base64StrToImage(input.PictureBaseStr, imgurl);
if (!string.IsNullOrEmpty(isupload))
return isupload;
else
return "";
}
/// <summary>
/// 获取用户信息 根据ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[HttpGet("api/identity/users/getinfo")]
public async Task<IdentityUserWithExtensionDto> GetWithExtensionAsync(Guid id)
{
var ent = await UserManager.GetByIdAsync(id);
var userSign = !string.IsNullOrWhiteSpace(ent.GetProperty<string>("user_sign")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty<string>("user_sign")) : "";
var userPhoto = !string.IsNullOrWhiteSpace(ent.GetProperty<string>("user_photo")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty<string>("user_photo")) : "";
var operatorType = ent.GetProperty<char>("operator_type");
var entDto = ObjectMapper.Map<IdentityUser, IdentityUserWithExtensionDto>(ent);
entDto.UserPhoto = userPhoto;
entDto.UserSign = userSign;
entDto.OperatorType = operatorType;
return entDto;
}
/// <summary>
/// 上传用户签名 图片base64
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
private string UploadUserSignAsync(UploadUserPhotoInputDto input)
{
string fileName = "";
if (input.UserId != null)
{
fileName = input.UserId.ToString();
}
else
{
fileName = Guid.NewGuid().ToString();
}
/// <summary>
/// 给用户绑定角色
/// </summary>
/// <param name="id">用户ID</param>
/// <param name="input">角色集合</param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Edit)]
[HttpPost("api/identity/users/updateroles")]
public override Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input)
{
return base.UpdateRolesAsync(id, input);
}
string imgurl = $"UserSign/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{fileName}";
var isupload = ImageHelper.Base64StrToImage(input.PictureBaseStr, imgurl);
if (!string.IsNullOrEmpty(isupload))
return isupload;
else
return "";
}
/// <summary>
/// 获取用户的角色信息 根据用户ID
/// </summary>
/// <param name="id">用户ID</param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[HttpGet("api/identity/users/getroles")]
public override Task<ListResultDto<IdentityRoleDto>> GetRolesAsync(Guid id)
{
return base.GetRolesAsync(id);
}
/// <summary>
/// 获取用户信息 根据ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[HttpGet("api/identity/users/getinfo")]
public async Task<IdentityUserWithExtensionDto> GetWithExtensionAsync(Guid id)
{
var ent = await UserManager.GetByIdAsync(id);
var userSign = !string.IsNullOrWhiteSpace(ent.GetProperty<string>("user_sign")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty<string>("user_sign")) : "";
var userPhoto = !string.IsNullOrWhiteSpace(ent.GetProperty<string>("user_photo")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty<string>("user_photo")) : "";
var operatorType = ent.GetProperty<char>("operator_type");
var entDto = ObjectMapper.Map<IdentityUser, IdentityUserWithExtensionDto>(ent);
entDto.UserPhoto = userPhoto;
entDto.UserSign = userSign;
entDto.OperatorType = operatorType;
return entDto;
}
/// <summary>
/// 给用户绑定角色
/// </summary>
/// <param name="id">用户ID</param>
/// <param name="input">角色集合</param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Edit)]
[HttpPost("api/identity/users/updateroles")]
public override Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input)
{
return base.UpdateRolesAsync(id, input);
}
/// <summary>
/// 获取当前登录用户的角色信息
/// </summary>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[HttpGet("api/identity/users/getassignableroles")]
public override Task<ListResultDto<IdentityRoleDto>> GetAssignableRolesAsync()
{
return base.GetAssignableRolesAsync();
}
/// <summary>
/// 获取用户的角色信息 根据用户ID
/// </summary>
/// <param name="id">用户ID</param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[HttpGet("api/identity/users/getroles")]
public override Task<ListResultDto<IdentityRoleDto>> GetRolesAsync(Guid id)
{
return base.GetRolesAsync(id);
}
/// <summary>
/// 暂未用到
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[RemoteService(false)]
public override Task<IdentityUserDto> FindByUsernameAsync(string userName)
{
return base.FindByUsernameAsync(userName);
}
/// <summary>
/// 暂未用到
/// </summary>
/// <param name="email"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[RemoteService(false)]
public override Task<IdentityUserDto> FindByEmailAsync(string email)
{
return base.FindByEmailAsync(email);
}
/// <summary>
/// 获取当前登录用户的角色信息
/// </summary>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[HttpGet("api/identity/users/getassignableroles")]
public override Task<ListResultDto<IdentityRoleDto>> GetAssignableRolesAsync()
{
return base.GetAssignableRolesAsync();
}
/// <summary>
/// 用户登录
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/identity/users/login")]
public async Task<UserLoginDto> UserLogin(UserLoginRequestDto input)
{
UserLoginDto msg;
/// <summary>
/// 暂未用到
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[RemoteService(false)]
public override Task<IdentityUserDto> FindByUsernameAsync(string userName)
{
return base.FindByUsernameAsync(userName);
}
/// <summary>
/// 暂未用到
/// </summary>
/// <param name="email"></param>
/// <returns></returns>
[Authorize(PeisPermissions.Users.Default)]
[RemoteService(false)]
public override Task<IdentityUserDto> FindByEmailAsync(string email)
{
return base.FindByEmailAsync(email);
}
var user = await _userManager.FindByNameAsync(input.UserName);
if (user != null)
/// <summary>
/// 用户登录
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/identity/users/login")]
public async Task<UserLoginDto> UserLogin(UserLoginRequestDto input)
{
var verifyResult = await _userManager.CheckPasswordAsync(user, input.PassWord);
if (verifyResult)
{
UserLoginDto msg;
var PeisId = await _peisOrganizationUnitManager.GetPeisIdAsync(user.Id);
if (user.IsActive == false)
{
throw new UserFriendlyException("账号已被禁用");
}
var user = await _userManager.FindByNameAsync(input.UserName);
if (user != null)
{
if (user.LockoutEnabled == true)
var verifyResult = await _userManager.CheckPasswordAsync(user, input.PassWord);
if (verifyResult)
{
throw new UserFriendlyException("账号已被锁定");
}
TokenResponse token = await RequestAuthServerLoginByPasswordAsync(input.UserName, input.PassWord);
var PeisId = await _peisOrganizationUnitManager.GetPeisIdAsync(user.Id);
if (token.HttpResponse != null && token.HttpResponse.StatusCode == HttpStatusCode.OK)
{
msg = new UserLoginDto
if (user.IsActive == false)
{
throw new UserFriendlyException("账号已被禁用");
}
if (user.LockoutEnabled == true)
{
throw new UserFriendlyException("账号已被锁定");
}
TokenResponse token = await RequestAuthServerLoginByPasswordAsync(input.UserName, input.PassWord);
if (token.HttpResponse != null && token.HttpResponse.StatusCode == HttpStatusCode.OK)
{
msg = new UserLoginDto
{
//code = 1,
//msg = "登录成功",
peisid = PeisId,
UserId = user.Id,
OperatorType = user.GetProperty<char>("operator_type"),
access_token = token.AccessToken,
expires_in = token.ExpiresIn,
refresh_token = token.RefreshToken,
token_type = token.TokenType
};
}
else
{
//code = 1,
//msg = "登录成功",
peisid = PeisId,
UserId = user.Id,
OperatorType = user.GetProperty<char>("operator_type"),
access_token = token.AccessToken,
expires_in = token.ExpiresIn,
refresh_token = token.RefreshToken,
token_type = token.TokenType
};
//msg = new UserLoginDto { code = 1, msg = "登录成功", peisid = PeisId };
throw new UserFriendlyException("获取token失败");
}
}
else
{
//msg = new UserLoginDto { code = 1, msg = "登录成功", peisid = PeisId };
throw new UserFriendlyException("获取token失败");
//msg = new UserLoginDto { code = -1, msg = "密码不正确" };
throw new UserFriendlyException("密码不正确");
}
}
else
{
//msg = new UserLoginDto { code = -1, msg = "密码不正确" };
throw new UserFriendlyException("密码不正确");
}
#region MyRegion
//var verifyResult = _passwordHasher.VerifyHashedPassword(user, user.PasswordHash, PassWord);
#region MyRegion
//var verifyResult = _passwordHasher.VerifyHashedPassword(user, user.PasswordHash, PassWord);
//if (verifyResult == PasswordVerificationResult.Success)
//{
// return "1";
//}
//else
//{
// throw new UserFriendlyException("密码错误");
//}
#endregion
//if (verifyResult == PasswordVerificationResult.Success)
//{
// return "1";
//}
//else
//{
// throw new UserFriendlyException("密码错误");
//}
#endregion
}
else
{
//msg = new UserLoginDto { code = -1, msg = "用户不存在" };
throw new UserFriendlyException("用户不存在");
}
return msg;
}
else
{
//msg = new UserLoginDto { code = -1, msg = "用户不存在" };
throw new UserFriendlyException("用户不存在");
}
}
return msg;
}
protected virtual async Task<TokenResponse> RequestAuthServerLoginByPasswordAsync(string username, string password)
{
var client = _httpClientFactory.CreateClient();
var request = new PasswordTokenRequest
protected virtual async Task<TokenResponse> RequestAuthServerLoginByPasswordAsync(string username, string password)
{
Address = _configuration["AuthServer:Authority"] + "/connect/token",
//GrantType = "password",
//UserName = username,
//Password = password,
//Scope = "Peis offline_access",
//ClientId = "Peis_App",
Parameters =
var client = _httpClientFactory.CreateClient();
var request = new PasswordTokenRequest
{
Address = _configuration["AuthServer:Authority"] + "/connect/token",
//GrantType = "password",
//UserName = username,
//Password = password,
//Scope = "Peis offline_access",
//ClientId = "Peis_App",
Parameters =
{
{"username",username},
{"password",password },
@ -677,12 +677,12 @@ namespace Shentun.Peis.MyUser
{"client_id","Peis_App" },
{"grant_type","password" }
}
};
};
//request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
//request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
return await client.RequestTokenAsync(request);
}
return await client.RequestTokenAsync(request);
}
}
}
}

4
src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs

@ -119,7 +119,7 @@ namespace Shentun.Peis.SampleTypes
var createEntity = ObjectMapper.Map<CreateSampleTypeDto, SampleType>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
await _sampleTypeCache.SetAsync(entity.Id, entity);
_sampleTypeCache.Set(entity.Id, entity);
var dto = ObjectMapper.Map<SampleType, SampleTypeDto>(entity);
return dto;
}
@ -135,7 +135,7 @@ namespace Shentun.Peis.SampleTypes
var sourceEntity = ObjectMapper.Map<UpdateSampleTypeDto, SampleType>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
await _sampleTypeCache.SetAsync(entity.Id, entity);
_sampleTypeCache.Set(entity.Id, entity);
return ObjectMapper.Map<SampleType, SampleTypeDto>(entity);
}
/// <summary>

8
src/Shentun.Peis.Application/Sexs/SexAppService.cs

@ -34,8 +34,8 @@ namespace Shentun.Peis.Sexs
private readonly IDistributedCache<Sex, char> _sexCache;
public SexAppService(
IRepository<Sex> repository,
SexManager manager,
IRepository<Sex> repository,
SexManager manager,
IDistributedCache<Sex, char> sexCache
)
{
@ -70,12 +70,12 @@ namespace Shentun.Peis.Sexs
var sourceEntity = ObjectMapper.Map<UpdateSexDto, Sex>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await _repository.UpdateAsync(entity);
await _sexCache.SetAsync(entity.Id, entity);
_sexCache.Set(entity.Id, entity);
return ObjectMapper.Map<Sex, SexDto>(entity);
}
/// <summary>
/// 修改排序 置顶,置底

Loading…
Cancel
Save