Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 87f11ae968 | |||
| becf48529d | |||
| 028a8b277d | |||
| 535e030927 | |||
| a53d9ddabe |
Generated
+1186
-1258
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -8,7 +8,7 @@
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "source ~/.nvm/nvm.sh && nvm use 22.10.0 && npm install && nest start",
|
||||
"start": "source ~/.nvm/nvm.sh && nvm use 22.10.0 && npm install && nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
@@ -29,29 +29,28 @@
|
||||
"@nestjs/serve-static": "^3.0.1",
|
||||
"@nestjs/swagger": "^6.2.1",
|
||||
"@nestjs/typeorm": "^9.0.1",
|
||||
"@types/multer": "^1.4.7",
|
||||
"bcrypt": "^5.1.0",
|
||||
"blob-stream": "^0.1.3",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.0",
|
||||
"class-validator": "^0.15.1",
|
||||
"date-fns": "^2.30.0",
|
||||
"exceljs": "^4.4.0",
|
||||
"moment": "^2.29.4",
|
||||
"moment": "^2.30.1",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"mysql2": "^3.14.3",
|
||||
"mysql2": "^3.23.2",
|
||||
"nodemailer": "^6.9.1",
|
||||
"passport": "^0.6.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"passport-local": "^1.0.0",
|
||||
"pdf-lib": "^1.17.1",
|
||||
"pdfkit": "^0.13.0",
|
||||
"pg": "^8.9.0",
|
||||
"pg": "^8.22.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rxjs": "^7.2.0",
|
||||
"rxjs": "^7.8.2",
|
||||
"swagger-ui-express": "^4.6.1",
|
||||
"sybase": "^1.2.3",
|
||||
"typeorm": "^0.3.12",
|
||||
"uuid": "^9.0.0",
|
||||
"uuid": "^9.0.1",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -59,10 +58,11 @@
|
||||
"@nestjs/cli": "^9.0.0",
|
||||
"@nestjs/schematics": "^9.0.0",
|
||||
"@nestjs/testing": "^9.0.0",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/express": "^5.0.6",
|
||||
"@types/jest": "29.2.4",
|
||||
"@types/multer": "^2.2.0",
|
||||
"@types/node": "18.11.18",
|
||||
"@types/passport-local": "^1.0.35",
|
||||
"@types/passport-local": "^1.0.38",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||
"@typescript-eslint/parser": "^5.0.0",
|
||||
@@ -75,8 +75,8 @@
|
||||
"source-map-support": "^0.5.20",
|
||||
"supertest": "^6.1.3",
|
||||
"ts-jest": "29.0.3",
|
||||
"ts-loader": "^9.2.3",
|
||||
"ts-node": "^10.0.0",
|
||||
"ts-loader": "^9.6.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig-paths": "4.1.1",
|
||||
"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
@@ -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: [
|
||||
@@ -75,7 +76,7 @@ import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity';
|
||||
username: configService.get('DB_USER'),
|
||||
password: configService.get('DB_PASSWORD'),
|
||||
database: configService.get('DB_NAME'),
|
||||
synchronize: false,
|
||||
synchronize: true,
|
||||
entities: [
|
||||
Evento,
|
||||
Participante,
|
||||
@@ -134,6 +135,7 @@ import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity';
|
||||
controllers: [
|
||||
AppController,
|
||||
InscripcionStatusController,
|
||||
TylController,
|
||||
],
|
||||
providers: [AppService, InscripcionStatusService],
|
||||
})
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
Res,
|
||||
UploadedFile,
|
||||
UseInterceptors,
|
||||
@@ -57,6 +58,11 @@ export class CarruselController {
|
||||
return this.carruselService.updateImagenCarrusel(id, carruselDto);
|
||||
}
|
||||
|
||||
@Put('updateOrden')
|
||||
async updateOrden(@Body() banners: { id: number; orden: number}[]) {
|
||||
return this.carruselService.updateOrden(banners);
|
||||
}
|
||||
|
||||
@Delete('delete/:id')
|
||||
deleteImagenByRuta(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.carruselService.deleteImagenByRuta(id);
|
||||
|
||||
@@ -39,7 +39,25 @@ 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.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 {
|
||||
const carrusel = await this.carruselRepository.save(carruselCreate);
|
||||
@@ -60,6 +78,8 @@ export class CarruselService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async updateImagenCarrusel(
|
||||
id: number,
|
||||
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) {
|
||||
try {
|
||||
const res = await this.carruselRepository.findOne({
|
||||
@@ -111,7 +155,13 @@ export class CarruselService {
|
||||
}
|
||||
|
||||
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 }> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IsNotEmpty, IsOptional } from "class-validator";
|
||||
import { IsNotEmpty, IsOptional, IsNumber } from "class-validator";
|
||||
|
||||
export class carruselDto {
|
||||
@IsNotEmpty()
|
||||
@@ -7,7 +7,7 @@ export class carruselDto {
|
||||
@IsNotEmpty()
|
||||
link: string
|
||||
|
||||
// @IsNotEmpty() valida que no sea nulo ni undefined ni cadena vacía
|
||||
// @IsOptional()
|
||||
// orden?: string
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
orden?: number
|
||||
}
|
||||
@@ -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: number
|
||||
}
|
||||
@@ -54,6 +54,8 @@ export class ComentariosService {
|
||||
if (to) {
|
||||
query.andWhere('comentarios.fecha_registro <= :to', { to: new Date(to) });
|
||||
}
|
||||
|
||||
query.orderBy('comentarios.fecha_registro', 'DESC');
|
||||
|
||||
return await query.getMany();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,11 @@ export class EventosService {
|
||||
) {}
|
||||
|
||||
getEventos() {
|
||||
return this.eventoRepository.find();
|
||||
return this.eventoRepository.find({
|
||||
order: {
|
||||
fecha_inicio: 'DESC',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public getEventosPorId(id: number) {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user