using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebApi.Controllers;

/// <summary>
/// 用户基础控制器
/// </summary>
[ApiController]
[Authorize("UserApi")]
public abstract class UserControllerBase : ControllerBase
{
    /// <summary>
    /// 当前用户内码
    /// </summary>
    /// <returns></returns>
    protected long CurrentUserId
    {
        get
        {
            long Id = 0;

            User.Claims.ToList().ForEach(item =>
            {
                if (item.Type == "id")
                {
                    Id = long.Parse(item.Value);
                }
            });
            return Id;
        }
    }
}
