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.

202 lines
5.1 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
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 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. parent_id:Annotated[int,Field(
  122. title="父级评论id",
  123. description="父级评论允许为空"
  124. )]=None
  125. blog_id:Annotated[int,Field(
  126. title="博客id",
  127. description="博客id允许为空"
  128. )]
  129. commentname:Annotated[str,Field(
  130. title="评论用户",
  131. description="评论用户不允许为空"
  132. )]
  133. email:Annotated[str,Field(
  134. title="评论用户邮箱",
  135. description="评论用户邮箱不允许为空"
  136. )]
  137. commenturl:Annotated[str,Field(
  138. title="评论地址",
  139. description="评论地址不允许为空"
  140. )]
  141. commentcontent:Annotated[str,Field(
  142. title="评论内容",
  143. description="评论内容不允许为空"
  144. )]
  145. class ComLink(BaseModel):
  146. linktext:Annotated[str,Field(
  147. title="链接名称",
  148. description="名称不允许为空"
  149. )]
  150. linkurl:Annotated[str,Field(
  151. title="链接地址",
  152. description="地址不允许为空"
  153. )]
  154. descr:Annotated[str,Field(
  155. title="备注",
  156. default=None,
  157. description="备注允许为空"
  158. )]
  159. class Type(BaseModel):
  160. typename:Annotated[str,Field(
  161. title="类型名称",
  162. description="名称不允许为空"
  163. )]
  164. descr:Annotated[str,Field(
  165. title="备注",
  166. default=None,
  167. description="备注允许为空"
  168. )]
  169. class Expense(BaseModel):
  170. pay_price:Annotated[Decimal,Field(
  171. title="支出",
  172. default=0.00,
  173. description="支出不允许为空"
  174. )]
  175. live_price:Annotated[Decimal,Field(
  176. title="收入",
  177. default=0.00,
  178. description="收入不允许为空"
  179. )]
  180. typeid:Annotated[int,Field(
  181. title="类型id",
  182. default=None,
  183. description="类型id允许为空"
  184. )]
  185. descr:Annotated[str,Field(
  186. title="备注",
  187. default=None,
  188. description="备注允许为空"
  189. )]