通过userid查询用户信息新增查询用户所有角色
This commit is contained in:
parent
cf3f86b06a
commit
a996ab1d22
@ -56,11 +56,10 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
long userId = HttpContext.GetUId();
|
||||
var user = UserService.SelectUserById(userId);
|
||||
|
||||
user.Roles = RoleService.SelectUserRoleListByUserId(userId);
|
||||
var roles = RoleService.SelectUserRoleNames(userId);
|
||||
var postGroup = UserPostService.GetPostsStrByUserId(userId);
|
||||
var deptInfo = DeptService.GetFirst(f => f.DeptId == user.DeptId);
|
||||
user.DeptName = deptInfo?.DeptName;
|
||||
user.DeptName = deptInfo?.DeptName ?? "-";
|
||||
|
||||
return SUCCESS(new { user, roles, postGroup }, TIME_FORMAT_FULL);
|
||||
}
|
||||
|
||||
@ -5,16 +5,12 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.System
|
||||
|
||||
@ -99,7 +99,7 @@ namespace ZR.Model.System
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[EpplusIgnore]
|
||||
public int[] RoleIds { get; set; }
|
||||
public long[] RoleIds { get; set; }
|
||||
/// <summary>
|
||||
/// 岗位集合
|
||||
/// </summary>
|
||||
|
||||
@ -51,7 +51,12 @@ namespace ZR.Service
|
||||
/// <returns></returns>
|
||||
public SysUser SelectUserById(long userId)
|
||||
{
|
||||
return UserRepository.SelectUserById(userId);
|
||||
var user = UserRepository.SelectUserById(userId);
|
||||
if (user != null && user.UserId > 0)
|
||||
{
|
||||
user.Roles = RoleService.SelectUserRoleListByUserId(userId);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user