68 lines
2.4 KiB
TypeScript
68 lines
2.4 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Header,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { TrainingService } from './training.service';
|
|
import { CreateTrainingMoveDto } from './dto/create-training-move.dto';
|
|
import { UpdateTrainingMoveDto } from './dto/update-training-move.dto';
|
|
import { QueryTrainingMovesDto } from './dto/query-training-moves.dto';
|
|
import { TrainingMove } from './entities/training-move.entity';
|
|
import { PaginatedResponse } from '@common/pagination.dto';
|
|
|
|
@ApiTags('Training')
|
|
@Controller('training-moves')
|
|
export class TrainingController {
|
|
constructor(private readonly trainingService: TrainingService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List training moves with filters and pagination' })
|
|
findAll(@Query() query: QueryTrainingMovesDto): Promise<PaginatedResponse<TrainingMove>> {
|
|
return this.trainingService.findAll(query as QueryTrainingMovesDto & Record<string, unknown>);
|
|
}
|
|
|
|
@Get('export')
|
|
@ApiOperation({ summary: 'Export training moves as JSONL for ML fine-tuning' })
|
|
@Header('Content-Type', 'application/x-ndjson')
|
|
@Header('Content-Disposition', 'attachment; filename="training-export.jsonl"')
|
|
async exportMoves(@Query('projectId') projectId: string | undefined): Promise<string> {
|
|
return this.trainingService.exportAsJsonl(projectId);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get training move by ID' })
|
|
findOne(@Param('id') id: string): Promise<TrainingMove> {
|
|
return this.trainingService.findOne(id);
|
|
}
|
|
|
|
@Get(':id/combo')
|
|
@ApiOperation({ summary: 'Get training move with expanded combo components' })
|
|
getComboExpanded(@Param('id') id: string): Promise<{ move: TrainingMove; components: TrainingMove[] }> {
|
|
return this.trainingService.getComboExpanded(id);
|
|
}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: 'Create training move' })
|
|
create(@Body() dto: CreateTrainingMoveDto): Promise<TrainingMove> {
|
|
return this.trainingService.createMove(dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@ApiOperation({ summary: 'Update training move' })
|
|
update(@Param('id') id: string, @Body() dto: UpdateTrainingMoveDto): Promise<TrainingMove> {
|
|
return this.trainingService.updateMove(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@ApiOperation({ summary: 'Soft delete training move (sets isActive=false)' })
|
|
remove(@Param('id') id: string): Promise<TrainingMove> {
|
|
return this.trainingService.softRemove(id);
|
|
}
|
|
}
|