From a996ab1d2252f1a8e794075d3579123933a07b82 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Thu, 6 Jan 2022 12:36:18 +0800
Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87userid=E6=9F=A5=E8=AF=A2?=
=?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=96=B0=E5=A2=9E=E6=9F=A5?=
=?UTF-8?q?=E8=AF=A2=E7=94=A8=E6=88=B7=E6=89=80=E6=9C=89=E8=A7=92=E8=89=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.Admin.WebApi/Controllers/System/SysProfileController.cs | 3 +--
ZR.Admin.WebApi/Controllers/System/SysUserController.cs | 4 ----
ZR.Model/System/SysUser.cs | 2 +-
ZR.Service/System/SysUserService.cs | 7 ++++++-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs b/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs
index bb310ac..87d0576 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs
@@ -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);
}
diff --git a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
index f26d399..06384b1 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
@@ -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
diff --git a/ZR.Model/System/SysUser.cs b/ZR.Model/System/SysUser.cs
index 7a19ae6..3adb5d7 100644
--- a/ZR.Model/System/SysUser.cs
+++ b/ZR.Model/System/SysUser.cs
@@ -99,7 +99,7 @@ namespace ZR.Model.System
///
[SugarColumn(IsIgnore = true)]
[EpplusIgnore]
- public int[] RoleIds { get; set; }
+ public long[] RoleIds { get; set; }
///
/// 岗位集合
///
diff --git a/ZR.Service/System/SysUserService.cs b/ZR.Service/System/SysUserService.cs
index 1230763..e856c61 100644
--- a/ZR.Service/System/SysUserService.cs
+++ b/ZR.Service/System/SysUserService.cs
@@ -51,7 +51,12 @@ namespace ZR.Service
///
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;
}
///