feat(schedule-tasks): support auto-publish via media accounts

Replace the legacy target_platform string on schedule tasks with a
workspace-aware auto-publish payload (auto_publish + publish_account_ids
JSONB + cover_asset_url + cover_image_asset_id) and migrate the schema,
sqlc queries, generated models, domain struct, ScheduleTaskService DTOs,
and dispatch worker to round-trip the new fields. PromptRuleGeneration
gains a WithPublishJobService hook so executeGeneration can enqueue an
auto-publish job once the article is ready, and worker-generate wires
the publish-job service in. On the admin-web side, extract
PublishArticleModal's account-card builders into a shared
publish-account-cards module, rebuild GenerateTaskDrawer's schedule
mode around account selection plus a CoverPickerModal, and surface the
new "auto publish" column on ScheduleTaskTab. Shared types and i18n
strings cover the new fields.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-30 01:32:19 +08:00
parent c9267d2fae
commit 6e6e19cccb
22 changed files with 1380 additions and 603 deletions
@@ -620,23 +620,27 @@ type QuotaReservation struct {
}
type ScheduleTask struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PromptRuleID int64 `json:"prompt_rule_id"`
BrandID pgtype.Int8 `json:"brand_id"`
Name string `json:"name"`
CronExpr string `json:"cron_expr"`
TargetPlatform pgtype.Text `json:"target_platform"`
StartAt pgtype.Timestamptz `json:"start_at"`
EndAt pgtype.Timestamptz `json:"end_at"`
NextRunAt pgtype.Timestamptz `json:"next_run_at"`
Status string `json:"status"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
OperatorID pgtype.Int8 `json:"operator_id"`
EnableWebSearch bool `json:"enable_web_search"`
GenerateCount int32 `json:"generate_count"`
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PromptRuleID int64 `json:"prompt_rule_id"`
BrandID pgtype.Int8 `json:"brand_id"`
Name string `json:"name"`
CronExpr string `json:"cron_expr"`
StartAt pgtype.Timestamptz `json:"start_at"`
EndAt pgtype.Timestamptz `json:"end_at"`
NextRunAt pgtype.Timestamptz `json:"next_run_at"`
Status string `json:"status"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
OperatorID pgtype.Int8 `json:"operator_id"`
EnableWebSearch bool `json:"enable_web_search"`
GenerateCount int32 `json:"generate_count"`
WorkspaceID pgtype.Int8 `json:"workspace_id"`
AutoPublish bool `json:"auto_publish"`
PublishAccountIds []byte `json:"publish_account_ids"`
CoverAssetUrl pgtype.Text `json:"cover_asset_url"`
CoverImageAssetID pgtype.Int8 `json:"cover_image_asset_id"`
}
type TaskRecord struct {