feat: implement brand asset cleanup event handling and reconciliation logic
Backend CI / Backend (push) Failing after 6m54s

This commit is contained in:
2026-06-21 08:26:56 +08:00
parent 05a69c7c89
commit c1b06dab18
11 changed files with 744 additions and 15 deletions
@@ -309,6 +309,13 @@ func (s *BrandService) Delete(ctx context.Context, id int64) error {
_, _ = tx.Exec(ctx, `UPDATE brand_questions SET deleted_at = NOW(), updated_at = NOW() WHERE brand_id = $1 AND tenant_id = $2 AND deleted_at IS NULL`, id, actor.TenantID)
_, _ = tx.Exec(ctx, `UPDATE competitors SET deleted_at = NOW(), updated_at = NOW() WHERE brand_id = $1 AND tenant_id = $2 AND deleted_at IS NULL`, id, actor.TenantID)
if _, err := EnqueueBrandAssetCleanupEvent(ctx, tx, actor.TenantID, id); err != nil {
return response.ErrInternal(50010, "delete_failed", "failed to enqueue brand cleanup event")
}
if err := NotifyBrandAssetCleanup(ctx, tx); err != nil {
return response.ErrInternal(50010, "delete_failed", "failed to notify brand cleanup")
}
afterJSON, _ := json.Marshal(map[string]interface{}{"id": id, "status": "deleting", "cleanup": "background"})
if err := tx.Commit(ctx); err != nil {
return err