using Furion;
using Nirvana.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YBDevice.NApi.Application.ThirdClient
{
    /// <summary>
    /// 获取授权用户信息
    /// </summary>
    public static class AuthUserInfoService
    {
        public static AuthUserInfo GetUserInfo()
        {
            AuthUserInfo CurrentUser = null;
            var user = App.User;
            if (user != null)
            {
                CurrentUser = new AuthUserInfo();
                if (user.HasClaim(x => x.Type == "UserId"))
                {
                    CurrentUser.UserId = user.FindFirst("UserId").Value.ToGuid();
                }
                if (user.HasClaim(x => x.Type == "OpenId"))
                {
                    CurrentUser.OpenId = user.FindFirst("OpenId").Value.ToString();
                }
            }
            return CurrentUser;
        }
    }
    /// <summary>
    /// 授权用户信息
    /// </summary>
    public class AuthUserInfo
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        public Guid UserId { get; set; }
        /// <summary>
        /// 用户OPENID
        /// </summary>
        public string OpenId { get; set; }
    }
}
