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()