diff --git a/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs b/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs index 624364d2..1c929df9 100644 --- a/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs +++ b/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs @@ -207,7 +207,7 @@ namespace Shentun.Peis.Asbitems var createEntity = ObjectMapper.Map(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(entity); return dto; } @@ -223,7 +223,7 @@ namespace Shentun.Peis.Asbitems var sourceEntity = ObjectMapper.Map(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(entity); } /// @@ -288,5 +288,19 @@ namespace Shentun.Peis.Asbitems return result; } + + + /// + /// 获取组合项目的缓存信息 + /// + /// + /// + [HttpPost("api/app/Asbitem/GetAsbitemCacheByAsbitemId")] + public async Task GetAsbitemCacheByAsbitemIdAsync(Guid AsbitemId) + { + //var asbitemEnt = await _cacheService.GetAsbitemAsync(AsbitemId); + var asbitemEnt = await _asbitemCache.GetAsync(AsbitemId); + return asbitemEnt; + } } } diff --git a/src/Shentun.Peis.Application/DeviceTypes/DeviceTypeAppService.cs b/src/Shentun.Peis.Application/DeviceTypes/DeviceTypeAppService.cs index 1f47f1b5..4b01f886 100644 --- a/src/Shentun.Peis.Application/DeviceTypes/DeviceTypeAppService.cs +++ b/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(entity); - await _deviceTypeCache.SetAsync(entity.Id, entity); + _deviceTypeCache.Set(entity.Id, entity); return dto; } /// @@ -136,7 +136,7 @@ namespace Shentun.Peis.DeviceTypes var sourceEntity = ObjectMapper.Map(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(entity); } /// @@ -150,7 +150,7 @@ namespace Shentun.Peis.DeviceTypes await _manager.CheckAndDeleteAsync(entity); } - + /// /// 修改排序 置顶,置底 diff --git a/src/Shentun.Peis.Application/ForSexs/ForSexAppService.cs b/src/Shentun.Peis.Application/ForSexs/ForSexAppService.cs index 97236671..69583f8f 100644 --- a/src/Shentun.Peis.Application/ForSexs/ForSexAppService.cs +++ b/src/Shentun.Peis.Application/ForSexs/ForSexAppService.cs @@ -48,7 +48,7 @@ namespace Shentun.Peis.ForSexs var sourceEntity = ObjectMapper.Map(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(entity); } diff --git a/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs b/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs index 2e97346f..b834c96b 100644 --- a/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs +++ b/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs @@ -78,7 +78,7 @@ namespace Shentun.Peis.ItemTypes var createEntity = ObjectMapper.Map(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(entity); return dto; @@ -95,7 +95,7 @@ namespace Shentun.Peis.ItemTypes var sourceEntity = ObjectMapper.Map(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(entity); } /// diff --git a/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs b/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs index 31e9fac6..c102b52f 100644 --- a/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs +++ b/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 } - /// - /// 获取列表 根据用户类别 - /// - /// - /// - [Authorize(PeisPermissions.Users.Default)] - [HttpPost("api/identity/users/GetListByOperatorType")] - public async Task> GetListByOperatorTypeAsync(OperatorTypeIuputDto input) - { - var entlist = await _identityUserRepository.GetListAsync(m => m.IsDeleted == false); - var entlistDto = entlist.Where(m => input.OperatorTypes.Contains(m.GetProperty("operator_type"))).Select(s => new ListByOperatorTypeDto + /// + /// 获取列表 根据用户类别 + /// + /// + /// + [Authorize(PeisPermissions.Users.Default)] + [HttpPost("api/identity/users/GetListByOperatorType")] + public async Task> 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("operator_type"))).Select(s => new ListByOperatorTypeDto + { + Id = s.Id, + SimpleCode = LanguageConverter.GetPYSimpleCode(s.Surname), + Surname = s.Surname, + UserName = s.UserName + }).ToList(); - /// - /// 修改用户信息 - /// - /// - /// - /// - //[Authorize(PeisPermissions.Users.Edit)] - //[HttpPost("api/identity/users/update")] - [RemoteService(false)] - public override async Task 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; + /// + /// 修改用户信息 + /// + /// + /// + /// + //[Authorize(PeisPermissions.Users.Edit)] + //[HttpPost("api/identity/users/update")] + [RemoteService(false)] + public override async Task UpdateAsync(Guid id, IdentityUserUpdateDto input) + { + var entityDto = await base.UpdateAsync(id, input); - } + var entity = await _identityUserRepository.GetAsync(id); + _userCache.Set(id, entity); + return entityDto; - /// - /// 修改 - /// - /// - /// - /// - [Authorize(PeisPermissions.Users.Edit)] - [HttpPost("api/identity/users/update")] - public async Task UpdateIdentityUserAsync(Guid id, IdentityUserUpdateInputDto input) - { + } - #region 上传图片 - string userPhoto = UploadUserPhotoAsync(new UploadUserPhotoInputDto - { - PictureBaseStr = input.UserPhoto, - UserId = id - }); - string userSign = UploadUserSignAsync(new UploadUserPhotoInputDto + /// + /// 修改 + /// + /// + /// + /// + [Authorize(PeisPermissions.Users.Edit)] + [HttpPost("api/identity/users/update")] + public async Task 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(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(); - /// - /// 获取用户信息 根据ID - /// - /// - /// - //[Authorize(PeisPermissions.Users.Default)] - //[HttpGet("api/identity/users/getinfo")] - [RemoteService(false)] - public override Task GetAsync(Guid id) - { - return base.GetAsync(id); - } + var entityDto = ObjectMapper.Map(user); - /// - ///上传用户照片 图片base64 - /// - /// - /// - /// - 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 + + /// + /// 获取用户信息 根据ID + /// + /// + /// + //[Authorize(PeisPermissions.Users.Default)] + //[HttpGet("api/identity/users/getinfo")] + [RemoteService(false)] + public override Task 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 ""; - } - - - /// - /// 上传用户签名 图片base64 - /// - /// - /// - /// - private string UploadUserSignAsync(UploadUserPhotoInputDto input) - { - string fileName = ""; - if (input.UserId != null) - { - fileName = input.UserId.ToString(); - } - else + /// + ///上传用户照片 图片base64 + /// + /// + /// + /// + 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 ""; - } - /// - /// 获取用户信息 根据ID - /// - /// - /// - [Authorize(PeisPermissions.Users.Default)] - [HttpGet("api/identity/users/getinfo")] - public async Task GetWithExtensionAsync(Guid id) - { - var ent = await UserManager.GetByIdAsync(id); - var userSign = !string.IsNullOrWhiteSpace(ent.GetProperty("user_sign")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty("user_sign")) : ""; - var userPhoto = !string.IsNullOrWhiteSpace(ent.GetProperty("user_photo")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty("user_photo")) : ""; - var operatorType = ent.GetProperty("operator_type"); - var entDto = ObjectMapper.Map(ent); - entDto.UserPhoto = userPhoto; - entDto.UserSign = userSign; - entDto.OperatorType = operatorType; - return entDto; - } + /// + /// 上传用户签名 图片base64 + /// + /// + /// + /// + private string UploadUserSignAsync(UploadUserPhotoInputDto input) + { + string fileName = ""; + if (input.UserId != null) + { + fileName = input.UserId.ToString(); + } + else + { + fileName = Guid.NewGuid().ToString(); + } - /// - /// 给用户绑定角色 - /// - /// 用户ID - /// 角色集合 - /// - [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 ""; + } - /// - /// 获取用户的角色信息 根据用户ID - /// - /// 用户ID - /// - [Authorize(PeisPermissions.Users.Default)] - [HttpGet("api/identity/users/getroles")] - public override Task> GetRolesAsync(Guid id) - { - return base.GetRolesAsync(id); - } + /// + /// 获取用户信息 根据ID + /// + /// + /// + [Authorize(PeisPermissions.Users.Default)] + [HttpGet("api/identity/users/getinfo")] + public async Task GetWithExtensionAsync(Guid id) + { + var ent = await UserManager.GetByIdAsync(id); + var userSign = !string.IsNullOrWhiteSpace(ent.GetProperty("user_sign")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty("user_sign")) : ""; + var userPhoto = !string.IsNullOrWhiteSpace(ent.GetProperty("user_photo")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty("user_photo")) : ""; + var operatorType = ent.GetProperty("operator_type"); + var entDto = ObjectMapper.Map(ent); + entDto.UserPhoto = userPhoto; + entDto.UserSign = userSign; + entDto.OperatorType = operatorType; + return entDto; + } + /// + /// 给用户绑定角色 + /// + /// 用户ID + /// 角色集合 + /// + [Authorize(PeisPermissions.Users.Edit)] + [HttpPost("api/identity/users/updateroles")] + public override Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input) + { + return base.UpdateRolesAsync(id, input); + } - /// - /// 获取当前登录用户的角色信息 - /// - /// - [Authorize(PeisPermissions.Users.Default)] - [HttpGet("api/identity/users/getassignableroles")] - public override Task> GetAssignableRolesAsync() - { - return base.GetAssignableRolesAsync(); - } + /// + /// 获取用户的角色信息 根据用户ID + /// + /// 用户ID + /// + [Authorize(PeisPermissions.Users.Default)] + [HttpGet("api/identity/users/getroles")] + public override Task> GetRolesAsync(Guid id) + { + return base.GetRolesAsync(id); + } - /// - /// 暂未用到 - /// - /// - /// - [Authorize(PeisPermissions.Users.Default)] - [RemoteService(false)] - public override Task FindByUsernameAsync(string userName) - { - return base.FindByUsernameAsync(userName); - } - /// - /// 暂未用到 - /// - /// - /// - [Authorize(PeisPermissions.Users.Default)] - [RemoteService(false)] - public override Task FindByEmailAsync(string email) - { - return base.FindByEmailAsync(email); - } + /// + /// 获取当前登录用户的角色信息 + /// + /// + [Authorize(PeisPermissions.Users.Default)] + [HttpGet("api/identity/users/getassignableroles")] + public override Task> GetAssignableRolesAsync() + { + return base.GetAssignableRolesAsync(); + } - /// - /// 用户登录 - /// - /// - /// - [HttpPost("api/identity/users/login")] - public async Task UserLogin(UserLoginRequestDto input) - { - UserLoginDto msg; + /// + /// 暂未用到 + /// + /// + /// + [Authorize(PeisPermissions.Users.Default)] + [RemoteService(false)] + public override Task FindByUsernameAsync(string userName) + { + return base.FindByUsernameAsync(userName); + } + /// + /// 暂未用到 + /// + /// + /// + [Authorize(PeisPermissions.Users.Default)] + [RemoteService(false)] + public override Task FindByEmailAsync(string email) + { + return base.FindByEmailAsync(email); + } - var user = await _userManager.FindByNameAsync(input.UserName); - if (user != null) + /// + /// 用户登录 + /// + /// + /// + [HttpPost("api/identity/users/login")] + public async Task 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("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("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 RequestAuthServerLoginByPasswordAsync(string username, string password) - { - var client = _httpClientFactory.CreateClient(); - var request = new PasswordTokenRequest + protected virtual async Task 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); + } -} + } } diff --git a/src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs b/src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs index 7d0765bd..16df6984 100644 --- a/src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs +++ b/src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs @@ -119,7 +119,7 @@ namespace Shentun.Peis.SampleTypes var createEntity = ObjectMapper.Map(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(entity); return dto; } @@ -135,7 +135,7 @@ namespace Shentun.Peis.SampleTypes var sourceEntity = ObjectMapper.Map(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(entity); } /// diff --git a/src/Shentun.Peis.Application/Sexs/SexAppService.cs b/src/Shentun.Peis.Application/Sexs/SexAppService.cs index cd4f634b..c056efeb 100644 --- a/src/Shentun.Peis.Application/Sexs/SexAppService.cs +++ b/src/Shentun.Peis.Application/Sexs/SexAppService.cs @@ -34,8 +34,8 @@ namespace Shentun.Peis.Sexs private readonly IDistributedCache _sexCache; public SexAppService( - IRepository repository, - SexManager manager, + IRepository repository, + SexManager manager, IDistributedCache sexCache ) { @@ -70,12 +70,12 @@ namespace Shentun.Peis.Sexs var sourceEntity = ObjectMapper.Map(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(entity); } - + /// /// 修改排序 置顶,置底