From 5d49a2ce4933d8027125d8c0a404a4cdfb775475 Mon Sep 17 00:00:00 2001 From: SEAN Date: Tue, 10 Feb 2026 10:23:25 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=EC=B2=B4=ED=81=AC=20API=20=EA=B5=AC=ED=98=84=20(#5?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POST /v1/in/auth/email/check 엔드포인트 추가. 기존 EmailExistsAsync 활용하여 이메일 사용 가능 여부 반환. --- SPMS.API/Controllers/AuthController.cs | 13 +++++++++++++ SPMS.Application/DTOs/Auth/EmailCheckRequestDto.cs | 10 ++++++++++ SPMS.Application/DTOs/Auth/EmailCheckResponseDto.cs | 11 +++++++++++ SPMS.Application/Interfaces/IAuthService.cs | 1 + SPMS.Application/Services/AuthService.cs | 10 ++++++++++ 5 files changed, 45 insertions(+) create mode 100644 SPMS.Application/DTOs/Auth/EmailCheckRequestDto.cs create mode 100644 SPMS.Application/DTOs/Auth/EmailCheckResponseDto.cs diff --git a/SPMS.API/Controllers/AuthController.cs b/SPMS.API/Controllers/AuthController.cs index 314c0ea..a6d9158 100644 --- a/SPMS.API/Controllers/AuthController.cs +++ b/SPMS.API/Controllers/AuthController.cs @@ -33,6 +33,19 @@ public class AuthController : ControllerBase return Ok(ApiResponse.Success(result, "회원가입 완료. 이메일 인증이 필요합니다.")); } + [HttpPost("email/check")] + [AllowAnonymous] + [SwaggerOperation( + Summary = "이메일 중복 체크", + Description = "회원가입 전 이메일 사용 가능 여부를 확인합니다.")] + [SwaggerResponse(200, "이메일 중복 체크 성공", typeof(ApiResponse))] + [SwaggerResponse(400, "잘못된 요청")] + public async Task CheckEmailAsync([FromBody] EmailCheckRequestDto request) + { + var result = await _authService.CheckEmailAsync(request); + return Ok(ApiResponse.Success(result)); + } + [HttpPost("login")] [AllowAnonymous] [SwaggerOperation( diff --git a/SPMS.Application/DTOs/Auth/EmailCheckRequestDto.cs b/SPMS.Application/DTOs/Auth/EmailCheckRequestDto.cs new file mode 100644 index 0000000..81cc2ec --- /dev/null +++ b/SPMS.Application/DTOs/Auth/EmailCheckRequestDto.cs @@ -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; +} diff --git a/SPMS.Application/DTOs/Auth/EmailCheckResponseDto.cs b/SPMS.Application/DTOs/Auth/EmailCheckResponseDto.cs new file mode 100644 index 0000000..49d47c5 --- /dev/null +++ b/SPMS.Application/DTOs/Auth/EmailCheckResponseDto.cs @@ -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; } +} diff --git a/SPMS.Application/Interfaces/IAuthService.cs b/SPMS.Application/Interfaces/IAuthService.cs index 84f7713..6c508dd 100644 --- a/SPMS.Application/Interfaces/IAuthService.cs +++ b/SPMS.Application/Interfaces/IAuthService.cs @@ -9,4 +9,5 @@ public interface IAuthService Task RefreshTokenAsync(TokenRefreshRequestDto request); Task LogoutAsync(long adminId); Task ChangePasswordAsync(long adminId, ChangePasswordRequestDto request); + Task CheckEmailAsync(EmailCheckRequestDto request); } diff --git a/SPMS.Application/Services/AuthService.cs b/SPMS.Application/Services/AuthService.cs index e2e3ea1..f0995b4 100644 --- a/SPMS.Application/Services/AuthService.cs +++ b/SPMS.Application/Services/AuthService.cs @@ -215,4 +215,14 @@ public class AuthService : IAuthService _adminRepository.Update(admin); await _unitOfWork.SaveChangesAsync(); } + + public async Task CheckEmailAsync(EmailCheckRequestDto request) + { + var exists = await _adminRepository.EmailExistsAsync(request.Email); + return new EmailCheckResponseDto + { + Email = request.Email, + IsAvailable = !exists + }; + } }