Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 535e030927 | |||
| a53d9ddabe |
Binary file not shown.
|
Before Width: | Height: | Size: 194 KiB |
+1
-1
@@ -75,7 +75,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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -95,6 +95,21 @@ export class CarruselService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Actualizar todas las imagenes por orden
|
||||
async updateOrden(banners: { id: number; orden: number}[]) {
|
||||
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 +126,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
|
||||
@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', default: 0 })
|
||||
orden: number
|
||||
}
|
||||
@@ -55,6 +55,8 @@ export class ComentariosService {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user