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.

166 lines
4.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
9 months ago
9 months ago
9 months ago
8 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
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. id:Annotated[int,Field(
  34. title="标签id",
  35. description="主键自增"
  36. )]
  37. labelname:Annotated[str,Field(
  38. title="标签名称",
  39. description="名称不允许为空"
  40. )]
  41. descr:Annotated[str,Field(
  42. title="备注",
  43. default=None,
  44. description="备注允许为空"
  45. )]
  46. class Blog(BaseModel):
  47. blogtitle:Annotated[str,Field(
  48. title="博客标题",
  49. pattern=r'^.{4,20}$',
  50. examples=[""],
  51. description="允许6-20个字符"
  52. )]
  53. blogcontent:Annotated[str,Field(
  54. title="博客内容",
  55. min_length=1,
  56. description="最少1个字符"
  57. )]
  58. imglink:Annotated[str,Field(
  59. title="文图地址",
  60. )]
  61. typeid:Annotated[int,Field(
  62. title="类型id",
  63. default=None,
  64. description="类型id允许为空"
  65. )]
  66. descr:Annotated[str,Field(
  67. title="备注",
  68. default=None,
  69. description="备注允许为空"
  70. )]
  71. class Diary(BaseModel):
  72. diarytitle:Annotated[str,Field(
  73. title="日记标题",
  74. pattern=r'^.{4,20}$',
  75. examples=[""],
  76. description="允许6-20个字符"
  77. )]
  78. diarycontent:Annotated[str,Field(
  79. title="日记内容",
  80. min_length=1,
  81. description="最少1个字符"
  82. )]
  83. imglink:Annotated[str,Field(
  84. title="文图地址",
  85. )]
  86. typeid:Annotated[int,Field(
  87. title="类型id",
  88. default=None,
  89. description="类型id允许为空"
  90. )]
  91. descr:Annotated[str,Field(
  92. title="备注",
  93. default=None,
  94. description="备注允许为空"
  95. )]
  96. class Classtic(BaseModel):
  97. header:Annotated[str,Field(
  98. title="语录名称",
  99. description="语录名称不允许为空"
  100. )]
  101. text:Annotated[str,Field(
  102. title="语录内容",
  103. description="语录内容不允许为空"
  104. )]
  105. descr:Annotated[str,Field(
  106. title="备注",
  107. default=None,
  108. description="备注允许为空"
  109. )]
  110. class ComLink(BaseModel):
  111. linktext:Annotated[str,Field(
  112. title="链接名称",
  113. description="名称不允许为空"
  114. )]
  115. linkurl:Annotated[str,Field(
  116. title="链接地址",
  117. description="地址不允许为空"
  118. )]
  119. descr:Annotated[str,Field(
  120. title="备注",
  121. default=None,
  122. description="备注允许为空"
  123. )]
  124. class Type(BaseModel):
  125. typename:Annotated[str,Field(
  126. title="类型名称",
  127. description="名称不允许为空"
  128. )]
  129. descr:Annotated[str,Field(
  130. title="备注",
  131. default=None,
  132. description="备注允许为空"
  133. )]
  134. class Expense(BaseModel):
  135. pay_price:Annotated[Decimal,Field(
  136. title="支出",
  137. default=0.00,
  138. description="支出不允许为空"
  139. )]
  140. live_price:Annotated[Decimal,Field(
  141. title="收入",
  142. default=0.00,
  143. description="收入不允许为空"
  144. )]
  145. typeid:Annotated[int,Field(
  146. title="类型id",
  147. default=None,
  148. description="类型id允许为空"
  149. )]
  150. descr:Annotated[str,Field(
  151. title="备注",
  152. default=None,
  153. description="备注允许为空"
  154. )]