public async Task <IActionResult> UserAuthorityManage(string userName) { if (string.IsNullOrWhiteSpace(userName)) { return(JsonParamsErrorResult(nameof(userName))); } var user = DbContext.Users.SingleOrDefault(x => x.UserName == userName); if (user == null) { return(JsonBusinessErrorResult("用户不存在或已被删除")); } var role = (await DbContext.QueryListBySqlAsync <AspNetRole>($"SELECT a.* FROM AspNetRole a,AspNetUserRole b WHERE b.UserId={user.Id} LIMIT 0,1")).First(); var roleAuthId = role.AuthorityId; var operations = _authorityService.GetAuthoritiesByAuthorityId(user.AuthorityId); ViewData["allAuthorities"] = _authorityService.GetAllAuthorityModels(); ViewData["userRoleOperations"] = _authorityService.GetAuthoritiesByAuthorityId(roleAuthId); return(View(new KeyValuePair <AspNetUser, List <InterfaceOperation> >(user, operations))); }