refactor: improve code structure and optimize key functions
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Literal, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class UserBase(BaseModel):
|
||||
username: str = Field(min_length=1)
|
||||
role: Literal["PM", "CRA", "PV", "IMP"]
|
||||
is_active: bool = True
|
||||
|
||||
|
||||
class UserCreate(UserBase):
|
||||
password: str = Field(min_length=1)
|
||||
|
||||
|
||||
class UserRead(UserBase):
|
||||
id: uuid.UUID
|
||||
created_at: datetime
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class UserInDB(UserBase):
|
||||
id: uuid.UUID
|
||||
hashed_password: str
|
||||
created_at: datetime
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class Token(BaseModel):
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
|
||||
|
||||
class TokenPayload(BaseModel):
|
||||
sub: uuid.UUID
|
||||
role: str
|
||||
exp: Optional[int] = None
|
||||
Reference in New Issue
Block a user