40 lines
948 B
Python
40 lines
948 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)
|
|
remark: Optional[str] = Field(default=None, max_length=500)
|
|
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)
|