1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- 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;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="form"></param>
- /// <returns></returns>
- [HttpPost("login")]
- [SwaggerOperation(Description = "登录接口", Summary = "Login")]
- public IActionResult LoginAsync([FromBody] LoginBody form)
- {
- var securityConfig = _configuration.GetSection(FrameworkConstant.SECURITY_CONFIG).Get<SecurityConfig>() ?? 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,
- });
- }
- }
- }
|