5 Commits

14 changed files with 1330 additions and 1281 deletions
+1186 -1258
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -29,29 +29,28 @@
"@nestjs/serve-static": "^3.0.1", "@nestjs/serve-static": "^3.0.1",
"@nestjs/swagger": "^6.2.1", "@nestjs/swagger": "^6.2.1",
"@nestjs/typeorm": "^9.0.1", "@nestjs/typeorm": "^9.0.1",
"@types/multer": "^1.4.7",
"bcrypt": "^5.1.0", "bcrypt": "^5.1.0",
"blob-stream": "^0.1.3", "blob-stream": "^0.1.3",
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
"class-validator": "^0.14.0", "class-validator": "^0.15.1",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"exceljs": "^4.4.0", "exceljs": "^4.4.0",
"moment": "^2.29.4", "moment": "^2.30.1",
"multer": "^1.4.5-lts.1", "multer": "^1.4.5-lts.1",
"mysql2": "^3.14.3", "mysql2": "^3.23.2",
"nodemailer": "^6.9.1", "nodemailer": "^6.9.1",
"passport": "^0.6.0", "passport": "^0.6.0",
"passport-jwt": "^4.0.1", "passport-jwt": "^4.0.1",
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"pdf-lib": "^1.17.1", "pdf-lib": "^1.17.1",
"pdfkit": "^0.13.0", "pdfkit": "^0.13.0",
"pg": "^8.9.0", "pg": "^8.22.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0", "rxjs": "^7.8.2",
"swagger-ui-express": "^4.6.1", "swagger-ui-express": "^4.6.1",
"sybase": "^1.2.3", "sybase": "^1.2.3",
"typeorm": "^0.3.12", "typeorm": "^0.3.12",
"uuid": "^9.0.0", "uuid": "^9.0.1",
"xlsx": "^0.18.5" "xlsx": "^0.18.5"
}, },
"devDependencies": { "devDependencies": {
@@ -59,10 +58,11 @@
"@nestjs/cli": "^9.0.0", "@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0", "@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0", "@nestjs/testing": "^9.0.0",
"@types/express": "^4.17.13", "@types/express": "^5.0.6",
"@types/jest": "29.2.4", "@types/jest": "29.2.4",
"@types/multer": "^2.2.0",
"@types/node": "18.11.18", "@types/node": "18.11.18",
"@types/passport-local": "^1.0.35", "@types/passport-local": "^1.0.38",
"@types/supertest": "^2.0.11", "@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0", "@typescript-eslint/parser": "^5.0.0",
@@ -75,8 +75,8 @@
"source-map-support": "^0.5.20", "source-map-support": "^0.5.20",
"supertest": "^6.1.3", "supertest": "^6.1.3",
"ts-jest": "29.0.3", "ts-jest": "29.0.3",
"ts-loader": "^9.2.3", "ts-loader": "^9.6.2",
"ts-node": "^10.0.0", "ts-node": "^10.9.2",
"tsconfig-paths": "4.1.1", "tsconfig-paths": "4.1.1",
"typescript": "^4.7.4" "typescript": "^4.7.4"
}, },
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

