from django.db import models from django.contrib.auth.models import User # 关键词任务表 class KeywordMission(models.Model): # 关键词任务id keyword_mission_id = models.AutoField(primary_key=True) # 关键词 keyword = models.CharField(max_length=256, unique=True) # 发起者 publisher = models.ForeignKey(User, on_delete=models.CASCADE, related_name='publisher') # 日期任务表 class DateMission(models.Model): # 日期任务id date_mission_id = models.AutoField(primary_key=True) # 日期 date = models.DateField() # 是否已完成 is_date_finished = models.BooleanField(default=False) # 关键词任务 keyword_mission = models.ForeignKey(KeywordMission, on_delete=models.CASCADE, related_name='DateMission') class Meta: unique_together = ('date', 'keyword_mission',) # 时间任务表 class TimeMission(models.Model): # 时间任务id time_mission_id = models.AutoField(primary_key=True) # 时间 time = models.DateTimeField() # 是否已完成 is_time_finished = models.BooleanField(default=False) # 日期任务 date_mission = models.ForeignKey(DateMission, on_delete=models.CASCADE, related_name='TimeMission') class Meta: unique_together = ('time', 'date_mission',) # 页面任务表 class PageMission(models.Model): # 页面任务id page_mission_id = models.AutoField(primary_key=True) # 页码 page = models.BigIntegerField() # 时间任务 time_mission = models.ForeignKey(TimeMission, on_delete=models.CASCADE, related_name='PageMission') # 完成者 finisher = models.ForeignKey(User, on_delete=models.CASCADE, related_name='PageMission') class Meta: unique_together = ('page', 'time_mission',) # 微博文章 class ArticleMission(models.Model): # 文章任务id article_mission_id = models.AutoField(primary_key=True) # 文章任务 page_mission = models.ForeignKey(PageMission, on_delete=models.CASCADE, related_name='ArticleMission') # 文章ID article_id = models.CharField(max_length=100) # 发表时间 publish_time = models.DateTimeField() # 内容 content = models.TextField() # 点赞数 like_count = models.IntegerField() # 评论数 comment_count = models.IntegerField() class Meta: unique_together = ('article_id', 'page_mission',)