✏️ Fix: [#48] user field 중복 체크 서비스 로직 구현
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user