import { Controller, Get, Post, Patch, Body, Param } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { ImportCandidateService } from './import-candidate.service';

@ApiTags('import-candidate')
@Controller()
export class ImportCandidateController {
  constructor(private readonly service: ImportCandidateService) {}

  @Get('knowledge-sources/:sourceId/import-candidates')
  @ApiOperation({ summary: '获取资料来源的候选知识点' })
  async findBySource(@Param('sourceId') sourceId: string) {
    return this.service.findBySource(sourceId);
  }

  @Get('import-candidates/:id')
  @ApiOperation({ summary: '获取候选知识点详情' })
  async findOne(@Param('id') id: string) {
    return this.service.findOne(id);
  }

  @Patch('import-candidates/:id')
  @ApiOperation({ summary: '编辑候选知识点' })
  async update(@Param('id') id: string, @Body() dto: any) {
    return this.service.update(id, dto);
  }

  @Post('import-candidates/:id/accept')
  @ApiOperation({ summary: '接受候选知识点 → 生成 KnowledgeItem' })
  async accept(@Param('id') id: string) {
    return this.service.accept(id);
  }

  @Post('import-candidates/:id/reject')
  @ApiOperation({ summary: '拒绝候选知识点' })
  async reject(@Param('id') id: string) {
    return this.service.reject(id);
  }

  @Post('import-candidates/batch-accept')
  @ApiOperation({ summary: '批量接受候选知识点' })
  async batchAccept(@Body() dto: { sourceId: string }) {
    return this.service.batchAccept(dto.sourceId);
  }
}
