26 lines
653 B
C#
26 lines
653 B
C#
using AI.Common.Helpers;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Security.Claims;
|
|
|
|
namespace AI.Api.Controllers
|
|
{
|
|
[ApiController]
|
|
[Authorize]
|
|
public class BaseController : ControllerBase
|
|
{
|
|
public long UId
|
|
{
|
|
get
|
|
{
|
|
var uid = HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value;
|
|
if (string.IsNullOrWhiteSpace(uid))
|
|
{
|
|
throw Oops.Oh("用户信息有误,请重新登录");
|
|
}
|
|
return long.Parse(uid);
|
|
}
|
|
}
|
|
}
|
|
}
|