feat(wordcloud): GET /api/wordcloud/jobs/:id/result 端点
This commit is contained in:
@@ -49,4 +49,11 @@ export class WordCloudController {
|
|||||||
async job(@CurrentUser() user: JwtPayload, @Param('id') id: string) {
|
async job(@CurrentUser() user: JwtPayload, @Param('id') id: string) {
|
||||||
return this.wordCloudService.getUserJob(user.sub, id);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,6 +220,18 @@ export class WordCloudService implements OnModuleInit {
|
|||||||
return updated;
|
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 → 返回小程序侧模型 */
|
/** 查询本人词云任务:归属校验 → 实时代理轮询 wordcloud → 返回小程序侧模型 */
|
||||||
async getUserJob(userId: string, id: string) {
|
async getUserJob(userId: string, id: string) {
|
||||||
const job = await this.prisma.wordCloudJob.findFirst({ where: { id, userId } });
|
const job = await this.prisma.wordCloudJob.findFirst({ where: { id, userId } });
|
||||||
|
|||||||
Reference in New Issue
Block a user