123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from typing import List, Optional
- from pydantic import Field
- from pydantic.main import BaseModel
- from schemas.base import ListMixin, Datetime2Str, DetailMixin
- class Operator(BaseModel):
- creator_id: int = Field(None, description="创建人ID,前端忽略,后端处理")
- creator_name: str = Field(None, description="创建人姓名,前端忽略,后端处理")
- editor_id: int = Field(None, description="最后编辑人ID,前端忽略,后端处理")
- editor_name: str = Field(None, description="最后编辑人姓名,前端忽略,后端处理")
- class ResourceBase(BaseModel):
- category_id: int = Field(None, alias="ctgid", description="资源分类ID")
- name: str = Field(None, description="资源名称")
- area: str = Field(None, description="省份")
- year: int = Field(None, description="年份")
- visit: int = Field(None, description="浏览量")
- collect: int = Field(None, description="收藏量")
- download: int = Field(None, description="下载量")
- attach_url: List[str] = Field(None, description="资源文件URL")
- class Config:
- orm_mode = True
- anystr_strip_whitespace = True
- class ResourceItem(ResourceBase):
- id: int = Field(..., description="资源ID")
- ctgid: Optional[int] = Field(None,
- alias="category_id",
- description="资源分类ID")
- rtype: Optional[str] = Field(None, description="作业资源类型")
- sid: Optional[int] = Field(None, alias="school_id", description="学校ID")
- sname: Optional[str] = Field(None, alias="school_name", description="学校名称")
- hot: Optional[bool] = Field(None, description="是否热点资源")
- isnew: Optional[bool] = Field(None, description="是否最新,客户端专用")
- created_at: Optional[Datetime2Str] = None
- class ResourceList(ListMixin):
- data: List[ResourceItem] = []
- class ResourceDetail(DetailMixin):
- data: Optional[ResourceItem] = None
- class NewResource(ResourceBase, Operator):
- ctype: str = Field(..., description="分类类型")
- school_id: Optional[int] = Field(None,
- alias="sid",
- description="学校ID,创建考试资源时传此参数")
- school_name: Optional[str] = Field(None, description="学校名称,后端处理,前端忽略")
- hot: Optional[bool] = Field(None, description="热点资源,创建考试资源时传此参数")
- class UpdateResource(BaseModel):
- ctype: str = Field(..., description="分类类型")
- category_id: Optional[int] = Field(None,
- alias="ctgid",
- description="资源分类ID")
- name: Optional[str] = Field(None, description="资源名称")
- area: Optional[str] = Field(None, description="省份")
- year: Optional[int] = Field(None, description="年份")
- visit: Optional[int] = Field(None, description="浏览量")
- collect: Optional[int] = Field(None, description="收藏量")
- download: Optional[int] = Field(None, description="下载量")
- attach_url: Optional[List[str]] = Field(None, description="资源文件URL")
- editor_id: int = Field(None, description="最后编辑人ID,后端处理,前端忽略")
- editor_name: str = Field(None, description="最后编辑人姓名,后端处理,前端忽略")
- rtype: Optional[str] = Field(None, description="作业资源类型,创建作业资源时传此参数")
- school_id: Optional[int] = Field(None,
- alias="sid",
- description="学校ID,创建考试资源时传此参数")
- school_name: Optional[str] = Field(None, description="学校名称,后端处理,前端忽略")
- hot: Optional[bool] = Field(None, description="热点资源,创建考试资源时传此参数")
- class Config:
- anystr_strip_whitespace = True
|