feat(edit): 编辑上报细节优化
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { ProductImageDeletionService } from './product-image-deletion.service.js';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
@@ -17,6 +18,7 @@ import {
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import {
|
||||
deleteProductImageRequestSchema,
|
||||
completeMediaUploadIntentRequestSchema,
|
||||
createMediaAccessUrlRequestSchema,
|
||||
createMediaUploadIntentRequestSchema,
|
||||
@@ -47,6 +49,7 @@ import { ImageSuiteService } from './image-suite.service.js';
|
||||
@Controller()
|
||||
export class MediaController {
|
||||
public constructor(
|
||||
@Inject(ProductImageDeletionService) private readonly imageDeletions: ProductImageDeletionService,
|
||||
@Inject(MediaService) private readonly media: MediaService,
|
||||
@Inject(AspectRatioDerivativeService) private readonly derivatives: AspectRatioDerivativeService,
|
||||
@Inject(WatermarkDerivativeService) private readonly watermarkDerivatives: WatermarkDerivativeService,
|
||||
@@ -56,6 +59,29 @@ export class MediaController {
|
||||
@Inject(ImageSuiteService) private readonly suites: ImageSuiteService,
|
||||
) {}
|
||||
|
||||
@Post('products/:productId/image-deletions')
|
||||
public async deleteProductImage(@Param('productId') productId: string, @Body() body: unknown,
|
||||
@Headers('idempotency-key') key: string | undefined, @Req() request: AuthenticatedRequest,
|
||||
@CurrentWorkspace() workspace: Workspace, @Res({ passthrough: true }) response: { status: (code: number) => void }) {
|
||||
const result = await this.imageDeletions.create(workspace.id, request.auth.userId, uuid('product_id', productId), idempotencyKey(key), parse(deleteProductImageRequestSchema, body));
|
||||
response.status(result.status); return result.body;
|
||||
}
|
||||
@Get('products/:productId/image-deletions')
|
||||
public async pendingImageDeletions(@Param('productId') productId: string, @CurrentWorkspace() workspace: Workspace) {
|
||||
return { data: await this.imageDeletions.pending(workspace.id, uuid('product_id', productId)) };
|
||||
}
|
||||
@Get('products/:productId/image-deletions/:deletionId')
|
||||
public async readImageDeletion(@Param('productId') productId: string, @Param('deletionId') id: string, @CurrentWorkspace() workspace: Workspace) {
|
||||
return { data: await this.imageDeletions.read(workspace.id, uuid('product_id', productId), uuid('deletion_id', id)) };
|
||||
}
|
||||
@Post('products/:productId/image-deletions/:deletionId/retry')
|
||||
public async retryImageDeletion(@Param('productId') productId: string, @Param('deletionId') id: string,
|
||||
@Headers('idempotency-key') key: string | undefined, @Req() request: AuthenticatedRequest, @CurrentWorkspace() workspace: Workspace,
|
||||
@Res({ passthrough: true }) response: { status: (code: number) => void }) {
|
||||
const result = await this.imageDeletions.retry(workspace.id, request.auth.userId, uuid('product_id', productId), uuid('deletion_id', id), idempotencyKey(key));
|
||||
response.status(result.status); return result.body;
|
||||
}
|
||||
|
||||
@Post('products/:productId/ai/suite-plans')
|
||||
public async planSuite(@Param('productId') productId: string, @Body() body: unknown,
|
||||
@Headers('idempotency-key') key: string | undefined, @Req() request: AuthenticatedRequest,
|
||||
@@ -214,15 +240,15 @@ export class MediaController {
|
||||
}
|
||||
|
||||
@Get('media-assets/product-uploads')
|
||||
@ApiOkResponse({ description: '最近上传的商品图片及短时预览地址' })
|
||||
public async productUploads(@CurrentWorkspace() workspace: Workspace) {
|
||||
return { data: await this.media.productUploads(workspace.id) };
|
||||
@ApiOkResponse({ description: '当前商品最近上传的图片及短时预览地址' })
|
||||
public async productUploads(@CurrentWorkspace() workspace: Workspace, @Query('product_id') productId: string) {
|
||||
return { data: await this.media.productUploads(workspace.id, uuid('product_id', productId)) };
|
||||
}
|
||||
|
||||
@Get('media-assets/product-imports')
|
||||
@ApiOkResponse({ description: '最近导入的网络商品图片及短时预览地址' })
|
||||
public async productImports(@CurrentWorkspace() workspace: Workspace) {
|
||||
return { data: await this.media.productImports(workspace.id) };
|
||||
@ApiOkResponse({ description: '当前商品最近导入的网络图片及短时预览地址' })
|
||||
public async productImports(@CurrentWorkspace() workspace: Workspace, @Query('product_id') productId: string) {
|
||||
return { data: await this.media.productImports(workspace.id, uuid('product_id', productId)) };
|
||||
}
|
||||
|
||||
@Post('media-assets/product-imports')
|
||||
|
||||
Reference in New Issue
Block a user