39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using LearningOfficer.OA.Common.Dtos.LoginMobile;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace LearningOfficer.OA.Mobile.Api.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 自定义基础Api控制器
|
|
/// </summary>
|
|
[Authorize]
|
|
[ApiController]
|
|
public class BaseApiController : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// Api版本前缀
|
|
/// </summary>
|
|
protected const string RoutePrefix = "api/v{version:apiVersion}";
|
|
public MobileTokenInfo ZereUser => GetTokenInfo();
|
|
private MobileTokenInfo GetTokenInfo()
|
|
{
|
|
return new MobileTokenInfo
|
|
{
|
|
UserType = HttpContext?.User?.FindFirst("UserType")?.Value,
|
|
UserName = HttpContext?.User?.FindFirst("UserName")?.Value,
|
|
UserId = HttpContext?.User?.FindFirst("UserId")?.Value,
|
|
RoleEnum = HttpContext?.User?.FindFirst("RoleEnum")?.Value,
|
|
Account = HttpContext?.User?.FindFirst("Account")?.Value,
|
|
Jwt_id = HttpContext?.User?.FindFirst("Jwt_id")?.Value,
|
|
loginType = HttpContext?.User?.FindFirst("loginType")?.Value,
|
|
Phone = HttpContext?.User?.FindFirst("Phone")?.Value,
|
|
Role_Name = HttpContext?.User?.FindFirst("Role_Name")?.Value,
|
|
School_Name = HttpContext?.User?.FindFirst("School_Name")?.Value,
|
|
Cloud_id = HttpContext?.User?.FindFirst("Cloud_id")?.Value,
|
|
};
|
|
}
|
|
|
|
}
|
|
}
|