import { Controller, Get, Post, Param, Req, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { AiJobService } from './ai-job.service';

@ApiTags('ai-jobs')
@Controller('api/ai/jobs')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
export class AiJobController {
  constructor(private readonly service: AiJobService) {}

  @Get(':jobId')
  @ApiOperation({ summary: '查询 Job 状态（用户自己的 Job）' })
  async getJob(@Req() req: any, @Param('jobId') jobId: string) {
    return this.service.getJobForUser(req.user.id, jobId);
  }

  @Post(':jobId/cancel')
  @ApiOperation({ summary: '取消 Job（用户自己的 Job）' })
  async cancelJob(@Req() req: any, @Param('jobId') jobId: string) {
    return this.service.cancelJobForUser(req.user.id, jobId);
  }
}
