using Furion;
using Nirvana.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YBDevice.Entity;
namespace YBDevice.Application
{
public static class BaseInfoService
{
///
/// 获取用户授权信息
///
///
public static OperatorModel GetUserInfo()
{
OperatorModel CurrentUser = null;
var user = App.User;
if (user != null)
{
CurrentUser = new OperatorModel();
if (user.HasClaim(x => x.Type == "UserId"))
{
CurrentUser.UserId = user.FindFirst("UserId").Value.ToInt();
}
if (user.HasClaim(x => x.Type == "BusinessId"))
{
CurrentUser.BusinessId = user.FindFirst("BusinessId").Value.ToInt();
}
if (user.HasClaim(x => x.Type == "BusinessCode"))
{
CurrentUser.BusinessCode = user.FindFirst("BusinessCode").Value.ToStr();
}
if (user.HasClaim(x => x.Type == "RealName"))
{
CurrentUser.RealName = user.FindFirst("RealName").Value.ToStr();
}
if (user.HasClaim(x => x.Type == "RoleId"))
{
CurrentUser.RoleId = user.FindFirst("RoleId").Value.ToGuid();
}
if (user.HasClaim(x => x.Type == "AccountType"))
{
CurrentUser.AccountType = (AccountType)(user.FindFirst("AccountType").Value.ToInt());
}
if (user.HasClaim(x => x.Type == "IsSuper"))
{
CurrentUser.IsSuper = user.FindFirst("IsSuper").Value.ToBool();
}
if (user.HasClaim(x => x.Type == "Type"))
{
CurrentUser.Type = user.FindFirst("Type").Value.ToInt();
}
}
return CurrentUser;
}
}
}