123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from typing import List, Optional, Dict, Union, Any
- from pydantic import BaseModel, Field
- from schemas.base import ListMixin, DetailMixin, Str2List, Datetime2Str
- class PaperBaseItem(BaseModel):
- id: int
- name: str
- pno: str
- pages: int
- score: int
- uploaded: bool
- cut: bool
- attached: bool
- creator_name: str
- points: List[Any] = None
- created_at: Datetime2Str
- class Config:
- orm_mode = True
- class PaperList(ListMixin):
- data: List[PaperBaseItem] = []
- class PaperItem4Detail(PaperBaseItem):
- imgs: Str2List
- attach_url: str
- questions: Optional[List[Any]] = []
- class PaperDetail(DetailMixin):
- data: Union[Dict[str, Any], PaperItem4Detail] = None
- class NewPaperInfo(BaseModel):
- name: str = Field(..., min_length=1, max_length=255, description="试卷名称")
- pno: str = Field(..., min_length=1, max_length=32, description="试卷编号")
- pages: int = Field(..., gt=0, description="试卷页数")
- ctgid: int = Field(..., description="试卷分类ID")
- imgs: Optional[List[str]] = Field(None, description="试卷图片")
- attachments: Optional[List[str]] = Field(None, description="电子卷附件")
- class PaperInDB(BaseModel):
- category_id: int = Field(..., alias="ctgid")
- name: str
- pno: str
- pages: int
- imgs: str = ""
- uploaded: bool = False
- points: str = ""
- attach_url: str = ""
- attached: bool = False
- cut: bool = False
- score: int = 100
- creator_id: int
- creator_name: str
- editor_id: int
- editor_name: str
- class Config:
- anystr_strip_whitespace = True
- class UpdatePaperInfo(BaseModel):
- category_id: Optional[int] = Field(None, alias="ctgid")
- name: Optional[str] = None
- pages: Optional[int] = None
- imgs: Optional[List[str]] = None
- uploaded: Optional[bool] = None
- points: Optional[str] = None
- attachments: Optional[List[str]] = None
- attached: Optional[bool] = None
- cut: Optional[bool] = None
- score: Optional[int] = None
- class Config:
- anystr_strip_whitespace = True
- class UpdatePaper(UpdatePaperInfo):
- imgs: Optional[str] = None
- attach_url: Optional[str] = None
- editor_id: int
- editor_name: str
- class Config:
- anystr_strip_whitespace = True
|