29 lines
708 B
Python
29 lines
708 B
Python
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
UnitCategory = Literal["company", "department"]
|
|
|
|
|
|
class UnitCreate(BaseModel):
|
|
name: str = Field(min_length=1, max_length=120)
|
|
description: str | None = None
|
|
parent_id: int | None = None
|
|
category: UnitCategory = "company"
|
|
|
|
|
|
class UnitUpdate(BaseModel):
|
|
name: str | None = Field(default=None, min_length=1, max_length=120)
|
|
description: str | None = None
|
|
parent_id: int | None = None
|
|
category: UnitCategory | None = None
|
|
|
|
|
|
class UnitResponse(BaseModel):
|
|
id: int
|
|
name: str
|
|
description: str | None = None
|
|
parent_id: int | None = None
|
|
category: UnitCategory = "company"
|
|
user_count: int = 0
|