|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// BaseApiCpntroller
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class BaseApiUserController : BaseApiController
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ISysUserService
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ISysUserService _sysUserService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造函数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sysUserService"></param>
|
|
|
|
|
public BaseApiUserController(ISysUserService sysUserService)
|
|
|
|
|
{
|
|
|
|
|
_sysUserService = sysUserService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前登录用户信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|