anexado guardar en minio y cambios generales en la interfaz de osp
This commit is contained in:
@@ -7,12 +7,9 @@ import {
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
Res,
|
||||
Req,
|
||||
UploadedFiles,
|
||||
UseInterceptors,
|
||||
StreamableFile,
|
||||
Header,
|
||||
Req
|
||||
} from '@nestjs/common';
|
||||
import { FilesInterceptor } from '@nestjs/platform-express';
|
||||
import {
|
||||
@@ -27,30 +24,29 @@ 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);
|
||||
}
|
||||
// @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({
|
||||
@@ -100,7 +96,11 @@ export class TrainingController {
|
||||
@UploadedFiles(ImageProcessingPipe) files: Express.Multer.File[],
|
||||
) {
|
||||
const userId = (req as any).user?.id;
|
||||
const data = await this.trainingService.create(createTrainingDto, files, userId);
|
||||
const data = await this.trainingService.create(
|
||||
createTrainingDto,
|
||||
files,
|
||||
userId,
|
||||
);
|
||||
return { message: 'Training record created successfully', data };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user