2020-09-22 13:59:29 +02:00
|
|
|
from datetime import datetime, timedelta
|
|
|
|
from secrets import randbits, token_hex
|
|
|
|
from typing import Optional
|
|
|
|
|
2020-06-05 01:09:55 +02:00
|
|
|
from fastapi import Query
|
2020-07-03 13:30:01 +02:00
|
|
|
from pydantic import BaseModel, EmailStr
|
2020-06-05 01:09:55 +02:00
|
|
|
|
|
|
|
|
2020-09-11 00:01:24 +02:00
|
|
|
class UserBase(BaseModel):
|
2020-06-05 01:09:55 +02:00
|
|
|
email: EmailStr
|
2020-09-11 00:01:24 +02:00
|
|
|
device_id: str
|
|
|
|
lang_type: int = Query(None, ge=1, le=2)
|
|
|
|
user_type: int = Query(None, ge=1, le=2)
|
|
|
|
|
|
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
|
|
full_name: str
|
2020-06-05 01:09:55 +02:00
|
|
|
password: str
|
2020-09-03 18:33:15 +02:00
|
|
|
gender: int = Query(None, ge=1, le=3)
|
2020-06-21 15:55:46 +02:00
|
|
|
mobile: str = Query(None, min_length=8, max_length=13)
|
2020-09-03 18:33:15 +02:00
|
|
|
user_image: Optional[str] = None
|
|
|
|
device_type: int = Query(None, ge=1, le=2)
|
2020-09-11 00:01:24 +02:00
|
|
|
city_id: int
|
2020-09-22 13:59:29 +02:00
|
|
|
access_key: str = token_hex()
|
2020-09-28 18:19:59 +02:00
|
|
|
otp: int = randbits(20)
|
2020-09-22 13:59:29 +02:00
|
|
|
otp_valid_time: datetime = datetime.now() + timedelta(minutes=10)
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
|
|
|
class UserCreateResponse(UserBase):
|
|
|
|
id: int
|
|
|
|
full_name: str
|
|
|
|
password: str
|
|
|
|
gender: int = Query(None, ge=1, le=3)
|
|
|
|
mobile: str = Query(None, min_length=8, max_length=13)
|
|
|
|
user_image: Optional[str] = None
|
|
|
|
device_type: int = Query(None, ge=1, le=2)
|
|
|
|
access_key: str
|
|
|
|
otp: int
|
|
|
|
otp_valid_time: datetime
|
|
|
|
status: int = Query(None, ge=0, le=1)
|
|
|
|
admin_status: int = Query(None, ge=0, le=1)
|
|
|
|
created: datetime
|
|
|
|
updated: datetime = Query(None)
|
2020-06-05 01:09:55 +02:00
|
|
|
|
2020-09-11 00:01:24 +02:00
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
2020-06-05 01:09:55 +02:00
|
|
|
|
2020-09-11 00:01:24 +02:00
|
|
|
|
|
|
|
class UserLogin(UserBase):
|
2020-06-05 01:09:55 +02:00
|
|
|
password: str
|
2020-09-11 00:01:24 +02:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
2020-06-05 01:09:55 +02:00
|
|
|
|
|
|
|
|
2020-09-22 13:59:29 +02:00
|
|
|
class UserLoginResponse(UserBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
2020-09-11 00:01:24 +02:00
|
|
|
class SocialLogin(UserBase):
|
|
|
|
type: int = Query(None, ge=1, le=2)
|
|
|
|
social_id: str
|
|
|
|
device_type: int = Query(None, ge=1, le=2)
|
|
|
|
mobile: str = Query(None, min_length=8, max_length=13)
|
|
|
|
full_name: str
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
2020-09-28 18:19:59 +02:00
|
|
|
class OTPBase(BaseModel):
|
2020-09-22 13:59:29 +02:00
|
|
|
access_key: str
|
|
|
|
otp: int
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
2020-09-28 18:19:59 +02:00
|
|
|
class OTPVerify(OTPBase):
|
2020-09-22 13:59:29 +02:00
|
|
|
pass
|
2020-09-11 00:01:24 +02:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
2020-09-28 18:19:59 +02:00
|
|
|
class OTPVerifyResponse(OTPBase):
|
|
|
|
id: int
|
|
|
|
full_name: str
|
|
|
|
email: EmailStr
|
|
|
|
gender: int = Query(None, ge=1, le=3)
|
|
|
|
mobile: str = Query(None, min_length=8, max_length=13)
|
|
|
|
otp_valid_time: datetime
|
|
|
|
lang_type: int = Query(None, ge=1, le=2)
|
|
|
|
status: int = Query(None, ge=0, le=1)
|
|
|
|
device_type: int = Query(None, ge=1, le=2)
|
|
|
|
created: datetime
|
|
|
|
updated: datetime = Query(None)
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
2020-09-03 18:33:15 +02:00
|
|
|
access_key: str
|
|
|
|
otp: int = Query(None, ge=6, le=6)
|
2020-09-11 00:01:24 +02:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|