Coverage for src / mysingle / auth / schemas / user.py: 0%
49 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-02 00:58 +0900
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-02 00:58 +0900
1from datetime import datetime
3from beanie import PydanticObjectId
4from pydantic import BaseModel, ConfigDict, EmailStr, Field
6from ...base.schemas import BaseResponseSchema
9class UserResponse(BaseResponseSchema):
10 """Base User model."""
12 email: EmailStr
13 full_name: str | None = None
14 is_active: bool = True
15 is_superuser: bool = False
16 is_verified: bool = False
17 avatar_url: str | None = None
18 oauth_accounts: list["OAuthAccountResponse"] = Field(default_factory=list)
20 # 활동 기록 필드
21 last_login_at: datetime | None = None
22 last_activity_at: datetime | None = None
23 login_count: int = 0
24 last_login_ip: str | None = None
25 last_activity_ip: str | None = None
27 model_config = ConfigDict(
28 from_attributes=True,
29 json_schema_extra={
30 "example": {
31 "_id": "string",
32 "email": "user@example.com",
33 "full_name": "string",
34 "is_active": True,
35 "is_superuser": False,
36 "is_verified": False,
37 "avatar_url": "string",
38 "oauth_accounts": [
39 {
40 "oauth_name": "string",
41 "account_id": "string",
42 "account_email": "user@example.com",
43 }
44 ],
45 }
46 },
47 )
50class UserCreate(BaseModel):
51 email: EmailStr
52 full_name: str | None = None
53 password: str
54 is_active: bool | None = True
55 is_superuser: bool | None = False
56 is_verified: bool | None = False
57 avatar_url: str | None = None
59 model_config = ConfigDict(
60 json_schema_extra={
61 "example": {
62 "email": "user@example.com",
63 "full_name": "string",
64 "password": "string",
65 "is_active": True,
66 "is_superuser": False,
67 "is_verified": False,
68 "avatar_url": "string",
69 }
70 }
71 )
74class UserUpdate(BaseModel):
75 password: str | None = None
76 email: EmailStr | None = None
77 full_name: str | None = None
78 is_active: bool | None = None
79 is_superuser: bool | None = None
80 is_verified: bool | None = None
81 avatar_url: str | None = None
83 model_config = ConfigDict(
84 json_schema_extra={
85 "example": {
86 "email": "user@example.com",
87 "full_name": "string",
88 "password": "string",
89 "is_active": True,
90 "is_superuser": False,
91 "is_verified": False,
92 "avatar_url": "string",
93 }
94 }
95 )
98class OAuthAccountResponse(BaseModel):
99 """Base OAuth account model."""
101 oauth_name: str
102 account_id: str
103 account_email: str
105 model_config = ConfigDict(
106 from_attributes=True,
107 json_schema_extra={
108 "example": {
109 "_id": "string",
110 "oauth_name": "string",
111 "account_id": "string",
112 "account_email": "user@example.com",
113 }
114 },
115 )
118class UserInfo(BaseModel):
119 id: PydanticObjectId = Field(..., alias="_id")
120 email: str
121 avatar_url: str | None = None
122 full_name: str | None = None
123 is_active: bool = True
124 is_superuser: bool = False
125 is_verified: bool = False