😎增加获取当前账号类型信息
This commit is contained in:
parent
21140b595b
commit
891021d957
@ -241,6 +241,12 @@ public enum ErrorCodeEnum
|
||||
[ErrorCodeItemMetadata("手机号已存在")]
|
||||
D1032,
|
||||
|
||||
/// <summary>
|
||||
/// 无权操作此账号
|
||||
/// </summary>
|
||||
[ErrorCodeItemMetadata("无权操作此账号")]
|
||||
D1033,
|
||||
|
||||
/// <summary>
|
||||
/// 父机构不存在
|
||||
/// </summary>
|
||||
|
||||
@ -105,7 +105,10 @@ public class SysUserService : IDynamicApiController, ITransient
|
||||
[ApiDescriptionSettings(Name = "Add"), HttpPost]
|
||||
[DisplayName("增加用户")]
|
||||
public virtual async Task<long> AddUser(AddUserInput input)
|
||||
{
|
||||
{
|
||||
// 是否有权操作此账号
|
||||
if (!_userManager.SuperAdmin && input.AccountType is AccountTypeEnum.SuperAdmin) throw Oops.Oh(ErrorCodeEnum.D1033);
|
||||
|
||||
var query = _sysUserRep.AsQueryable().ClearFilter();
|
||||
if (await query.AnyAsync(u => u.Account == input.Account)) throw Oops.Oh(ErrorCodeEnum.D1003);
|
||||
if (!string.IsNullOrWhiteSpace(input.Phone) && await query.AnyAsync(u => u.Phone == input.Phone)) throw Oops.Oh(ErrorCodeEnum.D1032);
|
||||
@ -138,7 +141,7 @@ public class SysUserService : IDynamicApiController, ITransient
|
||||
[ApiDescriptionSettings(Name = "Update"), HttpPost]
|
||||
[DisplayName("更新用户")]
|
||||
public virtual async Task UpdateUser(UpdateUserInput input)
|
||||
{
|
||||
{
|
||||
var query = _sysUserRep.AsQueryable().ClearFilter().Where(u => u.Id != input.Id);
|
||||
if (await query.AnyAsync(u => u.Account == input.Account)) throw Oops.Oh(ErrorCodeEnum.D1003);
|
||||
if (!string.IsNullOrWhiteSpace(input.Phone) && await query.AnyAsync(u => u.Phone == input.Phone)) throw Oops.Oh(ErrorCodeEnum.D1032);
|
||||
|
||||
@ -43,6 +43,11 @@ public class UserManager : IScoped
|
||||
/// </summary>
|
||||
public string NickName => _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.NickName)?.Value;
|
||||
|
||||
/// <summary>
|
||||
/// 账号类型
|
||||
/// </summary>
|
||||
public AccountTypeEnum? AccountType => int.TryParse(_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.AccountType)?.Value, out var val) ? (AccountTypeEnum?)val : null;
|
||||
|
||||
/// <summary>
|
||||
/// 是否超级管理员
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user