Refactor MailController and MailService for improved readability and consistency

This commit is contained in:
jorgemike
2025-06-28 18:21:12 -06:00
parent a220f2933d
commit 4a24eafa0d
2 changed files with 51 additions and 112 deletions
+16 -27
View File
@@ -7,58 +7,47 @@ import {
} from '@nestjs/common';
import { MailService } from './mail.service';
import { ApiTags } from '@nestjs/swagger';
import { ApiSendMail} from './mail.decorators';
import { ApiSendMail } from './mail.decorators';
import { SistemaService } from 'src/sistema/sistema.service';
import { SendCorreoDto } from 'src/mail/dto/send-email.dto';
import { AuthService } from 'src/auth/auth.service';
@ApiTags('Mail') // Grupo de endpoints
@Controller('mail')
export class MailController {
constructor(
private readonly sistemaService: SistemaService,
private readonly mailService: MailService,
// private readonly excelService: ExcelService,
private readonly authService: AuthService
// private readonly excelService: ExcelService,
private readonly authService: AuthService,
) {}
// Endpoint para enviar correos a través de una solicitud POST
@Post('send')
@ApiSendMail()
async sendMail(
@Headers() headers:{token:string},
@Body() body: SendCorreoDto
@Headers() headers: { token: string },
@Body() body: SendCorreoDto,
) {
if (!headers.token) {
throw new UnauthorizedException('Header "token" es requerido');
}
const result =
await this.mailService.sendMail(body,headers.token)
.then((value) => {
console.log("ya acabe el correo", value);
})
.catch((err)=>{
console.log(err)
})
const result = await this.mailService
.sendMail(body, headers.token)
.then((value) => {
console.log('ya acabe el correo', value);
})
.catch((err) => {
console.log(err);
});
// sistem
return result;
}
/*
/*
@Post('send-excel')
@UseInterceptors(FileInterceptor('file'))