通过userid查询用户信息新增查询用户所有角色

This commit is contained in:
不做码农 2022-01-06 12:36:18 +08:00
parent cf3f86b06a
commit a996ab1d22
4 changed files with 8 additions and 8 deletions

View File

@ -56,11 +56,10 @@ namespace ZR.Admin.WebApi.Controllers.System
long userId = HttpContext.GetUId(); long userId = HttpContext.GetUId();
var user = UserService.SelectUserById(userId); var user = UserService.SelectUserById(userId);
user.Roles = RoleService.SelectUserRoleListByUserId(userId);
var roles = RoleService.SelectUserRoleNames(userId); var roles = RoleService.SelectUserRoleNames(userId);
var postGroup = UserPostService.GetPostsStrByUserId(userId); var postGroup = UserPostService.GetPostsStrByUserId(userId);
var deptInfo = DeptService.GetFirst(f => f.DeptId == user.DeptId); 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); return SUCCESS(new { user, roles, postGroup }, TIME_FORMAT_FULL);
} }

View File

@ -5,16 +5,12 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection;
using ZR.Admin.WebApi.Filters; using ZR.Admin.WebApi.Filters;
using ZR.Common; using ZR.Common;
using ZR.Model; using ZR.Model;
using ZR.Model.System; using ZR.Model.System;
using ZR.Service;
using ZR.Service.System.IService; using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System namespace ZR.Admin.WebApi.Controllers.System

View File

@ -99,7 +99,7 @@ namespace ZR.Model.System
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
[EpplusIgnore] [EpplusIgnore]
public int[] RoleIds { get; set; } public long[] RoleIds { get; set; }
/// <summary> /// <summary>
/// 岗位集合 /// 岗位集合
/// </summary> /// </summary>

View File

@ -51,7 +51,12 @@ namespace ZR.Service
/// <returns></returns> /// <returns></returns>
public SysUser SelectUserById(long userId) 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> /// <summary>