You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.9 KiB

11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
10 months ago
9 months ago
  1. from pydantic import BaseModel,Field
  2. from typing import Annotated
  3. # Token相关的模型
  4. class Token(BaseModel):
  5. access_token: str
  6. token_type: str
  7. class TokenData(BaseModel):
  8. username: str = None
  9. # User相关的模型
  10. class User(BaseModel):
  11. username: Annotated[str,Field(
  12. title="用户",
  13. examples=["admin"],
  14. pattern=r'^.{4,20}$',
  15. description="允许4-20的字符"
  16. )]
  17. email: Annotated[str,Field(
  18. examples=["examples@example.com"],
  19. max_length=50,
  20. pattern=r'^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$',
  21. description="邮箱需要满足正则标准"
  22. )]
  23. full_name: Annotated[str,Field(
  24. examples=["admin"],
  25. pattern=r'^.{2,20}$',
  26. description="允许2-20个字符"
  27. )]
  28. disabled: bool = True
  29. class UserInDB(User):
  30. hashed_password: str = None
  31. class Label(BaseModel):
  32. id:Annotated[int,Field(
  33. title="标签id",
  34. description="主键自增"
  35. )]
  36. labelname:Annotated[str,Field(
  37. title="标签名称",
  38. description="名称不允许为空"
  39. )]
  40. descr:Annotated[str,Field(
  41. title="备注",
  42. default=None,
  43. description="备注允许为空"
  44. )]
  45. class Blog(BaseModel):
  46. blogtitle:Annotated[str,Field(
  47. title="博客标题",
  48. pattern=r'^.{4,20}$',
  49. examples=[""],
  50. description="允许6-20个字符"
  51. )]
  52. blogcontent:Annotated[str,Field(
  53. title="博客内容",
  54. min_length=1,
  55. description="最少1个字符"
  56. )]
  57. imglink:Annotated[str,Field(
  58. title="文图地址",
  59. )]
  60. typeid:Annotated[int,Field(
  61. title="类型id",
  62. default=None,
  63. description="类型id允许为空"
  64. )]
  65. descr:Annotated[str,Field(
  66. title="备注",
  67. default=None,
  68. description="备注允许为空"
  69. )]
  70. class Classtic(BaseModel):
  71. header:Annotated[str,Field(
  72. title="语录名称",
  73. description="语录名称不允许为空"
  74. )]
  75. text:Annotated[str,Field(
  76. title="语录内容",
  77. description="语录内容不允许为空"
  78. )]
  79. descr:Annotated[str,Field(
  80. title="备注",
  81. default=None,
  82. description="备注允许为空"
  83. )]
  84. class ComLink(BaseModel):
  85. linktext:Annotated[str,Field(
  86. title="链接名称",
  87. description="名称不允许为空"
  88. )]
  89. linkurl:Annotated[str,Field(
  90. title="链接地址",
  91. description="地址不允许为空"
  92. )]
  93. descr:Annotated[str,Field(
  94. title="备注",
  95. default=None,
  96. description="备注允许为空"
  97. )]
  98. class Type(BaseModel):
  99. typename:Annotated[str,Field(
  100. title="类型名称",
  101. description="名称不允许为空"
  102. )]
  103. descr:Annotated[str,Field(
  104. title="备注",
  105. default=None,
  106. description="备注允许为空"
  107. )]