import { Controller, Get, Post, Param, HttpCode, HttpStatus, Body } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { DocumentImportService } from './document-import.service';
import { CreateImportDto } from './dto/create-import.dto';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import type { UserPayload } from '../../common/types';

@ApiTags('document-import')
@Controller('imports')
export class DocumentImportController {
  constructor(private readonly service: DocumentImportService) {}

  @Post()
  @HttpCode(HttpStatus.CREATED)
  @ApiOperation({ summary: '创建导入任务' })
  async createImport(@CurrentUser() user: UserPayload, @Body() dto: CreateImportDto) {
    return this.service.createImport({ ...dto, userId: user.id });
  }

  @Get(':id/status')
  @ApiOperation({ summary: '查询导入状态' })
  async getStatus(@Param('id') id: string) {
    return this.service.getStatus(id);
  }
}
