From 368cbb1632b9f7b25dcf732a62f1265de16135af Mon Sep 17 00:00:00 2001 From: sm4640 Date: Tue, 6 May 2025 20:03:18 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix:=20[#48]=20user=20fiel?= =?UTF-8?q?d=20=EC=A4=91=EB=B3=B5=20=EC=B2=B4=ED=81=AC=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/services.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/users/services.py b/users/services.py index 8dee258..74182e3 100644 --- a/users/services.py +++ b/users/services.py @@ -8,14 +8,19 @@ from datetime import timedelta # 30일 이전 일수 계산 thirty_days_ago = timezone.now() - timedelta(days=30) +DUPLICATE_CHECK = { + 'email': 'email', + 'nickname': 'nickname' +} + class CheckUserFieldDuplicateService: @staticmethod - def check_nickname_duplicate(query): - pass - - @staticmethod - def check_custom_url_duplicate(): - pass + def check_duplicate(field: str, value: str) -> bool: + if field not in DUPLICATE_CHECK: + raise ValueError(f"{field}는 지원하지 않는 필드입니다.") + + filter_dict = {DUPLICATE_CHECK[field]:value} + return User.objects.filter(**filter_dict).exists()