From 6552b15d2e36e1d4272ca7ad9d7f34516416e74e Mon Sep 17 00:00:00 2001 From: obroccolio Date: Thu, 13 Aug 2026 01:40:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(wordcloud):=20GET=20/api/wordcloud/jobs/:i?= =?UTF-8?q?d/result=20=E7=AB=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wordcloud/wordcloud.controller.ts | 7 +++++++ src/wordcloud/wordcloud.service.ts | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/wordcloud/wordcloud.controller.ts b/src/wordcloud/wordcloud.controller.ts index 39517c4..102409c 100644 --- a/src/wordcloud/wordcloud.controller.ts +++ b/src/wordcloud/wordcloud.controller.ts @@ -49,4 +49,11 @@ export class WordCloudController { async job(@CurrentUser() user: JwtPayload, @Param('id') id: string) { return this.wordCloudService.getUserJob(user.sub, id); } + + /** 取词云任务结果(仅本人;产物已转存 COS) */ + @Get('jobs/:id/result') + @ApiOperation({ summary: '词云任务结果(仅本人)' }) + async result(@CurrentUser() user: JwtPayload, @Param('id') id: string) { + return this.wordCloudService.getUserJobResult(user.sub, id); + } } diff --git a/src/wordcloud/wordcloud.service.ts b/src/wordcloud/wordcloud.service.ts index 38c9784..6600382 100644 --- a/src/wordcloud/wordcloud.service.ts +++ b/src/wordcloud/wordcloud.service.ts @@ -220,6 +220,18 @@ export class WordCloudService implements OnModuleInit { return updated; } + /** 取词云任务结果(产物已由后台同步/轮询转存 COS) */ + async getUserJobResult(userId: string, id: string) { + const job = await this.prisma.wordCloudJob.findFirst({ where: { id, userId } }); + if (!job) { + throw new HttpException('任务不存在', HttpStatus.NOT_FOUND); + } + if (!job.imageUrl) { + throw new HttpException('结果未就绪', HttpStatus.NOT_FOUND); + } + return { imageUrl: job.imageUrl }; + } + /** 查询本人词云任务:归属校验 → 实时代理轮询 wordcloud → 返回小程序侧模型 */ async getUserJob(userId: string, id: string) { const job = await this.prisma.wordCloudJob.findFirst({ where: { id, userId } });