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.

199 lines
5.0 KiB

11 months ago
8 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
7 months ago
9 months ago
11 months ago
9 months ago
11 months ago
9 months ago
10 months ago
9 months ago
8 months ago
  1. from pydantic import BaseModel,Field
  2. from typing import Annotated
  3. from decimal import Decimal
  4. # Token相关的模型
  5. class Token(BaseModel):
  6. access_token: str
  7. token_type: str
  8. class TokenData(BaseModel):
  9. username: str = None
  10. # User相关的模型
  11. class User(BaseModel):
  12. username: Annotated[str,Field(
  13. title="用户",
  14. examples=["admin"],
  15. pattern=r'^.{4,20}$',
  16. description="允许4-20的字符"
  17. )]
  18. email: Annotated[str,Field(
  19. examples=["examples@example.com"],
  20. max_length=50,
  21. pattern=r'^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$',
  22. description="邮箱需要满足正则标准"
  23. )]
  24. full_name: Annotated[str,Field(
  25. examples=["admin"],
  26. pattern=r'^.{2,20}$',
  27. description="允许2-20个字符"
  28. )]
  29. disabled: bool = True
  30. class UserInDB(User):
  31. hashed_password: str = None
  32. class Label(BaseModel):
  33. labelname:Annotated[str,Field(
  34. title="标签名称",
  35. description="名称不允许为空"
  36. )]
  37. descr:Annotated[str,Field(
  38. title="备注",
  39. default=None,
  40. description="备注允许为空"
  41. )]
  42. class MoreLable(Label):
  43. id:Annotated[int,Field(
  44. title="标签id",
  45. description="主键自增"
  46. )]
  47. labelname:Annotated[str,Field(
  48. title="标签名称",
  49. description="名称不允许为空"
  50. )]
  51. descr:Annotated[str,Field(
  52. title="备注",
  53. default=None,
  54. description="备注允许为空"
  55. )]
  56. class Blog(BaseModel):
  57. blogtitle:Annotated[str,Field(
  58. title="博客标题",
  59. pattern=r'^.{4,20}$',
  60. examples=[""],
  61. description="允许6-20个字符"
  62. )]
  63. blogcontent:Annotated[str,Field(
  64. title="博客内容",
  65. min_length=1,
  66. description="最少1个字符"
  67. )]
  68. imglink:Annotated[str,Field(
  69. title="文图地址",
  70. )]
  71. typeid:Annotated[int,Field(
  72. title="类型id",
  73. default=None,
  74. description="类型id允许为空"
  75. )]
  76. descr:Annotated[str,Field(
  77. title="备注",
  78. default=None,
  79. description="备注允许为空"
  80. )]
  81. class Diary(BaseModel):
  82. diarytitle:Annotated[str,Field(
  83. title="日记标题",
  84. pattern=r'^.{4,20}$',
  85. examples=[""],
  86. description="允许6-20个字符"
  87. )]
  88. diarycontent:Annotated[str,Field(
  89. title="日记内容",
  90. min_length=1,
  91. description="最少1个字符"
  92. )]
  93. imglink:Annotated[str,Field(
  94. title="文图地址",
  95. )]
  96. typeid:Annotated[int,Field(
  97. title="类型id",
  98. default=None,
  99. description="类型id允许为空"
  100. )]
  101. descr:Annotated[str,Field(
  102. title="备注",
  103. default=None,
  104. description="备注允许为空"
  105. )]
  106. class Classtic(BaseModel):
  107. header:Annotated[str,Field(
  108. title="语录名称",
  109. description="语录名称不允许为空"
  110. )]
  111. text:Annotated[str,Field(
  112. title="语录内容",
  113. description="语录内容不允许为空"
  114. )]
  115. descr:Annotated[str,Field(
  116. title="备注",
  117. default=None,
  118. description="备注允许为空"
  119. )]
  120. class Comment(BaseModel):
  121. blog_id:Annotated[int,Field(
  122. title="博客id",
  123. default=None,
  124. description="博客id允许为空"
  125. )]
  126. commentname:Annotated[str,Field(
  127. title="评论用户",
  128. description="评论用户不允许为空"
  129. )]
  130. email:Annotated[str,Field(
  131. title="评论用户邮箱",
  132. description="评论用户邮箱不允许为空"
  133. )]
  134. commenturl:Annotated[str,Field(
  135. title="评论地址",
  136. description="评论地址不允许为空"
  137. )]
  138. commentcontent:Annotated[str,Field(
  139. title="评论内容",
  140. description="评论内容不允许为空"
  141. )]
  142. class ComLink(BaseModel):
  143. linktext:Annotated[str,Field(
  144. title="链接名称",
  145. description="名称不允许为空"
  146. )]
  147. linkurl:Annotated[str,Field(
  148. title="链接地址",
  149. description="地址不允许为空"
  150. )]
  151. descr:Annotated[str,Field(
  152. title="备注",
  153. default=None,
  154. description="备注允许为空"
  155. )]
  156. class Type(BaseModel):
  157. typename:Annotated[str,Field(
  158. title="类型名称",
  159. description="名称不允许为空"
  160. )]
  161. descr:Annotated[str,Field(
  162. title="备注",
  163. default=None,
  164. description="备注允许为空"
  165. )]
  166. class Expense(BaseModel):
  167. pay_price:Annotated[Decimal,Field(
  168. title="支出",
  169. default=0.00,
  170. description="支出不允许为空"
  171. )]
  172. live_price:Annotated[Decimal,Field(
  173. title="收入",
  174. default=0.00,
  175. description="收入不允许为空"
  176. )]
  177. typeid:Annotated[int,Field(
  178. title="类型id",
  179. default=None,
  180. description="类型id允许为空"
  181. )]
  182. descr:Annotated[str,Field(
  183. title="备注",
  184. default=None,
  185. description="备注允许为空"
  186. )]