models.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. from tortoise import fields
  2. from tortoise.models import Model
  3. from pydantic import BaseModel
  4. from datetime import datetime
  5. from tortoise import fields
  6. from tortoise.models import Model
  7. from pydantic import BaseModel
  8. from datetime import datetime
  9. class User(Model):
  10. id = fields.IntField(pk=True)
  11. username = fields.CharField(max_length=30, unique=True, description="帳號")
  12. password = fields.CharField(max_length=128, description="密碼")
  13. email = fields.CharField(max_length=128, description="信箱")
  14. points = fields.IntField(description="點數")
  15. is_superuser = fields.IntField(description="超級使用者")
  16. token = fields.CharField(max_length=200)
  17. is_active = fields.IntField(description="是否已認證")
  18. class UserPydantic(BaseModel):
  19. id: int
  20. username: str
  21. password: str
  22. email: str
  23. points: int
  24. is_superuser: int
  25. token: str
  26. # position : str
  27. is_active: int
  28. class Config:
  29. orm_mode = True
  30. #學校
  31. class Schools(Model):
  32. id = fields.IntField(pk=True)
  33. name = fields.CharField(max_length=45, description="學校名稱")
  34. longitude = fields.CharField(max_length=100, description="經度")
  35. latitude = fields.CharField(max_length=100, description="緯度")
  36. address = fields.CharField(max_length=128,description="地址")
  37. update_time = fields.DatetimeField(description="更新時間")
  38. introduction = fields.TextField(description="簡介", null=True)
  39. email = fields.TextField(description="email", null=True)
  40. phone = fields.TextField(description="電話", null=True)
  41. create_user_id = fields.IntField(description="創建使用者ID", null=True)
  42. def show_data(self):
  43. return {
  44. "location_id": self.id,
  45. "location_name": self.name,
  46. "Lng": self.longitude,
  47. "Lat": self.latitude,
  48. "address": self.address,
  49. "update_time":self.update_time,
  50. "school_introduction":self.introduction,
  51. "email":self.email,
  52. "phone":self.phone,
  53. "create_user_id" :self.create_user_id
  54. }
  55. class Group_name(Model):
  56. id = fields.IntField(pk=True)
  57. group_name = fields.CharField(max_length=45, description="學群名稱")
  58. class Class_name(Model):
  59. id = fields.IntField(pk=True)
  60. name = fields.CharField(max_length=45, description="課程名稱")
  61. school_id = fields.IntField(description="學校ID")
  62. category = fields.CharField(max_length=45, description="分類")
  63. introduction = fields.TextField(description="簡介", null=True)
  64. organizer = fields.CharField(max_length=45, description="主辦單位", null=True)
  65. cover_img = fields.CharField(max_length=255, description="封面圖片", null=True)
  66. group_id = fields.IntField(description="學群")
  67. group_sort = fields.CharField(max_length=45, description="學群細分")
  68. special_class_list_name = fields.CharField(max_length=45, description="特殊表格", null=True)
  69. recommend = fields.IntField(description="是否在首頁")
  70. is_inner = fields.IntField(description="是否是內課")
  71. is_check = fields.IntField(description="是否確認")
  72. create_user_id = fields.IntField(description="創建使用者ID", null=True)
  73. def show_data(self):
  74. return {
  75. "class_name_id": self.id,
  76. "name": self.name,
  77. "category": self.category,
  78. "introduction": self.introduction,
  79. "organizer": self.organizer,
  80. "group_id": self.group_id,
  81. "cover_img": self.cover_img,
  82. "group_sort":self.group_sort,
  83. "recommend" : self.recommend,
  84. "is_inner" : self.is_inner,
  85. "is_check" :self.is_check,
  86. "special_class_list_name":self.special_class_list_name,
  87. "create_user_id" :self.create_user_id
  88. }
  89. class Class_list(Model):
  90. id = fields.IntField(pk=True)
  91. name_id = fields.IntField(description="課程名稱ID")
  92. event = fields.CharField(max_length=45, description="場次", null=True)
  93. start_time = fields.DatetimeField(description="開始時間", null=True)
  94. end_time = fields.DatetimeField(description="結束時間", null=True)
  95. contact = fields.CharField(max_length=255, description="聯絡方式", null=True)
  96. lecturer = fields.CharField(max_length=255, description="講師", null=True)
  97. location = fields.CharField(max_length=255, description="地點詳情", null=True)
  98. content = fields.TextField(description="內容", null=True)
  99. URL = fields.TextField(description="連結網址", null=True)
  100. people = fields.CharField(max_length=255, description="對象", null=True)
  101. fee_method = fields.CharField(max_length=255, description="收費方式", null=True)
  102. registration_way = fields.CharField(max_length=255, description="報名方式", null=True)
  103. remark = fields.TextField(description="備註", null=True)
  104. ATM_address = fields.TextField(description="匯款帳號", null=True)
  105. create_user_id = fields.IntField(description="創建使用者ID", null=True)
  106. def show_data(self):
  107. return {
  108. "event_id": self.id,
  109. "name_id": self.name_id,
  110. "event": self.event,
  111. "start_time": self.start_time,
  112. "end_time": self.end_time,
  113. "location": self.location,
  114. "lecturer": self.lecturer,
  115. "contact": self.contact,
  116. "content": self.content,
  117. "URL": self.URL,
  118. "people": self.people,
  119. "fee_method": self.fee_method,
  120. "registration_way": self.registration_way,
  121. "remark": self.remark,
  122. "ATM_address":self.ATM_address,
  123. "create_user_id" :self.create_user_id
  124. }
  125. class Class_detail(Model):
  126. id = fields.IntField(pk=True)
  127. class_list_id = fields.IntField(description="課程場次ID")
  128. start_time = fields.DatetimeField(description="開始時間")
  129. end_time = fields.DatetimeField(description="結束時間")
  130. sessions = fields.IntField(description="堂數")
  131. content = fields.TextField(description="內容", null=True)
  132. class Registration(Model):
  133. id = fields.IntField(pk=True)
  134. event_id = fields.IntField(description="課程ID")
  135. user_id = fields.IntField(description="使用者ID")
  136. reg_confirm = fields.IntField(description="報名確認(1:報名成功 0:單純報名)")
  137. is_del = fields.IntField(description="是否取消(1:yes ,0:no)")
  138. create_time = fields.DatetimeField(description="創建時間")
  139. class News(Model):
  140. id = fields.IntField(pk=True)
  141. title = fields.CharField(max_length=200, description="標題")
  142. category = fields.CharField(max_length=45, description="類別", null=True)
  143. create_time = fields.DatetimeField(description="發布時間")
  144. click_time = fields.IntField(description="點擊次數", null=True)
  145. content = fields.TextField(description="內容", null=True)
  146. files = fields.TextField(description="附加檔案", null=True)
  147. URL = fields.TextField(description="外部連結", null=True)
  148. tags = fields.TextField(description="標籤", null=True)
  149. cover_img = fields.CharField(max_length=255, description="封面圖片", null=True)
  150. class Favorite_course(Model):
  151. id = fields.IntField(pk=True)
  152. user_id = fields.IntField(description="使用者ID")
  153. class_name_id = fields.IntField(description="課程ID")
  154. time_stemp = fields.DatetimeField(description="時間")
  155. class Article_list(Model):
  156. id = fields.IntField(pk=True)
  157. title = fields.CharField(max_length=45, description="標題")
  158. school_id = fields.IntField(description="學校ID", null=True)
  159. group_id = fields.IntField(description="學群", null=True)
  160. group_sort = fields.CharField(max_length=45, description="學群細分", null=True)
  161. create_user_id = fields.IntField(description="創建使用者ID", null=True)
  162. create_time = fields.DatetimeField(description="創建時間", null=True)
  163. latest_update_user_id = fields.IntField(description="最新更新使用者ID", null=True)
  164. latest_update_time = fields.DatetimeField(description="最新更新時間", null=True)
  165. tags = fields.TextField(description="標籤", null=True)
  166. category = fields.CharField(max_length=45, description="類別", null=True)
  167. depiction = fields.TextField(description="文章描述", null=True)
  168. cover_img = fields.TextField( description="封面圖片", null=True)
  169. vedio_url = fields.TextField( description="影片連結", null=True)
  170. click_time = fields.IntField(description="點擊次數", null=True)
  171. content = fields.TextField(description="內容", null=True)
  172. is_del = fields.IntField(description="是否刪除")
  173. files = fields.TextField(description="附件", null=True)
  174. url = fields.TextField(description="文章連結", null=True)
  175. recommend = fields.IntField(description="是否在首頁")
  176. class Online_course(Model):
  177. id = fields.IntField(pk=True)
  178. title = fields.CharField(max_length=45, description="標題")
  179. category = fields.CharField(max_length=45, description="類別", null=True)
  180. create_time = fields.DatetimeField(description="發布時間")
  181. click_time = fields.IntField(description="點擊次數", null=True)
  182. content = fields.TextField(description="發布時間", null=True)
  183. video_url = fields.TextField(description="影片連結")
  184. group_id = fields.IntField(description="學群", null=True)
  185. cover_img = fields.TextField(description="封面圖片", null=True)
  186. def show_data(self):
  187. return {
  188. "id" : self.id,
  189. "title": self.title,
  190. "category": self.category,
  191. "create_time": self.create_time,
  192. "click_time": self.click_time,
  193. "content": self.content,
  194. "video_url": self.video_url,
  195. "group_id": self.group_id,
  196. "cover_img": self.cover_img
  197. }
  198. class Guidance_group(Model):
  199. id = fields.IntField(pk=True)
  200. name = fields.CharField(max_length=125, description="協會(團體)名稱")
  201. contact_person = fields.CharField(max_length=125, description="聯絡人")
  202. contact_phone = fields.CharField(max_length=125, description="聯絡電話")
  203. line = fields.IntField(description="LINE (0:沒有、1:有)")
  204. address = fields.TextField(description="地址")
  205. email = fields.CharField(max_length=125, description="信箱")
  206. information = fields.TextField(description="開課資訊")
  207. request = fields.TextField(description="需求")
  208. schedule = fields.CharField(max_length=45, description="處理進度")
  209. result = fields.CharField(max_length=125, description="處理結果")
  210. person = fields.CharField(max_length=45, description="輔導人員")
  211. remark = fields.TextField(description="備註")
  212. class User_information(Model):
  213. id = fields.IntField(pk=True)
  214. user_id = fields.IntField(description="使用者ID")
  215. name = fields.CharField(max_length=45, description="姓名")
  216. birthday = fields.DateField(description="生日")
  217. gender = fields.CharField(max_length=45, description="性別")
  218. phone = fields.CharField(max_length=45, description="電話")
  219. address = fields.TextField(description="地址")
  220. is_default = fields.IntField(description="是否為預設")
  221. position = fields.JSONField(max_length=200,description="登入身分")
  222. class Class_date(Model):
  223. id = fields.IntField(pk=True)
  224. class_list_id = fields.IntField(description="場次ID")
  225. registration_start = fields.DatetimeField(description="報名時間開始", null=True)
  226. registration_end = fields.DatetimeField(description="報名時間結束", null=True)
  227. number_limit = fields.IntField(description="名額", null=True)
  228. amount_left = fields.IntField(description="剩餘名額", null=True)
  229. class Attend_record(Model):
  230. id = fields.IntField(pk=True)
  231. class_detail_id = fields.IntField(description="課堂ID")
  232. user_id = fields.IntField(description="使用者ID")
  233. is_attend = fields.IntField(description="是否已出席(1:是、0:否)")
  234. class One_day_class(Model):
  235. id = fields.IntField(pk=True)
  236. name_id = fields.IntField(description="課程名稱")
  237. teacher = fields.CharField(max_length=100, description="老師", null=True)
  238. contact = fields.CharField(max_length=100, description="聯絡方式", null=True)
  239. start_time = fields.DatetimeField(description="開始時間", null=True)
  240. end_time = fields.DatetimeField(description="結束時間", null=True)
  241. reg_deadline = fields.DatetimeField(description="報名結束時間", null=True)
  242. remark = fields.TextField(description="備註", null=True)
  243. people = fields.CharField(max_length=255, description="對象", null=True)
  244. way = fields.CharField(max_length=45, description="上課方式", null=True)
  245. fee_method = fields.TextField(description="收費方式", null=True)
  246. material = fields.TextField(description="材料", null=True)
  247. tools = fields.TextField(description="材料", null=True)
  248. number_limit = fields.TextField(description="人數限制", null=True)
  249. def show_data(self):
  250. return {
  251. "id" : self.id,
  252. "name_id": self.name_id,
  253. "teacher": self.teacher,
  254. "contact": self.contact,
  255. "start_time": self.start_time,
  256. "end_time": self.end_time,
  257. "reg_deadline": self.reg_deadline,
  258. "remark": self.remark,
  259. "people": self.people,
  260. "way": self.way,
  261. "material": self.material,
  262. "tools": self.tools,
  263. "number_limit": self.number_limit
  264. }
  265. class User_resume(Model):
  266. id = fields.IntField(pk=True)
  267. user_id = fields.IntField(description="使用者編號")
  268. teacher_name = fields.CharField(max_length=45,description="老師名字")
  269. work_type = fields.CharField(max_length=45, description="工作性質", null=True)
  270. experience = fields.CharField(max_length=100, description="教學經驗", null=True)
  271. expertise = fields.TextField(description="專業工藝技能", null=True)
  272. license = fields.TextField(description="相關證照", null=True)
  273. media = fields.TextField(description="社群媒體", null=True)
  274. imgs = fields.TextField(description="作品集", null=True)
  275. introduction = fields.TextField(description="自我介紹", null=True)
  276. def show_data(self):
  277. return {
  278. "id" : self.id,
  279. "user_id": self.user_id,
  280. "teacher_name": self.teacher_name,
  281. "work_type": self.work_type,
  282. "experience": self.experience,
  283. "expertise": self.expertise,
  284. "license": self.license,
  285. "media": self.media,
  286. "imgs": self.imgs,
  287. "introduction": self.introduction
  288. }
  289. class Tgc_pic(Model):
  290. id = fields.IntField(pk=True)
  291. pic_name = fields.TextField(description="照片名稱", null=True)
  292. pic_url = fields.TextField(description="照片連結", null=True)
  293. def show_data(self):
  294. return {
  295. "id" : self.id,
  296. "pic_name": self.pic_name,
  297. "pic_url": self.pic_url
  298. }
  299. class Tgc_report(Model):
  300. id = fields.IntField(pk=True)
  301. title = fields.CharField(max_length=100,description="標題", null=True)
  302. create_time = fields.DatetimeField(description="創建時間", null=True)
  303. url = fields.TextField(description="連結", null=True)
  304. def show_data(self):
  305. return {
  306. "id" : self.id,
  307. "title": self.title,
  308. "create_time": self.create_time,
  309. "url": self.url
  310. }
  311. class Outter_class_list(Model):
  312. id = fields.IntField(pk=True)
  313. name_id = fields.IntField(description="課程名稱")
  314. start_time = fields.DatetimeField(description="開始時間", null=True)
  315. end_time = fields.DatetimeField(description="結束時間", null=True)
  316. imgs = fields.TextField(description="圖片", null=True)
  317. price = fields.CharField(max_length=45, description="價錢", null=True)
  318. URL = fields.TextField(description="連結", null=True)
  319. def show_data(self):
  320. return {
  321. "id" : self.id,
  322. "name_id": self.name_id,
  323. "start_time": self.start_time,
  324. "end_time": self.end_time,
  325. "imgs": self.imgs,
  326. "price": self.price,
  327. "URL": self.URL
  328. }