public async Task <IHttpActionResult> UserAdds([FromBody] params UserLoginInputDto[] UserSet) => Json(await UserLoginService.TryCatchActionAsync( action: async m => { UserSet.CheckNotNullOrEmpty("UserSet"); var cacheUser = GetCacheUser; if (!cacheUser.IsAdministrator) { foreach (var i in UserSet) { if (!ListOrganizeId.Contains(i.Organize_Id) && i.Organize_Id != cacheUser.Organize_Id) { throw new Exception($"id:添加用户的组织机构归属不在权限范围内"); } foreach (var a in i.PermissionList.Split(',')) { if (!IntPermissionList.Contains(a)) { throw new Exception($"id:添加的用户的操作权限归属不在权限范围内"); } } } } // 不管信息是否添加成功?都执行删除当前对象页的缓存 ICache cache = CacheManager.GetCacher <UserPageView>(); cache.Clear(); // -------------------------------------------- return(await UserLoginService.AddUserLogin(GetCacheUser, UserSet)); }));
public async Task <IHttpActionResult> EditData([FromBody] params UserPageOutDto[] user) => Json(await UserLoginService.TryCatchActionAsync( action: async m => { Logger.Debug(user.ToJsonString()); user.CheckNotNullOrEmpty("user"); UserPageIn[] InputUser = new UserPageIn[user.Length]; await Task.Run(() => { var cacheUser = GetCacheUser; ICache iCache = CacheManager.GetCacher("CacheUserPageId"); var cacheIds = iCache.Get(cacheUser.UserName.AESEncrypt128()) as IEnumerable <Guid>; for (int n = 0; n < user.Length; n++) { var i = user[n]; if (!cacheUser.IsAdministrator) { if (cacheIds == null) { throw new Exception("id:请先获取数据再进行操作!"); } if (!cacheIds.Contains(i.Id)) { throw new Exception($"id:值主键{i.Id}不在范围内,请尝试重新获取数据后在操作..."); } if (!ListOrganizeId.Contains(i.Organize_Id)) { throw new Exception($"id:用户主键{i.Id}的组织机构归属不在权限范围内"); } if (i.Level <= cacheUser.Level) { throw new Exception($"id:用户主键{i.Id}的权限等级归属不在权限范围内"); } foreach (var a in i.PermissionList.Split(',')) { if (!IntPermissionList.Contains(a)) { throw new Exception($"id:用户主键{i.Id}的操作权限归属不在权限范围内"); } } } UserPageIn userPageIn = i.MapTo <UserPageIn>(); userPageIn.LastUpdatorUserId = cacheUser.UserName; InputUser[n] = userPageIn; } }); //不管用户是否更新成功,都执行删除当前对象页的缓存 ICache cache = CacheManager.GetCacher <UserPageView>(); cache.Clear(); //---------------------------------------------- return(await m.EditUserData(InputUser)); }));