import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common';
import { CreateTestCaseDto } from './dto/create-test-case.dto';
import { UpdateTestCaseDto } from './dto/update-test-case.dto';
import { TestCaseService } from './test-case.service';

@Controller('versions/:versionId/test-cases')
export class TestCaseController {
  constructor(private readonly testCaseService: TestCaseService) {}

  @Post()
  create(@Param('versionId') versionId: string, @Body() dto: CreateTestCaseDto) {
    return this.testCaseService.create(versionId, dto);
  }

  @Post('batch')
  createMany(@Param('versionId') versionId: string, @Body('items') items: CreateTestCaseDto[]) {
    return this.testCaseService.createMany(versionId, items ?? []);
  }

  @Get()
  findAll(@Param('versionId') versionId: string) {
    return this.testCaseService.findAll(versionId);
  }

  @Patch(':id')
  update(@Param('versionId') versionId: string, @Param('id') id: string, @Body() dto: UpdateTestCaseDto) {
    return this.testCaseService.update(versionId, id, dto);
  }

  @Patch(':id/status')
  updateStatus(
    @Param('versionId') versionId: string,
    @Param('id') id: string,
    @Body('status') status: string,
  ) {
    return this.testCaseService.updateStatus(versionId, id, status);
  }

  @Delete(':id')
  remove(@Param('versionId') versionId: string, @Param('id') id: string) {
    return this.testCaseService.remove(versionId, id);
  }
}
