using Admin.Core.Common;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using System.Security.Claims;
using Admin.Core.IService.ISys;
using Admin.Core.Model.Sys;
namespace Admin.Core.Api
{
///
/// BaseApiCpntroller
///
public class BaseApiUserController : BaseApiController
{
///
/// ISysUserService
///
public ISysUserService _sysUserService;
///
/// 构造函数
///
///
public BaseApiUserController(ISysUserService sysUserService)
{
_sysUserService = sysUserService;
}
///
/// 获取当前登录用户信息
///
///
public SysUser CurrentUser
{
get
{
var currentUser = new SysUser { LoginName = string.Empty };
var loginName = HttpContext.User.Identity.Name;
if (loginName.IsNotEmptyOrNull())
{
int.TryParse(ClaimHelper.Get(HttpContext, ClaimTypes.Sid), out int userId);
currentUser.UserID = userId;
currentUser.LoginName = loginName;
//var key = "Admin.Core." + currentUser.UserID;
//currentUser = OperatorProvider.GetCurrent(HttpContext, "1");
//if (!currentUser.IsNotEmptyOrNull())
//{
// currentUser = _sysUserService.QueryById(userId).Result;
// if (currentUser.IsNotEmptyOrNull())
// {
// OperatorProvider.AddCurrent(HttpContext, key, currentUser);
// }
//}
}
return currentUser;
}
}
}
}