/// <summary> /// 详情 -跳转到详情界面 /// </summary> /// <param name="id">用户ID</param> /// <returns></returns> // GET: UserBaseJsons/Details/5 public async Task <IActionResult> Details(string id) { Logger.Trace($"[{nameof(Details)}] 查看用户详情 用户ID: {id}"); // 0. 检查参数 if (id == null) { return(NotFound()); } try { // 1. 权限检查 if (!(await RoleOrgPerManager.HasPermissionForUser(SignUser.Id, Constants.USER_QUERY, id))) { Logger.Warn($"用户[{SignUser.SignName}]({SignUser.Id})没有权限({Constants.USER_QUERY})操作用户({id})"); ModelState.AddModelError("All", "没有权限"); return(RedirectToAction(nameof(Index))); } // 2. 业务处理 var user = await UserManager.FindById(id).SingleOrDefaultAsync(); Logger.Trace($"[{nameof(Details)}] 响应数据:\r\n{JsonUtil.ToJson(user)}"); if (user == null) { return(NotFound()); } else { // 再查询用户绑定的角色列表 ViewData[Constants.ROLES] = await RoleManager.FindByUserId(id); ViewData[Constants.USERROLES] = await UserRoleManager.FindByUserId(id).ToListAsync(); return(View(user)); } } catch (Exception e) { Logger.Error($"[{nameof(Details)}] 服务器错误:\r\n{e}"); return(RedirectToAction(nameof(Index))); } }