😎优化当前用户状态处理
This commit is contained in:
parent
93bd06cfa5
commit
c8a42cdf46
@ -9,6 +9,7 @@ using Furion.DataValidation;
|
|||||||
using Lazy.Captcha.Core;
|
using Lazy.Captcha.Core;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Yitter.IdGenerator;
|
using Yitter.IdGenerator;
|
||||||
|
using static SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.QueryMarketingMemberCardOpenCardsResponse.Types.Card.Types;
|
||||||
|
|
||||||
namespace Admin.NET.Application.Service.App;
|
namespace Admin.NET.Application.Service.App;
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ public class AppAuthService : IDynamicApiController, ITransient
|
|||||||
private readonly SqlSugarRepository<SysUser> _sysUserRep;
|
private readonly SqlSugarRepository<SysUser> _sysUserRep;
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
private readonly SysRoleService _sysRoleService;
|
private readonly SysRoleService _sysRoleService;
|
||||||
|
private readonly SysUserRoleService _sysUserRoleService;
|
||||||
private readonly SysOnlineUserService _sysOnlineUserService;
|
private readonly SysOnlineUserService _sysOnlineUserService;
|
||||||
private readonly SysConfigService _sysConfigService;
|
private readonly SysConfigService _sysConfigService;
|
||||||
private readonly ICaptcha _captcha;
|
private readonly ICaptcha _captcha;
|
||||||
@ -31,6 +33,7 @@ public class AppAuthService : IDynamicApiController, ITransient
|
|||||||
SqlSugarRepository<SysUser> sysUserRep,
|
SqlSugarRepository<SysUser> sysUserRep,
|
||||||
IHttpContextAccessor httpContextAccessor,
|
IHttpContextAccessor httpContextAccessor,
|
||||||
SysRoleService sysRoleService,
|
SysRoleService sysRoleService,
|
||||||
|
SysUserRoleService sysUserRoleService,
|
||||||
SysOnlineUserService sysOnlineUserService,
|
SysOnlineUserService sysOnlineUserService,
|
||||||
SysConfigService sysConfigService,
|
SysConfigService sysConfigService,
|
||||||
ICaptcha captcha,
|
ICaptcha captcha,
|
||||||
@ -40,6 +43,7 @@ public class AppAuthService : IDynamicApiController, ITransient
|
|||||||
_sysUserRep = sysUserRep;
|
_sysUserRep = sysUserRep;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
_sysRoleService = sysRoleService;
|
_sysRoleService = sysRoleService;
|
||||||
|
_sysUserRoleService = sysUserRoleService;
|
||||||
_sysOnlineUserService = sysOnlineUserService;
|
_sysOnlineUserService = sysOnlineUserService;
|
||||||
_sysConfigService = sysConfigService;
|
_sysConfigService = sysConfigService;
|
||||||
_captcha = captcha;
|
_captcha = captcha;
|
||||||
@ -206,19 +210,11 @@ public class AppAuthService : IDynamicApiController, ITransient
|
|||||||
[DisplayName("获取登录账号")]
|
[DisplayName("获取登录账号")]
|
||||||
public virtual async Task<LoginUserOutput> GetUserInfo()
|
public virtual async Task<LoginUserOutput> GetUserInfo()
|
||||||
{
|
{
|
||||||
var user = await _sysUserRep.GetByIdAsync(_appUserManager.UserId) ?? throw Oops.Oh(ErrorCodeEnum.D1011).StatusCode(401);
|
var user = await _sysUserRep.AsQueryable().Includes(u => u.SysOrg).Includes(u => u.SysPos).FirstAsync(u => u.Id == _appUserManager.UserId) ?? throw Oops.Oh(ErrorCodeEnum.D1011).StatusCode(401);
|
||||||
// 机构
|
|
||||||
var org = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysOrg>>().GetByIdAsync(user.OrgId);
|
|
||||||
// 职位
|
|
||||||
var pos = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysPos>>().GetByIdAsync(user.PosId);
|
|
||||||
// 角色集合
|
// 角色集合
|
||||||
var roles = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysUserRole>>().AsQueryable()
|
var roles = await _sysUserRoleService.GetUserRoleInfoList(user.Id);
|
||||||
.LeftJoin<SysRole>((u, a) => u.RoleId == a.Id)
|
|
||||||
.Where(u => u.UserId == user.Id)
|
|
||||||
.Select((u, a) => new RoleDto { Id = a.Id, Name = a.Name, Code = a.Code }).ToListAsync();
|
|
||||||
// 接口集合
|
// 接口集合
|
||||||
var apis = (await _sysRoleService.GetUserApiList())[0];
|
var apis = (await _sysRoleService.GetUserApiList())[0];
|
||||||
|
|
||||||
return new LoginUserOutput
|
return new LoginUserOutput
|
||||||
{
|
{
|
||||||
Id = user.Id,
|
Id = user.Id,
|
||||||
@ -232,9 +228,9 @@ public class AppAuthService : IDynamicApiController, ITransient
|
|||||||
Address = user.Address,
|
Address = user.Address,
|
||||||
Signature = user.Signature,
|
Signature = user.Signature,
|
||||||
OrgId = user.OrgId,
|
OrgId = user.OrgId,
|
||||||
OrgName = org?.Name,
|
OrgName = user.SysOrg?.Name,
|
||||||
OrgType = org?.Type,
|
OrgType = user.SysOrg?.Type,
|
||||||
PosName = pos?.Name,
|
PosName = user.SysPos?.Name,
|
||||||
Apis = apis,
|
Apis = apis,
|
||||||
Roles = roles
|
Roles = roles
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,10 +11,12 @@ namespace Admin.NET.Application.Service.App;
|
|||||||
public class AppUserManager : UserManager
|
public class AppUserManager : UserManager
|
||||||
{
|
{
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
private readonly SysCacheService _sysCacheService;
|
||||||
|
|
||||||
public AppUserManager(IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor)
|
public AppUserManager(IHttpContextAccessor httpContextAccessor, SysCacheService sysCacheService) : base(httpContextAccessor, sysCacheService)
|
||||||
{
|
{
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_sysCacheService = sysCacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扩展属性
|
// 扩展属性
|
||||||
|
|||||||
@ -99,7 +99,7 @@ public class LoginUserOutput
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 角色集合
|
/// 角色集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<RoleDto> Roles { get; set; }
|
public List<RoleOutput> Roles { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 水印文字
|
/// 水印文字
|
||||||
@ -110,25 +110,4 @@ public class LoginUserOutput
|
|||||||
/// 最新密码修改时间
|
/// 最新密码修改时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? LastChangePasswordTime;
|
public DateTime? LastChangePasswordTime;
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 角色
|
|
||||||
/// </summary>
|
|
||||||
public class RoleDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 角色Id
|
|
||||||
/// </summary>
|
|
||||||
public long Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 名称
|
|
||||||
/// </summary>
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 编码
|
|
||||||
/// </summary>
|
|
||||||
public string Code { get; set; }
|
|
||||||
}
|
}
|
||||||
@ -287,23 +287,13 @@ public class SysAuthService : IDynamicApiController, ITransient
|
|||||||
[DisplayName("获取登录账号")]
|
[DisplayName("获取登录账号")]
|
||||||
public virtual async Task<LoginUserOutput> GetUserInfo()
|
public virtual async Task<LoginUserOutput> GetUserInfo()
|
||||||
{
|
{
|
||||||
var user = await _sysUserRep.GetByIdAsync(_userManager.UserId) ?? throw Oops.Oh(ErrorCodeEnum.D1011).StatusCode(401);
|
var user = await _sysUserRep.AsQueryable().Includes(u => u.SysOrg).Includes(u => u.SysPos).FirstAsync(u => u.Id == _userManager.UserId) ?? throw Oops.Oh(ErrorCodeEnum.D1011).StatusCode(401);
|
||||||
// 机构
|
|
||||||
var org = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysOrg>>().GetByIdAsync(user.OrgId);
|
|
||||||
// 职位
|
|
||||||
var pos = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysPos>>().GetByIdAsync(user.PosId);
|
|
||||||
// 角色集合
|
// 角色集合
|
||||||
var roles = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysUserRole>>().AsQueryable()
|
var roles = await App.GetRequiredService<SysUserRoleService>().GetUserRoleInfoList(user.Id);
|
||||||
.LeftJoin<SysRole>((u, a) => u.RoleId == a.Id)
|
|
||||||
.Where(u => u.UserId == user.Id)
|
|
||||||
.Select((u, a) => new RoleDto { Id = a.Id, Name = a.Name, Code = a.Code }).ToListAsync();
|
|
||||||
// 接口集合
|
// 接口集合
|
||||||
var apis = (await App.GetRequiredService<SysRoleService>().GetUserApiList())[0];
|
var apis = (await App.GetRequiredService<SysRoleService>().GetUserApiList())[0];
|
||||||
// 个性化水印文字(若系统水印为空则不显示)
|
// 水印文字(若为空则不显示)
|
||||||
var watermarkText = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysTenant>>().AsQueryable().Where(u => u.Id == user.TenantId).Select(u => u.Watermark).FirstAsync();
|
var watermarkText = _sysCacheService.Get<List<SysTenant>>(CacheConst.KeyTenant)?.FirstOrDefault(u => u.Id == user.TenantId).Watermark;
|
||||||
if (!string.IsNullOrWhiteSpace(watermarkText))
|
|
||||||
watermarkText += $"-{user.RealName}"; // $"-{user.RealName}-{_httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(true)}-{DateTime.Now}";
|
|
||||||
|
|
||||||
return new LoginUserOutput
|
return new LoginUserOutput
|
||||||
{
|
{
|
||||||
Id = user.Id,
|
Id = user.Id,
|
||||||
@ -318,28 +308,16 @@ public class SysAuthService : IDynamicApiController, ITransient
|
|||||||
Address = user.Address,
|
Address = user.Address,
|
||||||
Signature = user.Signature,
|
Signature = user.Signature,
|
||||||
OrgId = user.OrgId,
|
OrgId = user.OrgId,
|
||||||
OrgName = org?.Name,
|
OrgName = user.SysOrg?.Name,
|
||||||
OrgType = org?.Type,
|
OrgType = user.SysOrg?.Type,
|
||||||
PosName = pos?.Name,
|
PosName = user.SysPos?.Name,
|
||||||
Apis = apis,
|
Apis = apis,
|
||||||
Roles = roles,
|
Roles = roles,
|
||||||
WatermarkText = watermarkText,
|
WatermarkText = string.IsNullOrWhiteSpace(watermarkText) ? watermarkText : watermarkText + $"-{user.RealName}",
|
||||||
LastChangePasswordTime = user.LastChangePasswordTime
|
LastChangePasswordTime = user.LastChangePasswordTime
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 获取刷新Token 🔖
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="accessToken"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//[DisplayName("获取刷新Token")]
|
|
||||||
//public string GetRefreshToken([FromQuery] string accessToken)
|
|
||||||
//{
|
|
||||||
// var refreshTokenExpire = _sysConfigService.GetRefreshTokenExpire().GetAwaiter().GetResult();
|
|
||||||
// return JWTEncryption.GenerateRefreshToken(accessToken, refreshTokenExpire);
|
|
||||||
//}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 退出系统 🔖
|
/// 退出系统 🔖
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -401,7 +401,7 @@ public class SysOrgService : IDynamicApiController, ITransient
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 缓存当前用户最大角色数据范围
|
// 缓存当前用户最大角色数据范围
|
||||||
_sysCacheService.Set(CacheConst.KeyRoleMaxDataScope + userId, strongerDataScopeType, TimeSpan.FromDays(7));
|
_sysCacheService.Set($"{CacheConst.KeyRoleMaxDataScope}{userId}", strongerDataScopeType, TimeSpan.FromDays(7));
|
||||||
|
|
||||||
// 根据角色集合获取机构集合
|
// 根据角色集合获取机构集合
|
||||||
var roleOrgIdList = await _sysRoleOrgService.GetRoleOrgIdList(customDataScopeRoleIdList);
|
var roleOrgIdList = await _sysRoleOrgService.GetRoleOrgIdList(customDataScopeRoleIdList);
|
||||||
|
|||||||
@ -403,7 +403,7 @@ public class SysRoleService : IDynamicApiController, ITransient
|
|||||||
public async Task<List<List<string>>> GetUserApiList()
|
public async Task<List<List<string>>> GetUserApiList()
|
||||||
{
|
{
|
||||||
var userId = _userManager.UserId;
|
var userId = _userManager.UserId;
|
||||||
var apiList = _sysCacheService.Get<List<List<string>>>(CacheConst.KeyUserApi + userId);
|
var apiList = _sysCacheService.Get<List<List<string>>>($"{CacheConst.KeyUserApi}{userId}");
|
||||||
if (apiList != null) return apiList;
|
if (apiList != null) return apiList;
|
||||||
|
|
||||||
apiList = [[], []];
|
apiList = [[], []];
|
||||||
@ -441,7 +441,7 @@ public class SysRoleService : IDynamicApiController, ITransient
|
|||||||
// 排序接口名称
|
// 排序接口名称
|
||||||
apiList[0].Sort();
|
apiList[0].Sort();
|
||||||
apiList[1].Sort();
|
apiList[1].Sort();
|
||||||
_sysCacheService.Set(CacheConst.KeyUserApi + userId, apiList, TimeSpan.FromDays(7)); // 缓存7天
|
_sysCacheService.Set($"{CacheConst.KeyUserApi}{userId}", apiList, TimeSpan.FromDays(7)); // 缓存7天
|
||||||
return apiList;
|
return apiList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ public class SysRoleService : IDynamicApiController, ITransient
|
|||||||
var userIdList = await _sysUserRoleService.GetUserIdList(roleId);
|
var userIdList = await _sysUserRoleService.GetUserIdList(roleId);
|
||||||
foreach (var userId in userIdList)
|
foreach (var userId in userIdList)
|
||||||
{
|
{
|
||||||
_sysCacheService.Remove(CacheConst.KeyUserApi + userId);
|
_sysCacheService.Remove($"{CacheConst.KeyUserApi}{userId}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ public class SysUserRoleService : ITransient
|
|||||||
await _sysUserRoleRep.InsertRangeAsync(userRoles);
|
await _sysUserRoleRep.InsertRangeAsync(userRoles);
|
||||||
|
|
||||||
// 清除缓存
|
// 清除缓存
|
||||||
_sysCacheService.Remove(CacheConst.KeyUserApi + input.UserId);
|
_sysCacheService.Remove($"{CacheConst.KeyUserApi}{input.UserId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -61,7 +61,7 @@ public class SysUserRoleService : ITransient
|
|||||||
// 清除缓存
|
// 清除缓存
|
||||||
foreach (var userId in input.UserIdList)
|
foreach (var userId in input.UserIdList)
|
||||||
{
|
{
|
||||||
_sysCacheService.Remove(CacheConst.KeyUserApi + userId);
|
_sysCacheService.Remove($"{CacheConst.KeyUserApi}{userId}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ public class SysUserRoleService : ITransient
|
|||||||
// 清除缓存
|
// 清除缓存
|
||||||
foreach (var userId in userIdList)
|
foreach (var userId in userIdList)
|
||||||
{
|
{
|
||||||
_sysCacheService.Remove(CacheConst.KeyUserApi + userId);
|
_sysCacheService.Remove($"{CacheConst.KeyUserApi}{userId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
await _sysUserRoleRep.DeleteAsync(u => u.RoleId == roleId);
|
await _sysUserRoleRep.DeleteAsync(u => u.RoleId == roleId);
|
||||||
@ -96,7 +96,7 @@ public class SysUserRoleService : ITransient
|
|||||||
await _sysUserRoleRep.DeleteAsync(u => u.UserId == userId);
|
await _sysUserRoleRep.DeleteAsync(u => u.UserId == userId);
|
||||||
|
|
||||||
// 清除缓存
|
// 清除缓存
|
||||||
_sysCacheService.Remove(CacheConst.KeyUserApi + userId);
|
_sysCacheService.Remove($"{CacheConst.KeyUserApi}{userId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -9,92 +9,118 @@ namespace Admin.NET.Core;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前登录用户信息
|
/// 当前登录用户信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UserManager : IScoped
|
public class UserManager(IHttpContextAccessor httpContextAccessor, SysCacheService sysCacheService) : IScoped
|
||||||
{
|
{
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 应用Id
|
/// 应用Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long AppId => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AppId)?.Value).ToLong();
|
public long AppId => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AppId)?.Value).ToLong();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 租户Id
|
/// 租户Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long TenantId => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.TenantId)?.Value).ToLong();
|
public long TenantId => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.TenantId)?.Value).ToLong();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户Id
|
/// 用户Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long UserId => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.UserId)?.Value).ToLong();
|
public long UserId => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.UserId)?.Value).ToLong();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户账号
|
/// 用户账号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Account => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.Account)?.Value;
|
public string Account => httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.Account)?.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 真实姓名
|
/// 真实姓名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string RealName => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.RealName)?.Value;
|
public string RealName => httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.RealName)?.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 昵称
|
/// 昵称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string NickName => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.NickName)?.Value;
|
public string NickName => httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.NickName)?.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 账号类型
|
/// 账号类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AccountTypeEnum? AccountType => int.TryParse(_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value, out var val) ? (AccountTypeEnum?)val : null;
|
public AccountTypeEnum? AccountType => int.TryParse(httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value, out var val) ? (AccountTypeEnum?)val : null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否超级管理员
|
/// 是否超级管理员
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SuperAdmin => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value == ((int)AccountTypeEnum.SuperAdmin).ToString();
|
public bool SuperAdmin => httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value == ((int)AccountTypeEnum.SuperAdmin).ToString();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否系统管理员
|
/// 是否系统管理员
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SysAdmin => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value == ((int)AccountTypeEnum.SysAdmin).ToString();
|
public bool SysAdmin => httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value == ((int)AccountTypeEnum.SysAdmin).ToString();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 组织机构Id
|
/// 组织机构Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long OrgId => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgId)?.Value).ToLong();
|
public long OrgId => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgId)?.Value).ToLong();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 组织机构名称
|
/// 组织机构名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OrgName => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgName)?.Value);
|
public string OrgName => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgName)?.Value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 组织机构Id
|
/// 组织机构Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OrgType => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgType)?.Value);
|
public string OrgType => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgType)?.Value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 组织机构级别
|
/// 组织机构级别
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int OrgLevel => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgLevel)?.Value).ToInt();
|
public int OrgLevel => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgLevel)?.Value).ToInt();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 登录模式
|
/// 登录模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int LoginMode => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.LoginMode)?.Value).ToInt();
|
public int LoginMode => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.LoginMode)?.Value).ToInt();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Token版本号
|
/// Token版本号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TokenVersion => (_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.TokenVersion)?.Value).ToInt();
|
public int TokenVersion => (httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.TokenVersion)?.Value).ToInt();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 微信OpenId
|
/// 微信OpenId
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OpenId => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OpenId)?.Value;
|
public string OpenId => httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OpenId)?.Value;
|
||||||
|
|
||||||
public UserManager(IHttpContextAccessor httpContextAccessor)
|
///// <summary>
|
||||||
|
///// 角色Id集合
|
||||||
|
///// </summary>
|
||||||
|
//public List<long> RoleIds
|
||||||
|
//{
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// return sysCacheService.Get<List<long>>($"{CacheConst.KeyUserOrg}{UserId}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 机构Id集合
|
||||||
|
/// </summary>
|
||||||
|
public List<long> OrgIds
|
||||||
{
|
{
|
||||||
_httpContextAccessor = httpContextAccessor;
|
get
|
||||||
|
{
|
||||||
|
return sysCacheService.Get<List<long>>($"{CacheConst.KeyUserOrg}{UserId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 权限集合
|
||||||
|
/// </summary>
|
||||||
|
public List<List<string>> Permissions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return sysCacheService.Get<List<List<string>>>($"{CacheConst.KeyUserApi}{UserId}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public static class SqlSugarFilter
|
|||||||
if (string.IsNullOrWhiteSpace(userId)) return maxDataScope;
|
if (string.IsNullOrWhiteSpace(userId)) return maxDataScope;
|
||||||
|
|
||||||
// 获取用户最大数据范围---仅本人数据
|
// 获取用户最大数据范围---仅本人数据
|
||||||
maxDataScope = App.GetRequiredService<SysCacheService>().Get<int>(CacheConst.KeyRoleMaxDataScope + userId);
|
maxDataScope = App.GetRequiredService<SysCacheService>().Get<int>($"{CacheConst.KeyRoleMaxDataScope}{userId}");
|
||||||
// 若为0则获取用户机构组织集合建立缓存
|
// 若为0则获取用户机构组织集合建立缓存
|
||||||
if (maxDataScope == 0)
|
if (maxDataScope == 0)
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ public static class SqlSugarFilter
|
|||||||
{
|
{
|
||||||
var services = scope.ServiceProvider;
|
var services = scope.ServiceProvider;
|
||||||
services.GetRequiredService<SysOrgService>().GetUserOrgIdList().GetAwaiter().GetResult();
|
services.GetRequiredService<SysOrgService>().GetUserOrgIdList().GetAwaiter().GetResult();
|
||||||
maxDataScope = services.GetRequiredService<SysCacheService>().Get<int>(CacheConst.KeyRoleMaxDataScope + userId);
|
maxDataScope = services.GetRequiredService<SysCacheService>().Get<int>($"{CacheConst.KeyRoleMaxDataScope}{userId}");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (maxDataScope != (int)DataScopeEnum.Self) return maxDataScope;
|
if (maxDataScope != (int)DataScopeEnum.Self) return maxDataScope;
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import { AdminNETResultListString } from '../models';
|
|||||||
import { AdminNETResultSmKeyPairOutput } from '../models';
|
import { AdminNETResultSmKeyPairOutput } from '../models';
|
||||||
import { AdminNETResultStressTestHarnessResult } from '../models';
|
import { AdminNETResultStressTestHarnessResult } from '../models';
|
||||||
import { AdminNETResultString } from '../models';
|
import { AdminNETResultString } from '../models';
|
||||||
import { NameAbbrInput } from '../models';
|
|
||||||
import { StressTestInput } from '../models';
|
import { StressTestInput } from '../models';
|
||||||
/**
|
/**
|
||||||
* SysCommonApi - axios parameter creator
|
* SysCommonApi - axios parameter creator
|
||||||
@ -273,54 +272,6 @@ export const SysCommonApiAxiosParamCreator = function (configuration?: Configura
|
|||||||
options: localVarRequestOptions,
|
options: localVarRequestOptions,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* 获取文本简称
|
|
||||||
* @summary 获取文本简称
|
|
||||||
* @param {NameAbbrInput} [body]
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
apiSysCommonNameAbbrPost: async (body?: NameAbbrInput, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
||||||
const localVarPath = `/api/sysCommon/nameAbbr`;
|
|
||||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
||||||
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
|
||||||
let baseOptions;
|
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
|
|
||||||
const localVarHeaderParameter = {} as any;
|
|
||||||
const localVarQueryParameter = {} as any;
|
|
||||||
|
|
||||||
// authentication Bearer required
|
|
||||||
// http bearer authentication required
|
|
||||||
if (configuration && configuration.accessToken) {
|
|
||||||
const accessToken = typeof configuration.accessToken === 'function'
|
|
||||||
? await configuration.accessToken()
|
|
||||||
: await configuration.accessToken;
|
|
||||||
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
localVarHeaderParameter['Content-Type'] = 'application/json-patch+json';
|
|
||||||
|
|
||||||
const query = new URLSearchParams(localVarUrlObj.search);
|
|
||||||
for (const key in localVarQueryParameter) {
|
|
||||||
query.set(key, localVarQueryParameter[key]);
|
|
||||||
}
|
|
||||||
for (const key in options.params) {
|
|
||||||
query.set(key, options.params[key]);
|
|
||||||
}
|
|
||||||
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
|
||||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
||||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
|
||||||
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
|
||||||
localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
|
|
||||||
|
|
||||||
return {
|
|
||||||
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
|
||||||
options: localVarRequestOptions,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 国密SM2解密字符串 🔖
|
* @summary 国密SM2解密字符串 🔖
|
||||||
@ -632,20 +583,6 @@ export const SysCommonApiFp = function(configuration?: Configuration) {
|
|||||||
return axios.request(axiosRequestArgs);
|
return axios.request(axiosRequestArgs);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* 获取文本简称
|
|
||||||
* @summary 获取文本简称
|
|
||||||
* @param {NameAbbrInput} [body]
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
async apiSysCommonNameAbbrPost(body?: NameAbbrInput, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminNETResultString>>> {
|
|
||||||
const localVarAxiosArgs = await SysCommonApiAxiosParamCreator(configuration).apiSysCommonNameAbbrPost(body, options);
|
|
||||||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
||||||
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
|
||||||
return axios.request(axiosRequestArgs);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 国密SM2解密字符串 🔖
|
* @summary 国密SM2解密字符串 🔖
|
||||||
@ -773,16 +710,6 @@ export const SysCommonApiFactory = function (configuration?: Configuration, base
|
|||||||
async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultString>> {
|
async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultString>> {
|
||||||
return SysCommonApiFp(configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(axios, basePath));
|
return SysCommonApiFp(configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* 获取文本简称
|
|
||||||
* @summary 获取文本简称
|
|
||||||
* @param {NameAbbrInput} [body]
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
async apiSysCommonNameAbbrPost(body?: NameAbbrInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultString>> {
|
|
||||||
return SysCommonApiFp(configuration).apiSysCommonNameAbbrPost(body, options).then((request) => request(axios, basePath));
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 国密SM2解密字符串 🔖
|
* @summary 国密SM2解密字符串 🔖
|
||||||
@ -896,17 +823,6 @@ export class SysCommonApi extends BaseAPI {
|
|||||||
public async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultString>> {
|
public async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultString>> {
|
||||||
return SysCommonApiFp(this.configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(this.axios, this.basePath));
|
return SysCommonApiFp(this.configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 获取文本简称
|
|
||||||
* @summary 获取文本简称
|
|
||||||
* @param {NameAbbrInput} [body]
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
* @memberof SysCommonApi
|
|
||||||
*/
|
|
||||||
public async apiSysCommonNameAbbrPost(body?: NameAbbrInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultString>> {
|
|
||||||
return SysCommonApiFp(this.configuration).apiSysCommonNameAbbrPost(body, options).then((request) => request(this.axios, this.basePath));
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 国密SM2解密字符串 🔖
|
* @summary 国密SM2解密字符串 🔖
|
||||||
|
|||||||
@ -175,14 +175,6 @@ export interface AddCodeGenInput {
|
|||||||
*/
|
*/
|
||||||
tableList: Array<AddSysCodeGenTable>;
|
tableList: Array<AddSysCodeGenTable>;
|
||||||
|
|
||||||
/**
|
|
||||||
* 简拼
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof AddCodeGenInput
|
|
||||||
*/
|
|
||||||
pinyin?: string | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {CodeGenMethodEnum}
|
* @type {CodeGenMethodEnum}
|
||||||
* @memberof AddCodeGenInput
|
* @memberof AddCodeGenInput
|
||||||
|
|||||||
@ -336,7 +336,6 @@ export * from './mqtt-client-status';
|
|||||||
export * from './mqtt-protocol-version';
|
export * from './mqtt-protocol-version';
|
||||||
export * from './mqtt-session-status';
|
export * from './mqtt-session-status';
|
||||||
export * from './mzb-input';
|
export * from './mzb-input';
|
||||||
export * from './name-abbr-input';
|
|
||||||
export * from './navigate';
|
export * from './navigate';
|
||||||
export * from './network-info';
|
export * from './network-info';
|
||||||
export * from './network-interface-statistics';
|
export * from './network-interface-statistics';
|
||||||
@ -407,7 +406,6 @@ export * from './reset-column-custom-input';
|
|||||||
export * from './reset-interval-enum';
|
export * from './reset-interval-enum';
|
||||||
export * from './reset-pwd-user-input';
|
export * from './reset-pwd-user-input';
|
||||||
export * from './role-api-input';
|
export * from './role-api-input';
|
||||||
export * from './role-dto';
|
|
||||||
export * from './role-input';
|
export * from './role-input';
|
||||||
export * from './role-menu-input';
|
export * from './role-menu-input';
|
||||||
export * from './role-org-input';
|
export * from './role-org-input';
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AccountTypeEnum } from './account-type-enum';
|
import { AccountTypeEnum } from './account-type-enum';
|
||||||
import { RoleDto } from './role-dto';
|
import { RoleOutput } from './role-output';
|
||||||
/**
|
/**
|
||||||
* 用户登录信息
|
* 用户登录信息
|
||||||
*
|
*
|
||||||
@ -159,10 +159,10 @@ export interface LoginUserOutput {
|
|||||||
/**
|
/**
|
||||||
* 角色集合
|
* 角色集合
|
||||||
*
|
*
|
||||||
* @type {Array<RoleDto>}
|
* @type {Array<RoleOutput>}
|
||||||
* @memberof LoginUserOutput
|
* @memberof LoginUserOutput
|
||||||
*/
|
*/
|
||||||
roles?: Array<RoleDto> | null;
|
roles?: Array<RoleOutput> | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 水印文字
|
* 水印文字
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Admin.NET 通用权限开发平台
|
|
||||||
* 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。<br/><u><b><font color='FF0000'> 👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!</font></b></u>
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文本简称
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface NameAbbrInput
|
|
||||||
*/
|
|
||||||
export interface NameAbbrInput {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文本
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof NameAbbrInput
|
|
||||||
*/
|
|
||||||
text?: string | null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否全称
|
|
||||||
*
|
|
||||||
* @type {boolean}
|
|
||||||
* @memberof NameAbbrInput
|
|
||||||
*/
|
|
||||||
all?: boolean;
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Admin.NET 通用权限开发平台
|
|
||||||
* 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。<br/><u><b><font color='FF0000'> 👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!</font></b></u>
|
|
||||||
*
|
|
||||||
* OpenAPI spec version: 1.0.0
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface RoleDto
|
|
||||||
*/
|
|
||||||
export interface RoleDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色Id
|
|
||||||
*
|
|
||||||
* @type {number}
|
|
||||||
* @memberof RoleDto
|
|
||||||
*/
|
|
||||||
id?: number;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 名称
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof RoleDto
|
|
||||||
*/
|
|
||||||
name?: string | null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编码
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof RoleDto
|
|
||||||
*/
|
|
||||||
code?: string | null;
|
|
||||||
}
|
|
||||||
@ -216,12 +216,4 @@ export interface SysCodeGen {
|
|||||||
* @memberof SysCodeGen
|
* @memberof SysCodeGen
|
||||||
*/
|
*/
|
||||||
tableList?: Array<SysCodeGenTable> | null;
|
tableList?: Array<SysCodeGenTable> | null;
|
||||||
|
|
||||||
/**
|
|
||||||
* 简拼
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof SysCodeGen
|
|
||||||
*/
|
|
||||||
pinyin?: string | null;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -167,14 +167,6 @@ export interface UpdateCodeGenInput {
|
|||||||
*/
|
*/
|
||||||
tableList: Array<AddSysCodeGenTable>;
|
tableList: Array<AddSysCodeGenTable>;
|
||||||
|
|
||||||
/**
|
|
||||||
* 简拼
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof UpdateCodeGenInput
|
|
||||||
*/
|
|
||||||
pinyin?: string | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {CodeGenMethodEnum}
|
* @type {CodeGenMethodEnum}
|
||||||
* @memberof UpdateCodeGenInput
|
* @memberof UpdateCodeGenInput
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user