52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System.Diagnostics;
|
|
using System.Security.Claims;
|
|
using UserCenter.Model;
|
|
using VideoAnalysisCore.Common;
|
|
using VideoAnalysisCore.Controllers.Dto;
|
|
|
|
namespace VideoAnalysisCore.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 通用接口
|
|
/// </summary>
|
|
[Authorize(AuthenticationSchemes = Authentication.vdAdmin)]
|
|
[Route("api/[controller]/[action]")]
|
|
public class AdminController : ControllerBase
|
|
{
|
|
public AdminController()
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// 登录
|
|
/// </summary>
|
|
/// <param name="req">请求体</param>
|
|
/// <returns></returns>
|
|
[HttpPost, AllowAnonymous]
|
|
public IActionResult Login([FromBody] AdminLoginReq req)
|
|
{
|
|
if (!ModelState.IsValid) return BadRequest(ModelState);
|
|
if (string.IsNullOrWhiteSpace(req.Account)
|
|
|| string.IsNullOrWhiteSpace(req.Password))
|
|
return BadRequest("无效的登录信息");
|
|
|
|
return Ok(new
|
|
{
|
|
//按钮权限
|
|
Permissions = "*",
|
|
//用户名
|
|
UserName = "管理员",
|
|
NickName = "管理员",
|
|
AccessToken = JwtHelper.GetToken(AppCommon.Config.AuthKey,
|
|
[
|
|
new Claim("Id","999"),
|
|
])
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|