diff --git a/Api/Ewide.Core/Enum/ErrorCode.cs b/Api/Ewide.Core/Enum/ErrorCode.cs
index b1d2fbe..d2d5f1e 100644
--- a/Api/Ewide.Core/Enum/ErrorCode.cs
+++ b/Api/Ewide.Core/Enum/ErrorCode.cs
@@ -137,7 +137,7 @@ namespace Ewide.Core
///
/// 已有相同组织机构,编码或名称相同
///
- [ErrorCodeItemMetadata("已有相同编码组织机构")]
+ [ErrorCodeItemMetadata("已有相同组织机构,编码或名称相同")]
D2002,
///
diff --git a/Api/Ewide.Core/Enum/OrgType.cs b/Api/Ewide.Core/Enum/OrgType.cs
index 8955c0a..f499fa8 100644
--- a/Api/Ewide.Core/Enum/OrgType.cs
+++ b/Api/Ewide.Core/Enum/OrgType.cs
@@ -10,10 +10,10 @@ namespace Ewide.Core
{
市住建部门 = 1,
- 区住建部门 = 11,
+ 区住建部门 = 2,
- 乡镇街道办事处 = 21,
+ 乡镇街道办事处 = 3,
- 片区 = 31
+ 片区 = 4
}
}
diff --git a/Api/Ewide.Core/Manager/IUserManager.cs b/Api/Ewide.Core/Manager/IUserManager.cs
index 44dd830..a9c9f42 100644
--- a/Api/Ewide.Core/Manager/IUserManager.cs
+++ b/Api/Ewide.Core/Manager/IUserManager.cs
@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading.Tasks;
namespace Ewide.Core
{
@@ -10,7 +11,15 @@ namespace Ewide.Core
SysUser User { get; }
string UserId { get; }
- Task CheckUserAsync(string userId, bool tracking = true);
+ Task CheckUserAsync(string userId);
+ Task CheckUserAsync();
Task GetUserEmpInfo(string userId);
+ Task GetUserEmpInfo();
+ Task GetUserOrgInfo(string userId);
+ Task GetUserOrgInfo();
+ Task> GetUserRoleIdList(string userId);
+ Task> GetUserRoleIdList();
+ Task> GetUserRoleList(string userId);
+ Task> GetUserRoleList();
}
}
\ No newline at end of file
diff --git a/Api/Ewide.Core/Manager/UserManager.cs b/Api/Ewide.Core/Manager/UserManager.cs
index 27ae40c..6512364 100644
--- a/Api/Ewide.Core/Manager/UserManager.cs
+++ b/Api/Ewide.Core/Manager/UserManager.cs
@@ -2,7 +2,10 @@
using Furion.DependencyInjection;
using Furion.FriendlyException;
using Microsoft.AspNetCore.Http;
+using System.Linq;
using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore;
+using System.Collections.Generic;
namespace Ewide.Core
{
@@ -12,7 +15,10 @@ namespace Ewide.Core
public class UserManager : IUserManager, IScoped
{
private readonly IRepository _sysUserRep; // 用户表仓储
+ private readonly IRepository _sysRoleRep;
+ private readonly IRepository _sysUserRoleRep;
private readonly IRepository _sysEmpRep; // 员工表
+ private readonly IRepository _sysOrgRep;
private readonly IHttpContextAccessor _httpContextAccessor;
public string UserId
@@ -40,12 +46,19 @@ namespace Ewide.Core
get => _sysUserRep.Find(UserId);
}
- public UserManager(IRepository sysUserRep,
- IRepository sysEmpRep,
- IHttpContextAccessor httpContextAccessor)
+ public UserManager(
+ IRepository sysUserRep,
+ IRepository sysRoleRep,
+ IRepository sysUserRoleRep,
+ IRepository sysEmpRep,
+ IRepository sysOrgRep,
+ IHttpContextAccessor httpContextAccessor)
{
_sysUserRep = sysUserRep;
+ _sysRoleRep = sysRoleRep;
+ _sysUserRoleRep = sysUserRoleRep;
_sysEmpRep = sysEmpRep;
+ _sysOrgRep = sysOrgRep;
_httpContextAccessor = httpContextAccessor;
}
@@ -53,14 +66,22 @@ namespace Ewide.Core
/// 获取用户信息
///
///
- ///
///
- public async Task CheckUserAsync(string userId, bool tracking = true)
+ public async Task CheckUserAsync(string userId)
{
- var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == userId, tracking);
+ var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == userId, false);
return user ?? throw Oops.Oh(ErrorCode.D1002);
}
+ ///
+ /// 获取用户信息
+ ///
+ ///
+ public async Task CheckUserAsync()
+ {
+ return await CheckUserAsync(UserId);
+ }
+
///
/// 获取用户员工信息
///
@@ -71,5 +92,76 @@ namespace Ewide.Core
var emp = await _sysEmpRep.FirstOrDefaultAsync(u => u.Id == userId, false);
return emp ?? throw Oops.Oh(ErrorCode.D1002);
}
+
+ ///
+ /// 获取用户员工信息
+ ///
+ ///
+ public async Task GetUserEmpInfo()
+ {
+ return await GetUserEmpInfo(UserId);
+ }
+
+ ///
+ /// 获取用户部门信息
+ ///
+ ///
+ ///
+ public async Task GetUserOrgInfo(string userId)
+ {
+ var emp = await GetUserEmpInfo(userId);
+ var org = await _sysOrgRep.FirstOrDefaultAsync(u => u.Id == emp.OrgId, false);
+ return org ?? throw Oops.Oh(ErrorCode.D1002);
+ }
+
+ ///
+ /// 获取用户部门信息
+ ///
+ ///
+ public async Task GetUserOrgInfo()
+ {
+ return await GetUserOrgInfo(UserId);
+ }
+
+ ///
+ /// 获取用户角色Id列表
+ ///
+ ///
+ ///
+ public async Task> GetUserRoleIdList(string userId)
+ {
+ var roleIds = await _sysUserRoleRep.DetachedEntities.Where(u => u.SysUserId == userId).Select(u => u.SysRoleId).ToListAsync();
+ return roleIds;
+ }
+
+ ///
+ /// 获取用户角色Id列表
+ ///
+ ///
+ public async Task> GetUserRoleIdList()
+ {
+ return await GetUserRoleIdList(UserId);
+ }
+
+ ///
+ /// 获取用户角色列表
+ ///
+ ///
+ ///
+ public async Task> GetUserRoleList(string userId)
+ {
+ var roleIds = await GetUserRoleIdList(userId);
+ var roles = await _sysRoleRep.DetachedEntities.Where(u => roleIds.Contains(u.Id)).ToListAsync();
+ return roles;
+ }
+
+ ///
+ /// 获取用户角色列表
+ ///
+ ///
+ public async Task> GetUserRoleList()
+ {
+ return await GetUserRoleList(UserId);
+ }
}
}
\ No newline at end of file