using System.Web.Http;
using CncModels.Dto;
using CncModels.Dto.Login;
using CncService.Interface;

namespace CncWebApi.Controllers
{
    /// <summary>
    /// 登录认证控制器
    /// </summary>
    [RoutePrefix("api/admin")]
    public class AuthController : ApiController
    {
        private readonly IAuthService _authService;

        /// <summary>
        /// 构造函数
        /// </summary>
        public AuthController(IAuthService authService)
        {
            _authService = authService;
        }

        /// <summary>
        /// 管理员登录
        /// POST /api/admin/login
        /// </summary>
        [HttpPost]
        [Route("login")]
        public IHttpActionResult Login([FromBody] LoginRequest request)
        {
            var result = _authService.Login(request);
            return Ok(ApiResponse<LoginResponse>.Success(result));
        }
    }
}
