Se corrigió envio de correos y creacion de controller servicio
This commit is contained in:
@@ -1,34 +1,158 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Body,
|
||||
Query,
|
||||
UploadedFile,
|
||||
UploadedFiles,
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
Res,
|
||||
ParseIntPipe,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
FileInterceptor,
|
||||
FileFieldsInterceptor,
|
||||
} from '@nestjs/platform-express';
|
||||
import { ServicioService } from './servicio.service';
|
||||
import { CreateServicioDto } from './dto/create-servicio.dto';
|
||||
import { UpdateServicioDto } from './dto/update-servicio.dto';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { CrearServicioDto } from './dto/create-servicio.dto';
|
||||
import { Response } from 'express';
|
||||
|
||||
@Controller('servicio')
|
||||
export class ServicioController {
|
||||
constructor(private readonly servicioService: ServicioService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createServicioDto: CreateServicioDto) {
|
||||
return this.servicioService.create(createServicioDto);
|
||||
// ------------------ POST ------------------
|
||||
|
||||
@Post('nuevo')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaAceptacion'))
|
||||
async crearServicio(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('alumno') alumnoJson: string,
|
||||
) {
|
||||
const dto: CrearServicioDto = JSON.parse(alumnoJson);
|
||||
return await this.servicioService.registrarNuevoServicio(dto, file);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.servicioService.findAll();
|
||||
// ------------------ GET ------------------
|
||||
|
||||
@Get('admin')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async obtenerAdmin(@Query() query: any) {
|
||||
return this.servicioService.obtenerDetalleServicio(query.idServicio);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.servicioService.findOne(+id);
|
||||
@Get('alumno')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async obtenerAlumno(@Query('idUsuario', ParseIntPipe) idUsuario: number) {
|
||||
return this.servicioService.obtenerServicioAlumno(idUsuario);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateServicioDto: UpdateServicioDto) {
|
||||
return this.servicioService.update(+id, updateServicioDto);
|
||||
@Get('gustavo_baz_prada')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async gustavoBaz(
|
||||
@Query('year', ParseIntPipe) year: number,
|
||||
@Res() res: Response,
|
||||
) {
|
||||
const path = await this.servicioService.generarGustavoBazPrada(year);
|
||||
return res.download(path);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.servicioService.remove(+id);
|
||||
@Get('reporte')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async generarReporte(@Query() query: any, @Res() res: Response) {
|
||||
const path = await this.servicioService.generarGustavoBazPrada(query.year);
|
||||
return res.download(path);
|
||||
}
|
||||
|
||||
// ------------------ PUT ------------------
|
||||
|
||||
@Put('cancelar')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async cancelar(@Body() body: { idServicio: number; mensaje: string }) {
|
||||
return this.servicioService.cancelarServicio(body);
|
||||
}
|
||||
|
||||
@Put('carta_aceptacion')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaAceptacion'))
|
||||
async subirCartaAceptacion(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const body = JSON.parse(dataJson);
|
||||
return this.servicioService.cartaTermino(body.idServicio, file);
|
||||
}
|
||||
|
||||
@Put('carta_termino')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaTermino'))
|
||||
async subirCartaTermino(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const body = JSON.parse(dataJson);
|
||||
return this.servicioService.subirCartaTermino(body.idServicio, file);
|
||||
}
|
||||
|
||||
@Put('informe_global')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('informeGlobal'))
|
||||
async subirInformeGlobal(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const body = JSON.parse(dataJson);
|
||||
return this.servicioService.subirInformeGlobal(body.idServicio, file);
|
||||
}
|
||||
|
||||
@Put('liberacion')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async liberarServicio(
|
||||
@Body('idServicio', ParseIntPipe) idServicio: number,
|
||||
@Body('vistoBuenoAcatlan') vistoBuenoAcatlan: boolean,
|
||||
) {
|
||||
return this.servicioService.liberarServicio(idServicio, vistoBuenoAcatlan);
|
||||
}
|
||||
|
||||
@Put('rechazar_aceptacion')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async rechazarAceptacion(
|
||||
@Body() body: { idServicio: number; mensaje: string },
|
||||
) {
|
||||
return this.servicioService.rechazar(body.idServicio, body.mensaje);
|
||||
}
|
||||
|
||||
@Put('rechazar_informe')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async rechazarInforme(@Body() body: { idServicio: number; mensaje: string }) {
|
||||
return this.servicioService.rechazarInforme(body.idServicio, body.mensaje);
|
||||
}
|
||||
|
||||
@Put('rechazar_termino')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async rechazarTermino(@Body() body: { idServicio: number; mensaje: string }) {
|
||||
return this.servicioService.rechazarTermino(body.idServicio, body.mensaje);
|
||||
}
|
||||
|
||||
@Put('update')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(
|
||||
FileFieldsInterceptor([
|
||||
{ name: 'cartaAceptacion', maxCount: 1 },
|
||||
{ name: 'cartaTermino', maxCount: 1 },
|
||||
{ name: 'informeGlobal', maxCount: 1 },
|
||||
]),
|
||||
)
|
||||
async actualizarServicio(
|
||||
@UploadedFiles() files: Record<string, Express.Multer.File[]>,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const data = JSON.parse(dataJson);
|
||||
return this.servicioService.update(data, files);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user