| 1 | import { Body, Controller, Post } from '@nestjs/common' |
| 2 | import { ApiTags } from '@nestjs/swagger' |
| 3 | import { Internal } from '@yikart/aitoearn-auth' |
| 4 | import { ApiDoc } from '@yikart/common' |
| 5 | import { DraftGenerationService } from '../draft-generation/draft-generation.service' |
| 6 | import { |
| 7 | CreateDraftGenerationVo, |
| 8 | DraftGenerationTaskVo, |
| 9 | } from '../draft-generation/draft-generation.vo' |
| 10 | import { |
| 11 | InternalCreateDraftV2Dto, |
| 12 | InternalCreateImageTextDraftDto, |
| 13 | InternalGetDraftTaskDto, |
| 14 | } from './draft-generation.dto' |
| 15 | |
| 16 | @ApiTags('Internal/DraftGeneration') |
| 17 | @Controller('internal') |
| 18 | @Internal() |
| 19 | export class DraftGenerationInternalController { |
| 20 | constructor( |
| 21 | private readonly draftGenerationService: DraftGenerationService, |
| 22 | ) {} |
| 23 | |
| 24 | @ApiDoc({ |
| 25 | summary: '生成品牌内容草稿 (V2)', |
| 26 | body: InternalCreateDraftV2Dto.schema, |
| 27 | response: CreateDraftGenerationVo, |
| 28 | }) |
| 29 | @Post('ai/draft-generation/v2') |
| 30 | async createDraftsV2(@Body() body: InternalCreateDraftV2Dto): Promise<CreateDraftGenerationVo> { |
| 31 | const taskIds = await this.draftGenerationService.createDraftsV2(body.userId, body.userType, body) |
| 32 | return CreateDraftGenerationVo.create({ taskIds }) |
| 33 | } |
| 34 | |
| 35 | @ApiDoc({ |
| 36 | summary: '生成图文内容草稿', |
| 37 | body: InternalCreateImageTextDraftDto.schema, |
| 38 | response: CreateDraftGenerationVo, |
| 39 | }) |
| 40 | @Post('ai/draft-generation/image-text') |
| 41 | async createImageTextDrafts(@Body() body: InternalCreateImageTextDraftDto): Promise<CreateDraftGenerationVo> { |
| 42 | const taskIds = await this.draftGenerationService.createImageTextDrafts(body.userId, body.userType, body) |
| 43 | return CreateDraftGenerationVo.create({ taskIds }) |
| 44 | } |
| 45 | |
| 46 | @ApiDoc({ |
| 47 | summary: '查询单个草稿生成任务', |
| 48 | body: InternalGetDraftTaskDto.schema, |
| 49 | response: DraftGenerationTaskVo, |
| 50 | }) |
| 51 | @Post('ai/draft-generation/task') |
| 52 | async getTask(@Body() body: InternalGetDraftTaskDto): Promise<DraftGenerationTaskVo> { |
| 53 | const task = await this.draftGenerationService.getTask(body.taskId, body.userId, body.userType) |
| 54 | return DraftGenerationTaskVo.create(task) |
| 55 | } |
| 56 | } |
| 57 |