78 lines
1.5 KiB
Python
78 lines
1.5 KiB
Python
from pydantic import BaseModel, EmailStr, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
class UserRegister(BaseModel):
|
|
username: str = Field(..., min_length=3, max_length=50)
|
|
email: EmailStr
|
|
password: str = Field(..., min_length=6)
|
|
|
|
|
|
class UserLogin(BaseModel):
|
|
username: str
|
|
password: str
|
|
|
|
|
|
class UserResponse(BaseModel):
|
|
id: int
|
|
username: str
|
|
email: str
|
|
created_at: datetime
|
|
|
|
|
|
class Token(BaseModel):
|
|
access_token: str
|
|
token_type: str = "bearer"
|
|
user: UserResponse
|
|
|
|
|
|
class SectionCreate(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
|
|
|
|
class SectionResponse(BaseModel):
|
|
id: int
|
|
name: str
|
|
display_order: int
|
|
apps: list = []
|
|
|
|
|
|
class AppCreate(BaseModel):
|
|
section_id: int
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
url: str
|
|
icon: Optional[str] = None
|
|
description: Optional[str] = None
|
|
|
|
|
|
class AppUpdate(BaseModel):
|
|
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
url: Optional[str] = None
|
|
icon: Optional[str] = None
|
|
description: Optional[str] = None
|
|
section_id: Optional[int] = None
|
|
|
|
|
|
class AppResponse(BaseModel):
|
|
id: int
|
|
section_id: int
|
|
name: str
|
|
url: str
|
|
icon: Optional[str]
|
|
description: Optional[str]
|
|
display_order: int
|
|
|
|
|
|
class AppData(BaseModel):
|
|
name: str
|
|
icon: str
|
|
description: str
|
|
url: str
|
|
|
|
|
|
class AppEntry(BaseModel):
|
|
section: str
|
|
app: AppData
|
|
original_name: str | None = None
|