This commit is contained in:
2026-07-16 16:57:04 +03:00
parent 3c8d2dd572
commit f8b6ab1739
6 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
from typing import Annotated
from pydantic import BaseModel, EmailStr, Field
from uuid import UUID
class Base(BaseModel):
pass
class UserCreate(Base):
first_name:Annotated[str, Field(..., max_length=64,description="first name of the user")]
last_name:Annotated[str, Field(...,max_length=64, description="last name of the user")]
middle_name:Annotated[str, Field(...,max_length=64, description="middle name of the user")]
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
plain_password:Annotated[str, Field(...,min_length=8,max_length=72, description="plain password of the user")]
status:Annotated[bool, Field(..., description="status of the user")]
permissions:Annotated[list[str], Field(..., description="permissions of the user")]
permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
class UserOut(Base):
id:Annotated[UUID, Field(..., description="Id of the user")]
first_name:Annotated[str, Field(..., max_length=64,description="first name of the user")]
last_name:Annotated[str, Field(..., max_length=64,description="last name of the user")]
middle_name:Annotated[str, Field(..., max_length=64, description="middle name of the user")]
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
status:Annotated[bool, Field(..., description="status of the user")]
permissions:Annotated[list[str], Field(..., description="permissions of the user")]
permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
model_config = {"from_attributes": True}
class UserUpdate(Base):
first_name:Annotated[str|None, Field(None, max_length=64, description="first name of the user")]
last_name:Annotated[str|None, Field(None, max_length=64,description="last name of the user")]
middle_name:Annotated[str|None, Field(None, max_length=64,description="middle name of the user")]
email:Annotated[EmailStr|None, Field(None, min_length=5, max_length=255, description="email of the user")]
status:Annotated[bool|None, Field(None, description="status of the user")]
permissions:Annotated[list[str]|None, Field(None, description="permissions of the user")]
permission_groups:Annotated[list[str]|None, Field(None, description="permissions groups of the user")]
class Permissions(Base):
id:int
permission_name:Annotated[str, Field(..., max_length=30, description="permission name")]
model_config = {"from_attributes": True}
class PermissionsOut(Base):
permission_name:Annotated[str, Field(..., max_length=30, description="permission name")]
model_config = {"from_attributes": True}