region.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from typing import Optional, List
  4. from pydantic import BaseModel
  5. from schemas.base import ListMixin
  6. # class CreateRegion(BaseModel):
  7. # code: str = Field(..., max_length=20, description="区域编号")
  8. # name: str = Field(..., max_length=40, description="区域名称")
  9. # pcode: str = Field(default="0", description="上级区域编码")
  10. # shortname: str = Field(max_length=40, default="", description="区域简称")
  11. # level: int = Field(
  12. # ...,
  13. # ge=1,
  14. # le=5,
  15. # description="地区级别,1:省/直辖市/自治区,2:地级市/地区/自治州/盟,3:市辖区/县级市/县,4:乡/镇,5:村")
  16. # citycode: str = Field(max_length=20, default="", description="区号")
  17. # zipcode: str = Field(max_length=20, default="", description="区号")
  18. # mergename: str = Field(max_length=100, default="", description="区号")
  19. # lng: float = Field(default=0, description="经度")
  20. # lat: float = Field(default=0, description="纬度")
  21. # pyname: str = Field(max_length=100, default="", description="拼音名称")
  22. # creator: int = Field(..., description="创建人")
  23. #
  24. #
  25. # class UpdateRegion(BaseModel):
  26. # code: str = Field(..., max_length=20, description="区域编号")
  27. # name: str = Field(..., max_length=40, description="区域名称")
  28. # pcode: str = Field(default="0", description="上级区域编码")
  29. # shortname: str = Field(max_length=40, default="", description="区域简称")
  30. # level: int = Field(
  31. # ...,
  32. # ge=1,
  33. # le=5,
  34. # description="地区级别,1:省/直辖市/自治区,2:地级市/地区/自治州/盟,3:市辖区/县级市/县,4:乡/镇,5:村")
  35. # citycode: str = Field(max_length=20, default="", description="区号")
  36. # zipcode: str = Field(max_length=20, default="", description="区号")
  37. # mergename: str = Field(max_length=100, default="", description="区号")
  38. # lng: float = Field(default=0, description="经度")
  39. # lat: float = Field(default=0, description="纬度")
  40. # pyname: str = Field(max_length=100, default="", description="拼音名称")
  41. # creator: int = Field(..., description="创建人")
  42. class RegionItem(BaseModel):
  43. id: int
  44. code: str
  45. name: str
  46. class Config:
  47. orm_mode = True
  48. class RegionInfo(RegionItem):
  49. pcode: str
  50. shortname: Optional[str] = ""
  51. level: int
  52. citycode: Optional[str] = ""
  53. zipcode: Optional[str] = ""
  54. mergename: Optional[str] = ""
  55. lng: Optional[float] = 0
  56. lat: Optional[float] = 0
  57. pyname: Optional[str] = ""
  58. # class RegionInfoAll(RegionInfo):
  59. # parent: Optional[RegionItem] = None
  60. class RegionList(ListMixin):
  61. data: List[RegionInfo] = []
  62. class RegionItemList(ListMixin):
  63. data: List[RegionItem] = []
  64. # class RegionDetail(DetailMixin):
  65. # data: Optional[RegionInfoAll] = None