feat(edit): 编辑页类目树逻辑开发
This commit is contained in:
+39
-6
@@ -63,9 +63,9 @@ const worker = new Worker<OutboxJob>(
|
||||
} else if (job.name === 'collection.assets.materialize.requested' || job.name === 'collection.assets.retry.requested') {
|
||||
await materializeCollectionAssets(database, objectStorage, workerConfig.objectStorageBucket, job.data);
|
||||
} else if (
|
||||
job.name === 'platform_category_tree_sync.requested' ||
|
||||
job.name === 'platform_category_attribute_sync.requested' ||
|
||||
job.name === 'platform_attribute_dictionary_sync.requested'
|
||||
job.name === 'store_category_tree_sync.requested' ||
|
||||
job.name === 'store_category_attribute_sync.requested' ||
|
||||
job.name === 'store_attribute_dictionary_sync.requested'
|
||||
) {
|
||||
await syncOzonCatalog(database, job.data as CatalogSyncJob);
|
||||
}
|
||||
@@ -86,9 +86,9 @@ worker.on('failed', (job, error) => {
|
||||
if (job.name === 'store_credential_verification.requested') {
|
||||
void markUnavailable(database, job.data as StoreVerificationJob, error);
|
||||
} else if (
|
||||
job.name === 'platform_category_tree_sync.requested' ||
|
||||
job.name === 'platform_category_attribute_sync.requested' ||
|
||||
job.name === 'platform_attribute_dictionary_sync.requested'
|
||||
job.name === 'store_category_tree_sync.requested' ||
|
||||
job.name === 'store_category_attribute_sync.requested' ||
|
||||
job.name === 'store_attribute_dictionary_sync.requested'
|
||||
) {
|
||||
void markCatalogSyncUnavailable(database, job.data as CatalogSyncJob, error);
|
||||
}
|
||||
@@ -215,6 +215,39 @@ async function completeVerification(
|
||||
: 'Ozon 未接受该 Client ID 或 API Key',
|
||||
],
|
||||
);
|
||||
if (!valid) return;
|
||||
const catalogOperation = await tx.query<{
|
||||
id: string;
|
||||
}>(
|
||||
`INSERT INTO atlas.operations
|
||||
(workspace_id, kind, resource_type, resource_id)
|
||||
VALUES (current_setting('app.workspace_id')::uuid,
|
||||
'store_category_tree_sync', 'store', $1)
|
||||
RETURNING id`,
|
||||
[job.payload.store_id],
|
||||
);
|
||||
const operationId = catalogOperation.rows[0]?.id;
|
||||
if (!operationId) throw new Error('Unable to create store catalog sync operation');
|
||||
await tx.query(
|
||||
`INSERT INTO atlas.outbox_events
|
||||
(workspace_id, aggregate_type, aggregate_id, event_type, event_payload, deduplication_key)
|
||||
VALUES (current_setting('app.workspace_id')::uuid, 'store', $1,
|
||||
'store_category_tree_sync.requested', $2::jsonb, $3)`,
|
||||
[
|
||||
job.payload.store_id,
|
||||
JSON.stringify({
|
||||
store_id: job.payload.store_id,
|
||||
secret_id: job.payload.secret_id,
|
||||
operation_id: operationId,
|
||||
platform_id: (await tx.query<{ platform_id: string }>(
|
||||
`SELECT platform_id FROM atlas.stores WHERE id = $1`,
|
||||
[job.payload.store_id],
|
||||
)).rows[0]?.platform_id,
|
||||
scope: 'tree',
|
||||
}),
|
||||
operationId,
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user