new
This commit is contained in:
		| @@ -35,7 +35,6 @@ type Article struct { | ||||
| 	IsFeatured  bool          `gorm:"default:false" json:"is_featured" comment:"是否推荐"` | ||||
| 	PublishedAt *time.Time    `json:"published_at" comment:"发布时间"` | ||||
| 	ScheduledAt *time.Time    `json:"scheduled_at" comment:"定时发布时间"` | ||||
| 	TaskID      string        `gorm:"type:varchar(100)" json:"task_id" comment:"定时任务ID"` | ||||
|  | ||||
| 	// 统计信息 | ||||
| 	ViewCount int `gorm:"default:0" json:"view_count" comment:"阅读量"` | ||||
| @@ -120,7 +119,7 @@ func (a *Article) Publish() error { | ||||
| } | ||||
|  | ||||
| // SchedulePublish 定时发布文章 | ||||
| func (a *Article) SchedulePublish(scheduledTime time.Time, taskID string) error { | ||||
| func (a *Article) SchedulePublish(scheduledTime time.Time) error { | ||||
| 	if a.Status == ArticleStatusPublished { | ||||
| 		return NewValidationError("文章已经是发布状态") | ||||
| 	} | ||||
| @@ -131,13 +130,12 @@ func (a *Article) SchedulePublish(scheduledTime time.Time, taskID string) error | ||||
|  | ||||
| 	a.Status = ArticleStatusDraft // 保持草稿状态,等待定时发布 | ||||
| 	a.ScheduledAt = &scheduledTime | ||||
| 	a.TaskID = taskID | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // UpdateSchedulePublish 更新定时发布时间 | ||||
| func (a *Article) UpdateSchedulePublish(scheduledTime time.Time, taskID string) error { | ||||
| func (a *Article) UpdateSchedulePublish(scheduledTime time.Time) error { | ||||
| 	if a.Status == ArticleStatusPublished { | ||||
| 		return NewValidationError("文章已经是发布状态") | ||||
| 	} | ||||
| @@ -147,7 +145,6 @@ func (a *Article) UpdateSchedulePublish(scheduledTime time.Time, taskID string) | ||||
| 	} | ||||
|  | ||||
| 	a.ScheduledAt = &scheduledTime | ||||
| 	a.TaskID = taskID | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
| @@ -159,7 +156,6 @@ func (a *Article) CancelSchedulePublish() error { | ||||
| 	} | ||||
|  | ||||
| 	a.ScheduledAt = nil | ||||
| 	a.TaskID = "" | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user