Modificaciones del carrusel

This commit is contained in:
Patriots01
2026-08-03 11:14:41 -06:00
parent f02dd40d51
commit 028a8b277d
6 changed files with 80 additions and 4 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

+2
View File
@@ -54,6 +54,7 @@ import { ComentariosModule } from './comentarios/comentarios.module';
import { Comentarios } from './comentarios/entity/comentarios.entity';
import { AlmacenamientoModule } from './almacenamiento/almacenamiento.module';
import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity';
import { TylController } from './tyl/tyl.controller';
@Module({
imports: [
@@ -134,6 +135,7 @@ import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity';
controllers: [
AppController,
InscripcionStatusController,
TylController,
],
providers: [AppService, InscripcionStatusService],
})
+18 -1
View File
@@ -39,7 +39,24 @@ export class CarruselService {
});
}
carruselDto.ruta = `/public/carrusel/${filename}`;
const carruselCreate = this.carruselRepository.create(carruselDto);
// Obtener el banner con mayor orden
const ultimoCarrusel = await this.carruselRepository.findOne({
order: {
orden: 'DESC',
},
});
const siguienteOrden = ultimoCarrusel
? ultimoCarrusel.orden + 1
: 1;
// const carruselCreate = this.carruselRepository.create(carruselDto);
const carruselCreate = this.carruselRepository.create({
...carruselDto,
orden: siguienteOrden,
});
try {
const carrusel = await this.carruselRepository.save(carruselCreate);
+2 -3
View File
@@ -13,7 +13,6 @@ export class Carrusel {
link: string
/* "https://www.acatlan.unam.mx/" */
// @Column({length: 20})
// orden: string
@Column({ type: 'int', unique: true })
orden: string
}
+18
View File
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TylController } from './tyl.controller';
describe('TylController', () => {
let controller: TylController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [TylController],
}).compile();
controller = module.get<TylController>(TylController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
+40
View File
@@ -0,0 +1,40 @@
import { Body, Controller, InternalServerErrorException, Post } from '@nestjs/common';
@Controller('tyl')
export class TylController {
@Post('')
async enviarTyl(@Body() body: { email: string }) {
try {
const user = 'acatlan'
const api = 'LW2rtatYP8o2PhCkIqeJV94d6a60cSvTmJXPbRpP';
const params = new URLSearchParams();
params.append('user_name', user!);
params.append('email', body.email);
params.append('api_key', process.env.API_KEY!);
const response = await fetch(
'https://accede.estudio.app/ventas-acatlan',
{
method: 'POST',
// headers: {
// 'Content-Type': 'application/x-www-form-urlencoded',
// },
body: params,
redirect: 'manual',
}
);
console.log('respuesta', response);
const redirectUrl = response.headers.get('location');
console.log('redirect', redirectUrl)
return { redirectUrl };
} catch (error) {
throw new InternalServerErrorException('Error al conectar con API externa');
}
}
}