using ERP.Core.Dto; using ERP.Core.Interface; using ERP.Framework.Attribute; using ERP.Framework.Config; using ERP.Framework.Constants; using ERP.Framework.Emum; using ERP.Framework.Security; using ERP.Framework.WebApi; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Swashbuckle.AspNetCore.Annotations; namespace ERP.Core.Controller { [Route("auth")] public class AuthController : BaseController { private readonly IConfiguration _configuration; private readonly IAuthService _authService; public AuthController(IConfiguration configuration, IAuthService authService) { _configuration = configuration; _authService = authService; } /// /// /// /// /// [HttpPost("login")] [SwaggerOperation(Description = "登录接口", Summary = "Login")] public IActionResult LoginAsync([FromBody] LoginBody form) { var securityConfig = _configuration.GetSection(FrameworkConstant.SECURITY_CONFIG).Get() ?? new SecurityConfig(); var loginUser = _authService.GetLoginUser(securityConfig, form.LoginName, form.Password); var result = LoginHelper.LoginByDevice(loginUser, securityConfig, DeviceEnum.Web); //Todo 记录登录日志 return Success(new { access_token = result, }); } } }