/// <summary> /// 获取我的权限数据 /// </summary> /// <returns></returns> public List <Entities.Category> getMyCategories() { //var user = getCurrentUser(); // return getMyCategories(user); //return _categoryService.getAll(); var list = _categoryService.getAll(); var user = getCurrentUser(); if (user == null) { return(null); } if (user.IsAdmin) { return(list); } //获取权限数据 var userRoles = _sysUserRoleService.getAll(); if (userRoles == null) { return(null); } if (userRoles == null || !userRoles.Any()) { return(null); } var roleIds = userRoles.Where(o => o.UserId == user.Id).Select(x => x.RoleId).Distinct().ToList(); var permissionList = _sysPermissionServices.getAll(); if (permissionList == null || !permissionList.Any()) { return(null); } var categoryIds = permissionList.Where(o => roleIds.Contains(o.RoleId)).Select(x => x.CategoryId).Distinct().ToList(); if (!categoryIds.Any()) { return(null); } list = list.Where(o => categoryIds.Contains(o.Id)).ToList(); return(list); }
public ActionResult RoleDetail(Guid id) { UserRoleViewModel model = new UserRoleViewModel(); model.RoleList = _sysRoleService.getAllRoles(); ViewBag.Userid = id; var roleList = _sysUserRoleService.getAll(); if (roleList != null && roleList.Any()) { model.User = _sysUserService.getById(id);; model.UserRoleList = roleList; //model.Permissions = _sysPermissionService.getByRoleId(id); } return(View(model)); }