Exportar OSP en excel con formato especifico (falta img y datos que no estan en el formulario)
This commit is contained in:
@@ -7,8 +7,11 @@ import {
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
Res,
|
||||
UploadedFiles,
|
||||
UseInterceptors,
|
||||
StreamableFile,
|
||||
Header
|
||||
} from '@nestjs/common';
|
||||
import { FilesInterceptor } from '@nestjs/platform-express';
|
||||
import {
|
||||
@@ -23,11 +26,30 @@ import { CreateTrainingDto } from './dto/create-training.dto';
|
||||
import { TrainingStatisticsFilterDto } from './dto/training-statistics-filter.dto';
|
||||
import { UpdateTrainingDto } from './dto/update-training.dto';
|
||||
import { TrainingService } from './training.service';
|
||||
import { Public } from '@/common/decorators';
|
||||
|
||||
@ApiTags('training')
|
||||
@Controller('training')
|
||||
export class TrainingController {
|
||||
constructor(private readonly trainingService: TrainingService) {}
|
||||
constructor(private readonly trainingService: TrainingService) { }
|
||||
|
||||
@Public()
|
||||
@Get('export/:id')
|
||||
@ApiOperation({ summary: 'Export training template' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Return training template.',
|
||||
content: { 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': { schema: { type: 'string', format: 'binary' } } }
|
||||
})
|
||||
@Header('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
||||
@Header('Content-Disposition', 'attachment; filename=export_osp.xlsx')
|
||||
async exportTemplate(@Param('id') id: string) {
|
||||
if (!Number(id)) {
|
||||
throw new Error('ID is required');
|
||||
}
|
||||
const data = await this.trainingService.exportTemplate(Number(id));
|
||||
return new StreamableFile(data);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
|
||||
Reference in New Issue
Block a user