models.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. # 关键词任务表
  4. class KeywordMission(models.Model):
  5. # 关键词任务id
  6. keyword_mission_id = models.AutoField(primary_key=True)
  7. # 关键词
  8. keyword = models.CharField(max_length=256, unique=True)
  9. # 发起者
  10. publisher = models.ForeignKey(User, on_delete=models.CASCADE, related_name='publisher')
  11. # 日期任务表
  12. class DateMission(models.Model):
  13. # 日期任务id
  14. date_mission_id = models.AutoField(primary_key=True)
  15. # 日期
  16. date = models.DateField()
  17. # 是否已完成
  18. is_date_finished = models.BooleanField(default=False)
  19. # 关键词任务
  20. keyword_mission = models.ForeignKey(KeywordMission, on_delete=models.CASCADE, related_name='DateMission')
  21. class Meta:
  22. unique_together = ('date', 'keyword_mission',)
  23. # 时间任务表
  24. class TimeMission(models.Model):
  25. # 时间任务id
  26. time_mission_id = models.AutoField(primary_key=True)
  27. # 时间
  28. time = models.DateTimeField()
  29. # 是否已完成
  30. is_time_finished = models.BooleanField(default=False)
  31. # 日期任务
  32. date_mission = models.ForeignKey(DateMission, on_delete=models.CASCADE, related_name='TimeMission')
  33. class Meta:
  34. unique_together = ('time', 'date_mission',)
  35. # 页面任务表
  36. class PageMission(models.Model):
  37. # 页面任务id
  38. page_mission_id = models.AutoField(primary_key=True)
  39. # 页码
  40. page = models.BigIntegerField()
  41. # 时间任务
  42. time_mission = models.ForeignKey(TimeMission, on_delete=models.CASCADE, related_name='PageMission')
  43. # 完成者
  44. finisher = models.ForeignKey(User, on_delete=models.CASCADE, related_name='PageMission')
  45. class Meta:
  46. unique_together = ('page', 'time_mission',)
  47. # 微博文章
  48. class ArticleMission(models.Model):
  49. # 文章任务id
  50. article_mission_id = models.AutoField(primary_key=True)
  51. # 文章任务
  52. page_mission = models.ForeignKey(PageMission, on_delete=models.CASCADE, related_name='ArticleMission')
  53. # 文章ID
  54. article_id = models.CharField(max_length=100)
  55. # 发表时间
  56. publish_time = models.DateTimeField()
  57. # 内容
  58. content = models.TextField()
  59. # 点赞数
  60. like_count = models.IntegerField()
  61. # 评论数
  62. comment_count = models.IntegerField()
  63. class Meta:
  64. unique_together = ('article_id', 'page_mission',)