12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from typing import List, Optional, Any
- from pydantic import Field
- from pydantic.main import BaseModel
- from schemas.base import ListMixin, DetailMixin
- class SearchItem(BaseModel):
- id: Optional[int] = None
- name: str = Field(..., description="名称")
- class PeriodList(ListMixin):
- data: List[SearchItem] = []
- class SubjectList(ListMixin):
- data: List[SearchItem] = []
- class WorkTypeList(ListMixin):
- data: List[SearchItem] = []
- class Category(BaseModel):
- id: Optional[int] = None
- name: Optional[str] = None
- pid: Optional[int] = None
- pname: Optional[str] = None
- period: Optional[str] = None
- subject: Optional[str] = None
- children: Optional[Any] = None
- class Config:
- orm_mode = True
- class CategoryTree(Category):
- children: List[Category]
- class CategoryList(ListMixin):
- data: List[CategoryTree] = []
- class CategoryDetail(DetailMixin):
- data: Optional[Category] = None
- class UpdateCategory(BaseModel):
- ctype: str = Field(..., description="分类类型")
- name: Optional[str] = Field(None, description="分类名称")
- pid: Optional[int] = Field(None, description="上级分类ID")
- pname: Optional[str] = Field(None, description="上级分类名称")
- period: Optional[str] = Field(None, description="学段名称")
- subject: Optional[str] = Field(None, description="学科")
- class NewCategory(BaseModel):
- ctype: str = Field(..., description="分类类型")
- name: str = Field(..., description="分类名称")
- pid: int = Field(0, description="上级分类ID")
- pname: str = Field(None, description="上级分类名称,前端忽略,后端处理")
- period: str = Field(..., description="学段名称")
- subject: str = Field(..., description="学科")
|