SPMS_API/SPMS.API/Controllers/AuthController.cs
seonkyu.kim b11c8dc918 feat: 관리자 로그인 API 구현 (#36)
- LoginRequestDto, LoginResponseDto 추가
- IAuthService, AuthService 구현 (BCrypt 비밀번호 검증)
- AdminRepository 구현 (GetByEmailAsync)
- AuthController 추가 (POST /v1/in/auth/login)
- DI 등록 (IAuthService, IAdminRepository)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-09 22:16:25 +09:00

35 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using SPMS.Application.DTOs.Auth;
using SPMS.Application.Interfaces;
using SPMS.Domain.Common;
namespace SPMS.API.Controllers;
[ApiController]
[Route("v1/in/auth")]
[ApiExplorerSettings(GroupName = "auth")]
public class AuthController : ControllerBase
{
private readonly IAuthService _authService;
public AuthController(IAuthService authService)
{
_authService = authService;
}
[HttpPost("login")]
[AllowAnonymous]
[SwaggerOperation(
Summary = "관리자 로그인",
Description = "이메일과 비밀번호로 로그인하여 JWT 토큰을 발급받습니다.")]
[SwaggerResponse(200, "로그인 성공", typeof(ApiResponse<LoginResponseDto>))]
[SwaggerResponse(401, "로그인 실패")]
public async Task<IActionResult> LoginAsync([FromBody] LoginRequestDto request)
{
var result = await _authService.LoginAsync(request);
return Ok(ApiResponse<LoginResponseDto>.Success(result));
}
}