feat: 이메일 중복 체크 API 구현 (#58)
All checks were successful
SPMS_API/pipeline/head This commit looks good

Reviewed-on: https://git.ipstein.myds.me/SPMS/SPMS_API/pulls/61
This commit is contained in:
김선규 2026-02-10 01:27:57 +00:00
commit e96bbff727
5 changed files with 45 additions and 0 deletions

View File

@ -33,6 +33,19 @@ public class AuthController : ControllerBase
return Ok(ApiResponse<SignupResponseDto>.Success(result, "회원가입 완료. 이메일 인증이 필요합니다."));
}
[HttpPost("email/check")]
[AllowAnonymous]
[SwaggerOperation(
Summary = "이메일 중복 체크",
Description = "회원가입 전 이메일 사용 가능 여부를 확인합니다.")]
[SwaggerResponse(200, "이메일 중복 체크 성공", typeof(ApiResponse<EmailCheckResponseDto>))]
[SwaggerResponse(400, "잘못된 요청")]
public async Task<IActionResult> CheckEmailAsync([FromBody] EmailCheckRequestDto request)
{
var result = await _authService.CheckEmailAsync(request);
return Ok(ApiResponse<EmailCheckResponseDto>.Success(result));
}
[HttpPost("login")]
[AllowAnonymous]
[SwaggerOperation(

View File

@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace SPMS.Application.DTOs.Auth;
public class EmailCheckRequestDto
{
[Required(ErrorMessage = "이메일은 필수입니다.")]
[EmailAddress(ErrorMessage = "올바른 이메일 형식이 아닙니다.")]
public string Email { get; set; } = string.Empty;
}

View File

@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace SPMS.Application.DTOs.Auth;
public class EmailCheckResponseDto
{
public string Email { get; set; } = string.Empty;
[JsonPropertyName("is_available")]
public bool IsAvailable { get; set; }
}

View File

@ -9,4 +9,5 @@ public interface IAuthService
Task<TokenRefreshResponseDto> RefreshTokenAsync(TokenRefreshRequestDto request);
Task LogoutAsync(long adminId);
Task ChangePasswordAsync(long adminId, ChangePasswordRequestDto request);
Task<EmailCheckResponseDto> CheckEmailAsync(EmailCheckRequestDto request);
}

View File

@ -215,4 +215,14 @@ public class AuthService : IAuthService
_adminRepository.Update(admin);
await _unitOfWork.SaveChangesAsync();
}
public async Task<EmailCheckResponseDto> CheckEmailAsync(EmailCheckRequestDto request)
{
var exists = await _adminRepository.EmailExistsAsync(request.Email);
return new EmailCheckResponseDto
{
Email = request.Email,
IsAvailable = !exists
};
}
}