From 8f1bf1cd625b0f066d26396854e83fbf235a936e Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期四, 16 一月 2025 14:41:25 +0800 Subject: [PATCH] 1 --- /dev/null | 0 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockViewService.cs | 2 代码管理/WMS/WIDESEA_WMSClient/src/views/system/PermissionPDA.vue | 2 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_RoleController.cs | 6 +++ 代码管理/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/471d11b3-4b7d-4bf3-869c-9513dd71c560.vsidx | 0 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_ISystemService/ISys_RoleService.cs | 2 + 7 files changed, 106 insertions(+), 3 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/views/system/PermissionPDA.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/views/system/PermissionPDA.vue" index 92d5227..41d1f88 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/views/system/PermissionPDA.vue" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/views/system/PermissionPDA.vue" @@ -248,7 +248,7 @@ }); } }); - let url = `api/Sys_Role/SavePermission?roleId=${selectId.value}`; + let url = `api/Sys_Role/SavePermissionPDA?roleId=${selectId.value}`; http.post(url, userPermissions, true).then((result) => { $message[result.status ? "success" : "error"](result.message); }); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/44fbbe1e-6bf2-4799-85ed-f204f13fc099.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/44fbbe1e-6bf2-4799-85ed-f204f13fc099.vsidx" deleted file mode 100644 index 3942689..0000000 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/44fbbe1e-6bf2-4799-85ed-f204f13fc099.vsidx" +++ /dev/null Binary files differ diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/471d11b3-4b7d-4bf3-869c-9513dd71c560.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/471d11b3-4b7d-4bf3-869c-9513dd71c560.vsidx" new file mode 100644 index 0000000..9c481f9 --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/471d11b3-4b7d-4bf3-869c-9513dd71c560.vsidx" Binary files differ diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/c55dc563-0ab2-4a62-9fbf-42cb95118eea.vsidx" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/c55dc563-0ab2-4a62-9fbf-42cb95118eea.vsidx" deleted file mode 100644 index 033cd0f..0000000 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/c55dc563-0ab2-4a62-9fbf-42cb95118eea.vsidx" +++ /dev/null Binary files differ diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/read.lock" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/read.lock" deleted file mode 100644 index e69de29..0000000 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/read.lock" +++ /dev/null diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_ISystemService/ISys_RoleService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_ISystemService/ISys_RoleService.cs" index f99e354..2c2536a 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_ISystemService/ISys_RoleService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_ISystemService/ISys_RoleService.cs" @@ -29,5 +29,7 @@ WebResponseContent GetUserTreePermissionPDA(int RoleId); WebResponseContent SavePermission(List<UserPermissionDTO> userPermissions, int roleId); + + WebResponseContent SavePermissionPDA(List<UserPermissionDTO> userPermissions, int roleId); } } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockViewService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockViewService.cs" index d43d985..8a732e7 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockViewService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockViewService.cs" @@ -80,7 +80,7 @@ sugarQueryable1 = sugarQueryable1.Where(whereSto); EntityProperties.ValidatePageOptions(options, ref sugarQueryable1); - string whereLo = GetDataRole(typeof(Dt_StockInfo)); + string whereLo = GetDataRole(typeof(Dt_LocationInfo)); ISugarQueryable<Dt_LocationInfo> sugarQueryable = _dbBase.Queryable<Dt_LocationInfo>().Where(whereLo); EntityProperties.ValidatePageOptions(options, ref sugarQueryable); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" index 0136a31..3a58e39 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_RoleService.cs" @@ -278,9 +278,104 @@ //褰撳墠鐢ㄦ埛鐨勬潈闄� List<Permissions> permissions = _MenuRepository.GetPermissions(App.User.RoleId); + List<int> menuIds = _MenuRepository.QueryData(x => x.MenuId, x => x.MenuType == 1); + List<int> originalMeunIds = new List<int>(); //琚垎閰嶈鑹茬殑鏉冮檺 - List<Sys_RoleAuth> roleAuths = _RoleAuthRepository.QueryData(x => x.RoleId == roleId); + List<Sys_RoleAuth> roleAuths = _RoleAuthRepository.QueryData(x => x.RoleId == roleId && menuIds.Contains(x.MenuId)); + List<Sys_RoleAuth> updateAuths = new List<Sys_RoleAuth>(); + foreach (UserPermissionDTO x in userPermissions) + { + Permissions per = permissions.FirstOrDefault(p => p.MenuId == x.Id); + //涓嶈兘鍒嗛厤瓒呰繃褰撳墠鐢ㄦ埛鐨勬潈闄� + if (per == null) continue; + //per.UserAuthArr.Contains(a.Value)鏍¢獙鏉冮檺鑼冨洿 + string[] arr = x.Actions == null || x.Actions.Count == 0 + ? new string[0] + : x.Actions.Where(a => per.UserAuthArr.Contains(a.Value)) + .Select(s => s.Value).ToArray(); + + //濡傛灉褰撳墠鏉冮檺娌℃湁鍒嗛厤杩囷紝璁剧疆Auth_Id榛樿涓�0锛岃〃绀烘柊澧炵殑鏉冮檺 + var auth = roleAuths.Where(r => r.MenuId == x.Id).Select(s => new { s.AuthId, s.AuthValue, s.MenuId }).FirstOrDefault(); + string newAuthValue = string.Join(",", arr); + //鏉冮檺娌℃湁鍙戠敓鍙樺寲鍒欎笉澶勭悊 + if (auth == null || auth.AuthValue != newAuthValue) + { + updateAuths.Add(new Sys_RoleAuth() + { + RoleId = roleId, + MenuId = x.Id, + AuthValue = string.Join(",", arr), + AuthId = auth == null ? 0 : auth.AuthId, + ModifyDate = DateTime.Now, + Modifier = App.User.UserName, + CreateDate = DateTime.Now, + Creater = App.User.UserName + }); + } + else + { + originalMeunIds.Add(auth.MenuId); + } + + } + //鏇存柊鏉冮檺 + _RoleAuthRepository.UpdateData(updateAuths); + //鏂板鐨勬潈闄� + _RoleAuthRepository.AddData(updateAuths); + + //鑾峰彇鏉冮檺鍙栨秷鐨勬潈闄� + int[] authIds = roleAuths.Where(x => userPermissions.Select(u => u.Id) + .ToList().Contains(x.MenuId) || originalMeunIds.Contains(x.MenuId)) + .Select(s => s.AuthId) + .ToArray(); + List<Sys_RoleAuth> delAuths = roleAuths.Where(x => x.AuthValue != "" && !authIds.Contains(x.AuthId)).ToList(); + delAuths.ForEach(x => + { + x.AuthValue = ""; + }); + //灏嗗彇娑堢殑鏉冮檺璁剧疆涓�"" + _RoleAuthRepository.DeleteData(delAuths); + + int addCount = updateAuths.Where(x => x.AuthId <= 0).Count(); + int updateCount = updateAuths.Where(x => x.AuthId > 0).Count(); + + string _version = DateTime.Now.ToString("yyyyMMddHHMMssfff"); + + + content.OK($"淇濆瓨鎴愬姛锛氭柊澧炲姞閰嶈彍鍗曟潈闄恵addCount}鏉�,鏇存柊鑿滃崟{updateCount}鏉�,鍒犻櫎鏉冮檺{delAuths.Count}鏉�"); + } + catch (Exception ex) + { + message = "寮傚父淇℃伅锛�" + ex.Message + ex.StackTrace + ","; + } + + return content; + } + + /// <summary> + /// 淇濆瓨瑙掕壊鏉冮檺 + /// </summary> + /// <param name="userPermissions"></param> + /// <param name="roleId"></param> + /// <returns></returns> + public WebResponseContent SavePermissionPDA(List<UserPermissionDTO> userPermissions, int roleId) + { + WebResponseContent content = new WebResponseContent(); + string message = ""; + try + { + if (!GetAllChildren(App.User.RoleId).Exists(x => x.Id == roleId)) + return WebResponseContent.Instance.Error("娌℃湁鏉冮檺淇敼姝よ鑹茬殑鏉冮檺淇℃伅"); + //褰撳墠鐢ㄦ埛鐨勬潈闄� + List<Permissions> permissions = _MenuRepository.GetPermissions(App.User.RoleId); + + List<int> originalMeunIds = new List<int>(); + + List<int> menuIds = _MenuRepository.QueryData(x => x.MenuId, x => x.MenuType == 1); + + //琚垎閰嶈鑹茬殑鏉冮檺 + List<Sys_RoleAuth> roleAuths = _RoleAuthRepository.QueryData(x => x.RoleId == roleId && menuIds.Contains(x.MenuId)); List<Sys_RoleAuth> updateAuths = new List<Sys_RoleAuth>(); foreach (UserPermissionDTO x in userPermissions) { diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_RoleController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_RoleController.cs" index 0318a13..22fc324 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_RoleController.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_RoleController.cs" @@ -74,5 +74,11 @@ { return Json(Service.SavePermission(userPermissions, roleId)); } + + [HttpPost, Route("SavePermissionPDA")] + public IActionResult SavePermissionPDA([FromBody] List<UserPermissionDTO> userPermissions, int roleId) + { + return Json(Service.SavePermissionPDA(userPermissions, roleId)); + } } } -- Gitblit v1.9.3