+3 -1
View File
@@ -54,6 +54,7 @@ import { ComentariosModule } from './comentarios/comentarios.module';
import { Comentarios } from './comentarios/entity/comentarios.entity'; import { Comentarios } from './comentarios/entity/comentarios.entity';
import { AlmacenamientoModule } from './almacenamiento/almacenamiento.module'; import { AlmacenamientoModule } from './almacenamiento/almacenamiento.module';
import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity'; import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity';
import { TylController } from './tyl/tyl.controller';
@Module({ @Module({
imports: [ imports: [
@@ -75,7 +76,7 @@ import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity';
username: configService.get('DB_USER'), username: configService.get('DB_USER'),
password: configService.get('DB_PASSWORD'), password: configService.get('DB_PASSWORD'),
database: configService.get('DB_NAME'), database: configService.get('DB_NAME'),
synchronize: false, synchronize: true,
entities: [ entities: [
Evento, Evento,
Participante, Participante,
@@ -134,6 +135,7 @@ import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity';
controllers: [ controllers: [
AppController, AppController,
InscripcionStatusController, InscripcionStatusController,
TylController,
], ],
providers: [AppService, InscripcionStatusService], providers: [AppService, InscripcionStatusService],
}) })
+6
View File
@@ -7,6 +7,7 @@ import {
ParseIntPipe, ParseIntPipe,
Patch, Patch,
Post, Post,
Put,
Res, Res,
UploadedFile, UploadedFile,
UseInterceptors, UseInterceptors,
@@ -57,6 +58,11 @@ export class CarruselController {
return this.carruselService.updateImagenCarrusel(id, carruselDto); return this.carruselService.updateImagenCarrusel(id, carruselDto);
} }
@Put('updateOrden')
async updateOrden(@Body() banners: { id: number; orden: number}[]) {
return this.carruselService.updateOrden(banners);
}
@Delete('delete/:id') @Delete('delete/:id')
deleteImagenByRuta(@Param('id', ParseIntPipe) id: number) { deleteImagenByRuta(@Param('id', ParseIntPipe) id: number) {
return this.carruselService.deleteImagenByRuta(id); return this.carruselService.deleteImagenByRuta(id);
+52 -2
View File
@@ -39,7 +39,25 @@ export class CarruselService {
}); });
} }
carruselDto.ruta = `/public/carrusel/${filename}`; carruselDto.ruta = `/public/carrusel/${filename}`;
const carruselCreate = this.carruselRepository.create(carruselDto);
// Obtener el banner con mayor orden
const ultimoCarrusel = await this.carruselRepository.find({
order: {
orden: 'DESC',
},
take: 1
});
const ultimoOrden = ultimoCarrusel.length > 0 ? ultimoCarrusel[0].orden : 0;
// const siguienteOrden = ultimoCarrusel
// ? ultimoCarrusel.orden + 1
// : 1;
// const carruselCreate = this.carruselRepository.create(carruselDto);
const carruselCreate = this.carruselRepository.create({
...carruselDto,
orden: ultimoOrden + 1,
});
try { try {
const carrusel = await this.carruselRepository.save(carruselCreate); const carrusel = await this.carruselRepository.save(carruselCreate);
@@ -60,6 +78,8 @@ export class CarruselService {
}); });
} }
} }
async updateImagenCarrusel( async updateImagenCarrusel(
id: number, id: number,
carruselDto: carruselDto, carruselDto: carruselDto,
@@ -95,6 +115,30 @@ export class CarruselService {
}); });
} }
} }
// Actualizar todas las imagenes por orden
async updateOrden(banners: { id: number; orden: number}[]) {
// Paso 1.- Mandar los banner a un orden extremo para que no causen conflicto al actualizar
for( const banner of banners ) {
await this.carruselRepository.update(
{ id_imagen_carrusel: banner.id },
{ orden: banner.orden + 1000 },
);
}
// Paso 2.- Actualizamos al nuevo orden
for (const banner of banners ) {
await this.carruselRepository.update(
{ id_imagen_carrusel: banner.id },
{ orden: banner.orden },
)
}
return {
message: 'Orden actualizado correctamente',
}
}
async deleteImagenByRuta(id: number) { async deleteImagenByRuta(id: number) {
try { try {
const res = await this.carruselRepository.findOne({ const res = await this.carruselRepository.findOne({
@@ -111,7 +155,13 @@ export class CarruselService {
} }
getAllImages(): Promise<Carrusel[]> { getAllImages(): Promise<Carrusel[]> {
return this.carruselRepository.find(); // return this.carruselRepository.find();
return this.carruselRepository.find({
order: {
orden: 'ASC',
},
});
// return this.carruselRepository.find();
} }
async deleteAllCarrusel(): Promise<{ message: string }> { async deleteAllCarrusel(): Promise<{ message: string }> {
+4 -4
View File
@@ -1,4 +1,4 @@
import { IsNotEmpty, IsOptional } from "class-validator"; import { IsNotEmpty, IsOptional, IsNumber } from "class-validator";
export class carruselDto { export class carruselDto {
@IsNotEmpty() @IsNotEmpty()
@@ -7,7 +7,7 @@ export class carruselDto {
@IsNotEmpty() @IsNotEmpty()
link: string link: string
// @IsNotEmpty() valida que no sea nulo ni undefined ni cadena vacía @IsOptional()
// @IsOptional() @IsNumber()
// orden?: string orden?: number
} }
+2 -3
View File
@@ -13,7 +13,6 @@ export class Carrusel {
link: string link: string
/* "https://www.acatlan.unam.mx/" */ /* "https://www.acatlan.unam.mx/" */
// @Column({length: 20}) @Column({ type: 'int', unique: true })
// orden: string orden: number
} }
+2
View File
@@ -55,6 +55,8 @@ export class ComentariosService {
query.andWhere('comentarios.fecha_registro <= :to', { to: new Date(to) }); query.andWhere('comentarios.fecha_registro <= :to', { to: new Date(to) });
} }
query.orderBy('comentarios.fecha_registro', 'DESC');
return await query.getMany(); return await query.getMany();
} }
+5 -1
View File
@@ -20,7 +20,11 @@ export class EventosService {
) {} ) {}
getEventos() { getEventos() {
return this.eventoRepository.find(); return this.eventoRepository.find({
order: {
fecha_inicio: 'DESC',
},
});
} }
public getEventosPorId(id: number) { public getEventosPorId(id: number) {
+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');
}
}
}