75 lines
1.6 KiB
Python
75 lines
1.6 KiB
Python
from datetime import datetime
|
|
from typing import List, Optional
|
|
from pydantic import BaseModel, EmailStr
|
|
from beanie import Document, Indexed
|
|
from enum import IntEnum
|
|
|
|
|
|
class UserRegion(IntEnum):
|
|
OTHER = 0
|
|
ZH_CN = 1
|
|
|
|
|
|
class Tags(BaseModel):
|
|
skill: List[str]
|
|
|
|
|
|
class SelfIntro(BaseModel):
|
|
summary: str = ""
|
|
content_html: str = ""
|
|
tags: Tags
|
|
|
|
|
|
class Photo(BaseModel):
|
|
url: Optional[str]
|
|
base64: str
|
|
filename: str
|
|
|
|
|
|
class Email(BaseModel):
|
|
address: Optional[EmailStr]
|
|
verified: bool = False
|
|
|
|
|
|
class Mobile(BaseModel):
|
|
number: Optional[str]
|
|
verified: bool
|
|
|
|
|
|
class FLID(BaseModel):
|
|
identity: str
|
|
set_by: str
|
|
create_time: datetime
|
|
update_time: datetime
|
|
|
|
|
|
class Password(BaseModel):
|
|
set_up: bool
|
|
update_time: datetime
|
|
expiry: datetime
|
|
|
|
|
|
class BasicProfileDoc(Document):
|
|
user_id: str
|
|
first_name: Indexed(str) = "" # type: ignore
|
|
last_name: Indexed(str) = "" # type: ignore Index for faster search
|
|
spoken_language: List[str] = []
|
|
self_intro: SelfIntro
|
|
photo: Photo
|
|
photo_id: Optional[str] = None
|
|
email: Email
|
|
mobile: Mobile
|
|
FLID: FLID
|
|
password: Password
|
|
region: int = UserRegion.OTHER
|
|
time_zone: Optional[str] = None
|
|
|
|
class Settings:
|
|
name = "basic_profile"
|
|
indexes = [
|
|
"user_id", # Add index for fast querying by user_id
|
|
"email.address", # This adds an index for the 'email.address' field
|
|
# Compound text index for fuzzy search across multiple fields
|
|
[("first_name", "text"), ("last_name", "text"), ("email.address", "text")],
|
|
]
|