added programa, area ubicacion and programa_equipo
This commit is contained in:
@@ -37,7 +37,7 @@ export class AlumnoInscritoService {
|
||||
|
||||
async findByAlumno(id_cuenta: number): Promise<AlumnoInscrito[]> {
|
||||
return this.alumnoInscritoRepo.find({
|
||||
where: { alumno: { id_cuenta } },
|
||||
where: { alumno: { id_cuenta }, periodo:{id_periodo:24}},
|
||||
relations: ['alumno', 'periodo', 'plataforma'],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
|
||||
import { AlumnoSancionService } from './alumno_sancion.service';
|
||||
import { CreateAlumnoSancionDto } from './dto/create-alumno_sancion.dto';
|
||||
|
||||
@@ -11,14 +11,14 @@ export class AlumnoSancionController {
|
||||
return this.alumnoSancionService.create(createAlumnoSancionDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.alumnoSancionService.findAll();
|
||||
@Get(':id')
|
||||
findbyStudent(@Param('id') id: number) {
|
||||
return this.alumnoSancionService.findbyStudent(+id);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: number) {
|
||||
return this.alumnoSancionService.findOne(+id);
|
||||
@Delete()
|
||||
deleteSancion(){
|
||||
|
||||
}
|
||||
}
|
||||
//IO
|
||||
@@ -36,16 +36,25 @@ export class AlumnoSancionService {
|
||||
return await this.alumnosancionRepository.save(alumnosancion);
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all alumnoSancion`;
|
||||
}
|
||||
|
||||
async findOne(id_cuenta: number): Promise<AlumnoSancion> {
|
||||
const alusancion = await this.alumnosancionRepository.findOne({
|
||||
async findbyStudent(id_cuenta: number): Promise<AlumnoSancion[]> {
|
||||
const alusancion = await this.alumnosancionRepository.find({
|
||||
where: { alumno: { id_cuenta } },
|
||||
select:{
|
||||
id_alumno_sancion:true,
|
||||
fecha_inicio:true,
|
||||
alumno:{
|
||||
id_cuenta:true,
|
||||
nombre:true
|
||||
},
|
||||
sancion:{
|
||||
id_sancion:true,
|
||||
sancion:true,
|
||||
duracion:true
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!alusancion) {
|
||||
throw new NotFoundException(`Student with ID ${id_cuenta} not found`);
|
||||
throw new NotFoundException(`student without sancion`);
|
||||
}
|
||||
return alusancion;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,12 @@ import {
|
||||
import { EquipoModule } from './equipo/equipo.module';
|
||||
import { CarreraModule } from './carrera/carrera.module';
|
||||
import { Carrera } from './carrera/entities/carrera.entity';
|
||||
import { Equipo } from './equipo/entities/equipo.entity';
|
||||
import { AreaUbicacionModule } from './area_ubicacion/area_ubicacion.module';
|
||||
import { ProgramaModule } from './programa/programa.module';
|
||||
import { AreaUbicacion } from './area_ubicacion/entities/area_ubicacion.entity';
|
||||
import { Programa } from './programa/entities/programa.entity';
|
||||
import { ProgramaEquipoModule } from './programa_equipo/programa_equipo.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -60,6 +66,9 @@ import { Carrera } from './carrera/entities/carrera.entity';
|
||||
Mesa,
|
||||
AlumnoInscrito,
|
||||
Plataforma,
|
||||
Equipo,
|
||||
AreaUbicacion,
|
||||
Programa,
|
||||
],
|
||||
synchronize: false, //Never change to true in production!
|
||||
}),
|
||||
@@ -77,6 +86,9 @@ import { Carrera } from './carrera/entities/carrera.entity';
|
||||
AlumnoInscritoModule,
|
||||
EquipoModule,
|
||||
CarreraModule,
|
||||
AreaUbicacionModule,
|
||||
ProgramaModule,
|
||||
ProgramaEquipoModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { AreaUbicacionService } from './area_ubicacion.service';
|
||||
|
||||
@Controller('area-ubicacion')
|
||||
export class AreaUbicacionController {
|
||||
constructor(private readonly areaUbicacionService: AreaUbicacionService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.areaUbicacionService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.areaUbicacionService.findOne(+id);
|
||||
}
|
||||
}
|
||||
//IO
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AreaUbicacionService } from './area_ubicacion.service';
|
||||
import { AreaUbicacionController } from './area_ubicacion.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { AreaUbicacion } from './entities/area_ubicacion.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([AreaUbicacion])],
|
||||
controllers: [AreaUbicacionController],
|
||||
providers: [AreaUbicacionService],
|
||||
})
|
||||
export class AreaUbicacionModule {}
|
||||
//IO
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { AreaUbicacion } from './entities/area_ubicacion.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class AreaUbicacionService {
|
||||
constructor(
|
||||
@InjectRepository(AreaUbicacion)
|
||||
private readonly areaUbicacionRepository: Repository<AreaUbicacion>,
|
||||
) {}
|
||||
findAll() {
|
||||
return this.areaUbicacionRepository.find();
|
||||
}
|
||||
|
||||
findOne(id_area_ubicacion: number) {
|
||||
const area = this.areaUbicacionRepository.findOne({
|
||||
where: { id_area_ubicacion },
|
||||
});
|
||||
|
||||
if(!area){
|
||||
return "this area dosnt exist"
|
||||
}
|
||||
|
||||
return area
|
||||
}
|
||||
}
|
||||
//IO
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Equipo } from 'src/equipo/entities/equipo.entity';
|
||||
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'area_ubicacion' })
|
||||
export class AreaUbicacion {
|
||||
@PrimaryGeneratedColumn({ name: 'id_area_ubicacion' })
|
||||
id_area_ubicacion: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 45, nullable: false })
|
||||
area: string;
|
||||
|
||||
@Column({ type: 'char', length: 1, default: '0', nullable: false })
|
||||
extra: string;
|
||||
|
||||
@OneToMany(() => Equipo, (equipo) => equipo.areaUbicacion)
|
||||
equipos: Equipo[];
|
||||
}
|
||||
//IO
|
||||
@@ -1,3 +1,5 @@
|
||||
import { AreaUbicacion } from 'src/area_ubicacion/entities/area_ubicacion.entity';
|
||||
import { ProgramaEquipo } from 'src/programa_equipo/entities/programa_equipo.entity';
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
@@ -21,22 +23,6 @@ export class Plataforma {
|
||||
equipos: Equipo[];
|
||||
}
|
||||
|
||||
@Entity({ name: 'area_ubicacion' })
|
||||
export class AreaUbicacion {
|
||||
@PrimaryGeneratedColumn({ name: 'id_area_ubicacion', type: 'int' })
|
||||
id_area_ubicacion: number;
|
||||
|
||||
@Column({ name: 'area', type: 'varchar', length: 45 })
|
||||
area: string;
|
||||
|
||||
@Column({ name: 'extra', type: 'char', length: 1, default: '0' })
|
||||
extra: string;
|
||||
|
||||
// Relación con equipos
|
||||
@OneToMany(() => Equipo, (equipo) => equipo.areaUbicacion)
|
||||
equipos: Equipo[];
|
||||
}
|
||||
|
||||
@Entity({ name: 'equipo' })
|
||||
@Unique('indice_unico_ubicacion', ['ubicacion'])
|
||||
export class Equipo {
|
||||
@@ -77,4 +63,7 @@ export class Equipo {
|
||||
})
|
||||
@JoinColumn({ name: 'id_area_ubicacion' })
|
||||
areaUbicacion: AreaUbicacion;
|
||||
|
||||
@OneToMany(() => ProgramaEquipo, (programaEquipo) => programaEquipo.equipo)
|
||||
programaEquipos: ProgramaEquipo[];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { EquipoService } from './equipo.service';
|
||||
import { CreateEquipoDto } from './dto/create-equipo.dto';
|
||||
import { UpdateEquipoDto } from './dto/update-equipo.dto';
|
||||
|
||||
@Controller('equipo')
|
||||
export class EquipoController {
|
||||
@@ -13,7 +11,8 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
findOne(@Param('id') id: number) {
|
||||
return this.equipoService.findOne(+id);
|
||||
}
|
||||
}
|
||||
//IO
|
||||
@@ -10,3 +10,4 @@ import { Equipo } from './entities/equipo.entity';
|
||||
providers: [EquipoService],
|
||||
})
|
||||
export class EquipoModule {}
|
||||
//IO
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateEquipoDto } from './dto/create-equipo.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Equipo } from './entities/equipo.entity';
|
||||
@@ -17,3 +16,4 @@ private readonly equipoRepository: Repository<Equipo>){}
|
||||
return this.equipoRepository.findOne({where:{id_equipo}});
|
||||
}
|
||||
}
|
||||
//IO
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateProgramaDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateProgramaDto } from './create-programa.dto';
|
||||
|
||||
export class UpdateProgramaDto extends PartialType(CreateProgramaDto) {}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ProgramaEquipo } from 'src/programa_equipo/entities/programa_equipo.entity';
|
||||
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'programa' })
|
||||
export class Programa {
|
||||
@PrimaryGeneratedColumn({ name: 'id_programa' })
|
||||
id_programa: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 45, nullable: false })
|
||||
programa: string;
|
||||
|
||||
@OneToMany(() => ProgramaEquipo, (programaEquipo) => programaEquipo.programa)
|
||||
programaEquipos: ProgramaEquipo[];
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { ProgramaService } from './programa.service';
|
||||
import { CreateProgramaDto } from './dto/create-programa.dto';
|
||||
import { UpdateProgramaDto } from './dto/update-programa.dto';
|
||||
|
||||
@Controller('programa')
|
||||
export class ProgramaController {
|
||||
constructor(private readonly programaService: ProgramaService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createProgramaDto: CreateProgramaDto) {
|
||||
return this.programaService.create(createProgramaDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.programaService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.programaService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateProgramaDto: UpdateProgramaDto) {
|
||||
return this.programaService.update(+id, updateProgramaDto);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ProgramaService } from './programa.service';
|
||||
import { ProgramaController } from './programa.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Programa } from './entities/programa.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([Programa])],
|
||||
controllers: [ProgramaController],
|
||||
providers: [ProgramaService],
|
||||
})
|
||||
export class ProgramaModule {}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateProgramaDto } from './dto/create-programa.dto';
|
||||
import { UpdateProgramaDto } from './dto/update-programa.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Programa } from './entities/programa.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class ProgramaService {
|
||||
constructor(
|
||||
@InjectRepository(Programa)
|
||||
private readonly programaRepository:Repository<Programa>
|
||||
){}
|
||||
create(createProgramaDto: CreateProgramaDto) {
|
||||
return 'This action adds a new programa';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.programaRepository.find();
|
||||
}
|
||||
|
||||
findOne(id_programa: number) {
|
||||
const programa = this.programaRepository.findOne({where:{id_programa}})
|
||||
|
||||
if(!programa){
|
||||
return "this program dosnt exist"
|
||||
}
|
||||
|
||||
return programa;
|
||||
}
|
||||
|
||||
update(id: number, updateProgramaDto: UpdateProgramaDto) {
|
||||
return `This action updates a #${id} programa`;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateProgramaEquipoDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateProgramaEquipoDto } from './create-programa_equipo.dto';
|
||||
|
||||
export class UpdateProgramaEquipoDto extends PartialType(CreateProgramaEquipoDto) {}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Equipo } from "src/equipo/entities/equipo.entity";
|
||||
import { Programa } from "src/programa/entities/programa.entity";
|
||||
import { Entity, PrimaryColumn, ManyToOne, JoinColumn } from "typeorm";
|
||||
|
||||
@Entity("programa_equipo")
|
||||
export class ProgramaEquipo {
|
||||
@PrimaryColumn({ name: "id_programa", type: "int" })
|
||||
id_programa: number;
|
||||
|
||||
@PrimaryColumn({ name: "id_equipo", type: "int" })
|
||||
id_equipo: number;
|
||||
|
||||
@ManyToOne(() => Programa, (programa) => programa.programaEquipos, {
|
||||
onUpdate: "CASCADE",
|
||||
})
|
||||
@JoinColumn({ name: "id_programa" })
|
||||
programa: Programa;
|
||||
|
||||
@ManyToOne(() => Equipo, (equipo) => equipo.programaEquipos, {
|
||||
onUpdate: "CASCADE",
|
||||
})
|
||||
@JoinColumn({ name: "id_equipo" })
|
||||
equipo: Equipo;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { ProgramaEquipoService } from './programa_equipo.service';
|
||||
import { CreateProgramaEquipoDto } from './dto/create-programa_equipo.dto';
|
||||
import { UpdateProgramaEquipoDto } from './dto/update-programa_equipo.dto';
|
||||
|
||||
@Controller('programa-equipo')
|
||||
export class ProgramaEquipoController {
|
||||
constructor(private readonly programaEquipoService: ProgramaEquipoService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.programaEquipoService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.programaEquipoService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateProgramaEquipoDto: UpdateProgramaEquipoDto) {
|
||||
return this.programaEquipoService.update(+id, updateProgramaEquipoDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ProgramaEquipoService } from './programa_equipo.service';
|
||||
import { ProgramaEquipoController } from './programa_equipo.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ProgramaEquipo } from './entities/programa_equipo.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([ProgramaEquipo])],
|
||||
controllers: [ProgramaEquipoController],
|
||||
providers: [ProgramaEquipoService],
|
||||
})
|
||||
export class ProgramaEquipoModule {}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { CreateProgramaEquipoDto } from './dto/create-programa_equipo.dto';
|
||||
import { UpdateProgramaEquipoDto } from './dto/update-programa_equipo.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { ProgramaEquipo } from './entities/programa_equipo.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class ProgramaEquipoService {
|
||||
constructor(
|
||||
@InjectRepository(ProgramaEquipo)
|
||||
private readonly ProgramaEquipoRepository: Repository<ProgramaEquipo>,
|
||||
) {}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all programaEquipo`;
|
||||
}
|
||||
|
||||
async findOne(id_equipo: number) {
|
||||
const equipo = await this.ProgramaEquipoRepository.find({
|
||||
where: { id_equipo },
|
||||
});
|
||||
|
||||
if (equipo.length === 0) {
|
||||
throw new NotFoundException(`machine without programs`);
|
||||
}
|
||||
|
||||
return equipo;
|
||||
}
|
||||
|
||||
update(id: number, updateProgramaEquipoDto: UpdateProgramaEquipoDto) {
|
||||
return `This action updates a #${id} programaEquipo`;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsDate, IsNumber, IsString } from 'class-validator';
|
||||
import { IsDate, IsDateString, IsNumber, IsString } from 'class-validator';
|
||||
|
||||
export class CreateReciboDto {
|
||||
|
||||
@@ -13,3 +13,11 @@ export class CreateReciboDto {
|
||||
@Type(() => Date)
|
||||
fecha_recibo: Date;
|
||||
}
|
||||
|
||||
export class FindReciboByRangeDto {
|
||||
@IsDateString()
|
||||
desde: string;
|
||||
|
||||
@IsDateString()
|
||||
hasta: string;
|
||||
}
|
||||
@@ -29,13 +29,13 @@ export class Recibo {
|
||||
monto: number;
|
||||
|
||||
@Column({ name: 'fecha_recibo', type: 'date', nullable: false })
|
||||
fecha_recibo: Date ;
|
||||
fecha_recibo: Date;
|
||||
|
||||
@ManyToOne(() => Alumno, (alum) => alum.id_cuenta, {})
|
||||
@ManyToOne(() => Alumno, (alum) => alum.id_cuenta, { eager: true })
|
||||
@JoinColumn({ name: 'id_cuenta' })
|
||||
alum: Alumno;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id_usuario, {})
|
||||
@ManyToOne(() => User, (user) => user.id_usuario, { eager: true })
|
||||
@JoinColumn({ name: 'id_usuario' })
|
||||
user: User;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,15 @@ import {
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import { ReciboService } from './recibo.service';
|
||||
import { FindReciboByRangeDto } from './dto/create-recibo.dto';
|
||||
|
||||
@Controller('recibo')
|
||||
export class ReciboController {
|
||||
constructor(private readonly reciboService: ReciboService) {}
|
||||
|
||||
@Post('rango')
|
||||
async findByDateRange(@Body() data: FindReciboByRangeDto) {
|
||||
return this.reciboService.findByDateRange(data.desde, data.hasta);
|
||||
}
|
||||
}
|
||||
//IO
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ConflictException, Injectable } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Recibo } from './entities/recibo.entity';
|
||||
import { EntityManager, Repository } from 'typeorm';
|
||||
import { Between, EntityManager, Repository } from 'typeorm';
|
||||
import { CreateReciboDto } from './dto/create-recibo.dto';
|
||||
|
||||
@Injectable()
|
||||
@@ -23,5 +23,17 @@ export class ReciboService {
|
||||
const details = repo.create(data);
|
||||
return await repo.save(details);
|
||||
}
|
||||
|
||||
async findByDateRange(desde: string, hasta: string) {
|
||||
// Convertimos strings a objetos Date
|
||||
const fechaDesde = new Date(desde);
|
||||
const fechaHasta = new Date(hasta);
|
||||
|
||||
return await this.reciboRepository.find({
|
||||
where: {
|
||||
fecha_recibo: Between(fechaDesde, fechaHasta),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
//IO
|
||||
|
||||
Reference in New Issue
Block a user