master #10
+8
-1
@@ -50,6 +50,8 @@ import { ServeStaticModule } from '@nestjs/serve-static';
|
||||
import { join } from 'path';
|
||||
import { CarruselModule } from './carrusel/carrusel.module';
|
||||
import { Carrusel } from './entities/carrusel.entity';
|
||||
import { ComentariosModule } from './comentarios/comentarios.module';
|
||||
import { Comentarios } from './comentarios/entity/comentarios.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -94,7 +96,9 @@ import { Carrusel } from './entities/carrusel.entity';
|
||||
EquipoEvento,
|
||||
EquipoMiembro,
|
||||
/* Agregado el 2 de junio */
|
||||
Carrusel
|
||||
Carrusel,
|
||||
/* No recuerdo porque empece a ponerle fechas */
|
||||
Comentarios,
|
||||
],
|
||||
synchronize: true,
|
||||
}),
|
||||
@@ -117,10 +121,12 @@ import { Carrusel } from './entities/carrusel.entity';
|
||||
ProyectoActividadModule,
|
||||
ActividadModule,
|
||||
EmailModule,
|
||||
ComentariosModule,
|
||||
MulterModule.register({
|
||||
dest: './uploads', // directorio de destino para guardar los archivos cargados
|
||||
}),
|
||||
CarruselModule,
|
||||
ComentariosModule,
|
||||
],
|
||||
controllers: [
|
||||
AppController,
|
||||
@@ -132,6 +138,7 @@ import { Carrusel } from './entities/carrusel.entity';
|
||||
export class AppModule {
|
||||
static port: number;
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
console.log('PORT', this.configService.get('PORT'));
|
||||
AppModule.port = this.configService.get('PORT');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export class ComentarioDto {
|
||||
from: string;
|
||||
comentario: string;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ComentariosService } from './comentarios.service';
|
||||
import { ComentarioDto } from './comentario.dto';
|
||||
|
||||
@Controller('comentarios')
|
||||
export class ComentariosController {
|
||||
constructor(private comentariosService: ComentariosService) {}
|
||||
|
||||
@Post()
|
||||
postComentario(@Body() comentario: ComentarioDto) {
|
||||
return this.comentariosService.postComentario(comentario);
|
||||
}
|
||||
|
||||
@Get()
|
||||
getComentarios() {
|
||||
return this.comentariosService.getComentarios();
|
||||
}
|
||||
|
||||
@Get('by-date')
|
||||
getComentariosByDate(
|
||||
@Query('before') before?: string,
|
||||
@Query('after') after?: string,
|
||||
@Query('from') from?: string,
|
||||
@Query('to') to?: string,
|
||||
) {
|
||||
return this.comentariosService.getComentariosByDate(before, after, from, to);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
deleteComentario(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.comentariosService.deleteComentario(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ComentariosController } from './comentarios.controller';
|
||||
import { ComentariosService } from './comentarios.service';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Comentarios } from './entity/comentarios.entity';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Comentarios])],
|
||||
controllers: [ComentariosController],
|
||||
providers: [ComentariosService],
|
||||
})
|
||||
export class ComentariosModule {}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Comentarios } from './entity/comentarios.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { ComentarioDto } from './comentario.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ComentariosService {
|
||||
constructor(
|
||||
@InjectRepository(Comentarios)
|
||||
private comentariosRepository: Repository<Comentarios>,
|
||||
) {}
|
||||
|
||||
postComentario(comentario: ComentarioDto) {
|
||||
const nuevoComentario = this.comentariosRepository.create(comentario);
|
||||
return this.comentariosRepository.save(nuevoComentario);
|
||||
}
|
||||
|
||||
getComentarios() {
|
||||
return this.comentariosRepository.find();
|
||||
}
|
||||
|
||||
async getComentariosByDate(
|
||||
before?: string,
|
||||
after?: string,
|
||||
from?: string,
|
||||
to?: string,
|
||||
) {
|
||||
const query = this.comentariosRepository.createQueryBuilder('comentarios');
|
||||
|
||||
if (before) {
|
||||
query.andWhere('comentarios.fecha_registro < :before', {
|
||||
before: new Date(before),
|
||||
});
|
||||
}
|
||||
|
||||
if (after) {
|
||||
query.andWhere('comentarios.fecha_registro > :after', { after: new Date(after) });
|
||||
}
|
||||
|
||||
if (from) {
|
||||
query.andWhere('comentarios.fecha_registro >= :from', { from: new Date(from) });
|
||||
}
|
||||
|
||||
if (to) {
|
||||
query.andWhere('comentarios.fecha_registro <= :to', { to: new Date(to) });
|
||||
}
|
||||
|
||||
return await query.getMany();
|
||||
}
|
||||
|
||||
deleteComentario(id: number) {
|
||||
return this.comentariosRepository.delete({ id_comentario: id });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn } from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
export class Comentarios {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_comentario: number;
|
||||
|
||||
@Column()
|
||||
from: string;
|
||||
|
||||
@Column()
|
||||
comentario: string;
|
||||
|
||||
@CreateDateColumn({ type: 'timestamp' })
|
||||
fecha_registro: Date;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ export class actualizarEventoDto {
|
||||
proyecto?: string;
|
||||
modalidad?: string;
|
||||
lugar?: string;
|
||||
requisitos?: string;
|
||||
observaciones?: string;
|
||||
cuota_inscripcion?: number;
|
||||
patrocinador?: string;
|
||||
tipo_acreditacion?: string;
|
||||
|
||||
@@ -6,7 +6,7 @@ export class crearEventoDto {
|
||||
modalidad: string;
|
||||
lugar: string;
|
||||
cupo: number;
|
||||
requisitos: string;
|
||||
observaciones: string;
|
||||
cuota_inscripcion: number;
|
||||
patrocinador: string;
|
||||
tipo_acreditacion: string;
|
||||
|
||||
@@ -14,52 +14,52 @@ export class Evento {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_evento: number;
|
||||
|
||||
@Column({length: 70, nullable: false })
|
||||
@Column({ length: 70, nullable: false })
|
||||
nombre: string;
|
||||
|
||||
@Column({length: 15, nullable: false })
|
||||
|
||||
@Column({ length: 15, nullable: false })
|
||||
tipo_evento: string;
|
||||
|
||||
@Column({length: 100,nullable: false})
|
||||
organizadores: string
|
||||
@Column({ length: 100, nullable: false })
|
||||
organizadores: string;
|
||||
|
||||
@Column({length:30 ,nullable: true})
|
||||
proyecto: string
|
||||
|
||||
@Column({length: 40,nullable: false})
|
||||
modalidad: string
|
||||
|
||||
@Column({length: 60,nullable: false })
|
||||
@Column({ length: 30, nullable: true })
|
||||
proyecto: string;
|
||||
|
||||
@Column({ length: 40, nullable: false })
|
||||
modalidad: string;
|
||||
|
||||
@Column({ length: 60, nullable: false })
|
||||
lugar: string;
|
||||
|
||||
@Column({nullable: false})
|
||||
@Column({ nullable: false })
|
||||
cupo: number;
|
||||
|
||||
@Column({length: 60, nullable: false })
|
||||
requisitos: string;
|
||||
@Column({ length: 300, nullable: false })
|
||||
observaciones: string;
|
||||
|
||||
@Column({type:'decimal', precision: 7, scale: 2, nullable: true })
|
||||
@Column({ type: 'decimal', precision: 7, scale: 2, nullable: true })
|
||||
cuota_inscripcion: number;
|
||||
|
||||
@Column({length: 50, nullable: true })
|
||||
@Column({ length: 50, nullable: true })
|
||||
patrocinador: string;
|
||||
|
||||
@Column({length: 40, nullable: true })
|
||||
@Column({ length: 40, nullable: true })
|
||||
tipo_acreditacion: string;
|
||||
|
||||
@Column({length: 200 ,nullable: false})
|
||||
objetivo: string
|
||||
@Column({ length: 200, nullable: false })
|
||||
objetivo: string;
|
||||
|
||||
@Column({ nullable: false, type: 'datetime' })
|
||||
fecha_inicio: Date;
|
||||
|
||||
|
||||
@Column({ nullable: false, type: 'datetime' })
|
||||
fecha_fin: Date;
|
||||
|
||||
|
||||
@Column({ nullable: false, type: 'datetime' })
|
||||
fecha_limite_inscripcion: Date;
|
||||
|
||||
@Column({length:40 ,nullable: true })
|
||||
@Column({ length: 40, nullable: true })
|
||||
horario: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@@ -71,9 +71,6 @@ export class Evento {
|
||||
)
|
||||
eventoParticipantes: EventoParticipante[];
|
||||
|
||||
@OneToMany(
|
||||
() => EquipoEvento, (equipoEvento) => equipoEvento.evento
|
||||
)
|
||||
equipoEvento: EquipoEvento
|
||||
|
||||
@OneToMany(() => EquipoEvento, (equipoEvento) => equipoEvento.evento)
|
||||
equipoEvento: EquipoEvento;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user