| | |
| | | //å½åç¨æ·çæé |
| | | List<Permissions> permissions = _MenuService.GetPermissions(App.User.RoleId); |
| | | |
| | | List<int> menuIds = _MenuService.Repository.QueryData(x => x.MenuId, x => x.MenuType == 1); |
| | | |
| | | List<int> originalMeunIds = new List<int>(); |
| | | //被åé
è§è²çæé |
| | | List<Sys_RoleAuth> roleAuths = _RoleAuthService.Repository.QueryData(x => x.RoleId == roleId && menuIds.Contains(x.MenuId)); |
| | | List<Sys_RoleAuth> roleAuths = _RoleAuthService.Repository.QueryData(x => x.RoleId == roleId); |
| | | List<Sys_RoleAuth> updateAuths = new List<Sys_RoleAuth>(); |
| | | List<Sys_RoleAuth> addAuths = new List<Sys_RoleAuth>(); |
| | | foreach (UserPermissionDTO x in userPermissions) |
| | | { |
| | | Permissions per = permissions.FirstOrDefault(p => p.MenuId == x.Id); |
| | |
| | | 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) |
| | | if (auth == null) |
| | | { |
| | | addAuths.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 if (auth.AuthValue != newAuthValue) |
| | | { |
| | | updateAuths.Add(new Sys_RoleAuth() |
| | | { |
| | |
| | | //æ´æ°æé |
| | | _RoleAuthService.Repository.UpdateData(updateAuths); |
| | | //æ°å¢çæé |
| | | _RoleAuthService.Repository.AddData(updateAuths); |
| | | _RoleAuthService.Repository.AddData(addAuths); |
| | | |
| | | //è·åæéåæ¶çæé |
| | | int[] authIds = roleAuths.Where(x => userPermissions.Select(u => u.Id) |