import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CreateSkinGenerationJobDto } from './dto/create_skin_generation_job.dto';
import { SkinGenerationService } from './skin_generation.service';
import { JwtAuthGuard } from '../../gateway/auth/jwt_auth.guard';
import { CurrentUser } from '../../gateway/auth/current_user.decorator';
import { JwtPayload } from '../../core/login_core/login_core.service';

@ApiTags('角色皮肤生成')
@Controller('api/skin-generation')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
export class SkinGenerationController {
  constructor(private readonly skinGenerationService: SkinGenerationService) {}

  @Post('jobs')
  @ApiOperation({ summary: '创建角色皮肤生成任务' })
  async createJob(@CurrentUser() user: JwtPayload, @Body() dto: CreateSkinGenerationJobDto) {
    const data = await this.skinGenerationService.createJob(BigInt(user.sub), dto);
    return { success: true, data };
  }

  @Get('jobs/:jobId')
  @ApiOperation({ summary: '查询角色皮肤生成任务' })
  async getJob(@CurrentUser() user: JwtPayload, @Param('jobId') jobId: string) {
    const data = await this.skinGenerationService.getJob(BigInt(user.sub), jobId);
    return { success: true, data };
  }
}
