180 lines
3.6 KiB
Python
180 lines
3.6 KiB
Python
"""Reference data schemas."""
|
|
|
|
from pydantic import BaseModel, Field
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
|
|
|
|
class RoleBase(BaseModel):
|
|
"""Role base schema."""
|
|
name: str = Field(..., min_length=1, max_length=50)
|
|
description: Optional[str] = None
|
|
|
|
|
|
class RoleCreate(RoleBase):
|
|
"""Role creation schema."""
|
|
pass
|
|
|
|
|
|
class RoleResponse(RoleBase):
|
|
"""Role response schema."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class StatusBase(BaseModel):
|
|
"""Status base schema."""
|
|
name: str = Field(..., min_length=1, max_length=50)
|
|
is_final: bool = False
|
|
|
|
|
|
class StatusCreate(StatusBase):
|
|
"""Status creation schema."""
|
|
pass
|
|
|
|
|
|
class StatusResponse(StatusBase):
|
|
"""Status response schema."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class PriorityBase(BaseModel):
|
|
"""Priority base schema."""
|
|
name: str = Field(..., min_length=1, max_length=50)
|
|
level: int = Field(..., ge=1, le=10)
|
|
default_response_time_minutes: int = Field(60, ge=1)
|
|
|
|
|
|
class PriorityCreate(PriorityBase):
|
|
"""Priority creation schema."""
|
|
pass
|
|
|
|
|
|
class PriorityResponse(PriorityBase):
|
|
"""Priority response schema."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class CategoryBase(BaseModel):
|
|
"""Category base schema."""
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
parent_id: Optional[int] = None
|
|
|
|
|
|
class CategoryCreate(CategoryBase):
|
|
"""Category creation schema."""
|
|
pass
|
|
|
|
|
|
class CategoryResponse(CategoryBase):
|
|
"""Category response schema."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class CompanyBase(BaseModel):
|
|
"""Company base schema."""
|
|
name: str = Field(..., min_length=1, max_length=255)
|
|
address: Optional[str] = None
|
|
phone: Optional[str] = None
|
|
website: Optional[str] = None
|
|
|
|
|
|
class CompanyCreate(CompanyBase):
|
|
"""Company creation schema."""
|
|
pass
|
|
|
|
|
|
class CompanyResponse(CompanyBase):
|
|
"""Company response schema."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class LocationBase(BaseModel):
|
|
"""Location base schema."""
|
|
name: str = Field(..., min_length=1, max_length=255)
|
|
address: Optional[str] = None
|
|
phone: Optional[str] = None
|
|
|
|
|
|
class LocationCreate(LocationBase):
|
|
"""Location creation schema."""
|
|
pass
|
|
|
|
|
|
class LocationResponse(LocationBase):
|
|
"""Location response schema."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class DepartmentBase(BaseModel):
|
|
"""Department base schema."""
|
|
name: str = Field(..., min_length=1, max_length=255)
|
|
|
|
|
|
class DepartmentCreate(DepartmentBase):
|
|
"""Department creation schema."""
|
|
pass
|
|
|
|
|
|
class DepartmentResponse(DepartmentBase):
|
|
"""Department response schema."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class NotificationResponse(BaseModel):
|
|
"""Notification response schema."""
|
|
id: int
|
|
user_id: int
|
|
ticket_id: Optional[int]
|
|
type: str
|
|
title: str
|
|
message: str
|
|
is_read: int
|
|
is_delivered: int
|
|
sent_at: Optional[datetime]
|
|
created_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class NotificationListResponse(BaseModel):
|
|
"""Notification list response schema."""
|
|
notifications: List[NotificationResponse]
|
|
total: int
|
|
unread_count: int
|