AI ニジカ綜合
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.

models.py 1.4 KiB

1 day ago
1 day ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from __future__ import annotations
  2. from datetime import datetime
  3. from eloquent import Model
  4. class Answer (Model):
  5. id: int
  6. query_id: int
  7. character: int
  8. content: str
  9. answer_type: int
  10. sent_at: datetime
  11. answered: bool
  12. __timestamps__ = False
  13. @property
  14. def query (
  15. self,
  16. ) -> Query:
  17. return self.belongs_to (Query)
  18. class Query (Model):
  19. id: int
  20. user_id: int | None
  21. target_character: int
  22. content: str
  23. image_url: str | None
  24. query_type: int
  25. model: int
  26. sent_at: datetime
  27. answered: bool
  28. __timestamps__ = False
  29. @property
  30. def user (
  31. self,
  32. ) -> User:
  33. return self.belongs_to (User)
  34. @property
  35. def answer_histories (
  36. self,
  37. ) -> list[Answer]:
  38. return [x.answer for x in self.has_many (QueryAnswerHistory).get ()]
  39. class QueryAnswerHistory (Model):
  40. id: int
  41. query_id: int
  42. answer_id: int
  43. @property
  44. def query (
  45. self,
  46. ) -> Query:
  47. return self.belongs_to (Query)
  48. @property
  49. def answer (
  50. self,
  51. ) -> Answer:
  52. return self.belongs_to (Answer)
  53. class User (Model):
  54. id: int
  55. platform: int
  56. code: str
  57. name: str
  58. icon: bytes