Files
shanxia2.0/backend/app/schemas/duty.py
T
2026-08-16 14:58:19 +08:00

39 lines
884 B
Python

"""值班排班 Pydantic schemas"""
from __future__ import annotations
from datetime import date
from typing import List, Literal, Optional
from pydantic import BaseModel, Field
ShiftType = Literal["morning", "evening", "duty"]
LinkStatus = Literal["open", "closed"]
SourceType = Literal["assign", "grab"]
class DutyAssignmentIn(BaseModel):
source: SourceType = "assign"
userId: Optional[str] = None
personName: str = ""
class DutySlotSaveIn(BaseModel):
shiftType: ShiftType
capacity: int = Field(ge=1, le=99)
assignments: List[DutyAssignmentIn] = []
class DutyDaySaveBody(BaseModel):
dutyDate: date
slots: List[DutySlotSaveIn]
linkStatus: Optional[LinkStatus] = None
class DutyLinkBody(BaseModel):
linkStatus: LinkStatus
class DutyGrabBody(BaseModel):
shiftType: ShiftType
userId: str = Field(min_length=1, max_length=64)