new Ep
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Controller, Get, Post, Body, Param } from '@nestjs/common';
|
||||
import { Controller, Get, Post, Body, Param, Patch } from '@nestjs/common';
|
||||
import { AlumnoInscritoService } from './alumno_inscrito.service';
|
||||
import { CreateAlumnoInscritoDto } from './dto/create-alumno_inscrito.dto';
|
||||
import { AlumnoInscrito } from './entities/alumno_inscrito.entity';
|
||||
@@ -28,4 +28,17 @@ export class AlumnoInscritoController {
|
||||
): Promise<AlumnoInscrito[]> {
|
||||
return this.alumnoInscritoService.findById(id_cuenta);
|
||||
}
|
||||
//pruebas borrar
|
||||
@Patch('platica/:idCuenta/:idPeriodo/:idPlataforma')
|
||||
marcarPlatica(
|
||||
@Param('idCuenta') idCuenta: number,
|
||||
@Param('idPeriodo') idPeriodo: number,
|
||||
@Param('idPlataforma') idPlataforma: number,
|
||||
) {
|
||||
return this.alumnoInscritoService.marcarPlatica(
|
||||
idCuenta,
|
||||
idPeriodo,
|
||||
idPlataforma,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@ import { AlumnoInscritoService } from './alumno_inscrito.service';
|
||||
import { AlumnoInscritoController } from './alumno_inscrito.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { AlumnoInscrito, Plataforma } from './entities/alumno_inscrito.entity';
|
||||
import { BitacoraMesa } from 'src/bitacora_mesa/entities/bitacora_mesa.entity';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([AlumnoInscrito,Plataforma])],
|
||||
imports: [TypeOrmModule.forFeature([AlumnoInscrito,Plataforma,BitacoraMesa])],
|
||||
controllers: [AlumnoInscritoController],
|
||||
providers: [AlumnoInscritoService],
|
||||
})
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
|
||||
import {
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { CreateAlumnoInscritoDto } from './dto/create-alumno_inscrito.dto';
|
||||
import { AlumnoInscrito, Plataforma } from './entities/alumno_inscrito.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
@@ -9,7 +13,7 @@ export class AlumnoInscritoService {
|
||||
constructor(
|
||||
@InjectRepository(AlumnoInscrito)
|
||||
private readonly alumnoInscritoRepo: Repository<AlumnoInscrito>,
|
||||
@InjectRepository(Plataforma)
|
||||
@InjectRepository(Plataforma)
|
||||
private readonly plataformaRepo: Repository<Plataforma>,
|
||||
) {}
|
||||
|
||||
@@ -18,7 +22,7 @@ export class AlumnoInscritoService {
|
||||
where: {
|
||||
alumno: { id_cuenta: dto.id_cuenta },
|
||||
periodo: { id_periodo: dto.id_periodo },
|
||||
plataforma:{id_plataforma:dto.id_plataforma}
|
||||
plataforma: { id_plataforma: dto.id_plataforma },
|
||||
},
|
||||
});
|
||||
|
||||
@@ -35,24 +39,49 @@ export class AlumnoInscritoService {
|
||||
async findAll(): Promise<AlumnoInscrito[]> {
|
||||
return this.alumnoInscritoRepo.find({
|
||||
relations: ['alumno', 'periodo', 'plataforma'],
|
||||
take:100,
|
||||
take: 100,
|
||||
});
|
||||
}
|
||||
|
||||
async findAllPlataforma(){
|
||||
return this.plataformaRepo.find()
|
||||
async findAllPlataforma() {
|
||||
return this.plataformaRepo.find();
|
||||
}
|
||||
|
||||
async findById(id_cuenta: number): Promise<AlumnoInscrito[]> {
|
||||
const students = await this.alumnoInscritoRepo
|
||||
.createQueryBuilder('ai')
|
||||
.leftJoinAndSelect('ai.alumno', 'alumno')
|
||||
.leftJoinAndSelect('ai.periodo', 'periodo')
|
||||
.leftJoinAndSelect('ai.plataforma', 'plataforma')
|
||||
.where('alumno.id_cuenta = :id_cuenta', { id_cuenta })
|
||||
.andWhere("periodo.activo = b'1'")
|
||||
.getMany();
|
||||
|
||||
const student = await this.alumnoInscritoRepo.find({
|
||||
where: { alumno: { id_cuenta }, periodo: { id_periodo: 27 } },
|
||||
relations: ['alumno', 'periodo', 'plataforma'],
|
||||
});
|
||||
if (students.length === 0) {
|
||||
throw new NotFoundException('unregistered student');
|
||||
}
|
||||
|
||||
if(!student) throw new NotFoundException("unregistered student")
|
||||
return students;
|
||||
}
|
||||
|
||||
console.log(student)
|
||||
return student;
|
||||
async marcarPlatica(
|
||||
idCuenta: number,
|
||||
idPeriodo: number,
|
||||
idPlataforma: number,
|
||||
) {
|
||||
const result = await this.alumnoInscritoRepo
|
||||
.createQueryBuilder()
|
||||
.update(AlumnoInscrito)
|
||||
.set({ platica: () => "b'1'" })
|
||||
.where('id_cuenta = :idCuenta', { idCuenta })
|
||||
.andWhere('id_periodo = :idPeriodo', { idPeriodo })
|
||||
.andWhere('id_plataforma = :idPlataforma', { idPlataforma })
|
||||
.execute();
|
||||
|
||||
if (result.affected === 0) {
|
||||
throw new NotFoundException('Alumno inscrito no encontrado');
|
||||
}
|
||||
|
||||
return { message: 'Plática marcada correctamente' };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Alumno } from 'src/alumno/entities/student.entity';
|
||||
import { BitacoraMesa } from 'src/bitacora_mesa/entities/bitacora_mesa.entity';
|
||||
import { Equipo } from 'src/equipo/entities/equipo.entity';
|
||||
import { Periodo } from 'src/periodo/entities/periodo.entity';
|
||||
import {
|
||||
@@ -69,4 +70,7 @@ export class AlumnoInscrito {
|
||||
default: () => "b'0'",
|
||||
})
|
||||
ad?: boolean;
|
||||
|
||||
@OneToMany(() => BitacoraMesa, (bitacoraMesa) => bitacoraMesa.alumno_inscrito)
|
||||
bitacoras_mesa: BitacoraMesa[];
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import { Programa } from './programa/entities/programa.entity';
|
||||
import { ProgramaEquipoModule } from './programa_equipo/programa_equipo.module';
|
||||
import { ProgramaEquipo } from './programa_equipo/entities/programa_equipo.entity';
|
||||
import { BitacoraMesaModule } from './bitacora_mesa/bitacora_mesa.module';
|
||||
import { BitacoraMesa } from './bitacora_mesa/entities/bitacora_mesa.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -72,6 +73,7 @@ import { BitacoraMesaModule } from './bitacora_mesa/bitacora_mesa.module';
|
||||
AreaUbicacion,
|
||||
Programa,
|
||||
ProgramaEquipo,
|
||||
BitacoraMesa,
|
||||
],
|
||||
synchronize: false, //Never change to true in production!
|
||||
}),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { BitacoraMesaService } from './bitacora_mesa.service';
|
||||
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
|
||||
import { UpdateBitacoraMesaDto } from './dto/update-bitacora_mesa.dto';
|
||||
|
||||
@Controller('bitacora-mesa')
|
||||
export class BitacoraMesaController {
|
||||
@@ -21,14 +20,4 @@ export class BitacoraMesaController {
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.bitacoraMesaService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateBitacoraMesaDto: UpdateBitacoraMesaDto) {
|
||||
return this.bitacoraMesaService.update(+id, updateBitacoraMesaDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.bitacoraMesaService.remove(+id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { BitacoraMesaService } from './bitacora_mesa.service';
|
||||
import { BitacoraMesaController } from './bitacora_mesa.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { BitacoraMesa } from './entities/bitacora_mesa.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([BitacoraMesa])],
|
||||
controllers: [BitacoraMesaController],
|
||||
providers: [BitacoraMesaService],
|
||||
})
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateBitacoraMesaDto } from './dto/create-bitacora_mesa.dto';
|
||||
import { UpdateBitacoraMesaDto } from './dto/update-bitacora_mesa.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { BitacoraMesa } from './entities/bitacora_mesa.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class BitacoraMesaService {
|
||||
constructor(
|
||||
@InjectRepository(BitacoraMesa)
|
||||
private readonly bitacoraMesaRepository: Repository<BitacoraMesa>,
|
||||
) {}
|
||||
create(createBitacoraMesaDto: CreateBitacoraMesaDto) {
|
||||
return 'This action adds a new bitacoraMesa';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all bitacoraMesa`;
|
||||
return this.bitacoraMesaRepository.find({relations:['mesa','alumno_inscrito'],take:100});
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} bitacoraMesa`;
|
||||
}
|
||||
|
||||
update(id: number, updateBitacoraMesaDto: UpdateBitacoraMesaDto) {
|
||||
return `This action updates a #${id} bitacoraMesa`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} bitacoraMesa`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,29 @@
|
||||
export class BitacoraMesa {}
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Mesa } from 'src/mesa/entities/mesa.entity';
|
||||
import { AlumnoInscrito } from 'src/alumno_inscrito/entities/alumno_inscrito.entity';
|
||||
|
||||
@Entity({ name: 'bitacora_mesa' })
|
||||
export class BitacoraMesa {
|
||||
@PrimaryGeneratedColumn({ name: 'id_bitacora_mesa' })
|
||||
id_bitacora_mesa: number;
|
||||
|
||||
@Column({ name: 'tiempo_asignado', type: 'int' })
|
||||
tiempo_asignado: number;
|
||||
|
||||
@Column({ name: 'tiempo_entrada', type: 'datetime' })
|
||||
tiempo_entrada: Date;
|
||||
|
||||
@ManyToOne(() => Mesa)
|
||||
@JoinColumn({ name: 'id_mesa' })
|
||||
mesa: Mesa;
|
||||
|
||||
@ManyToOne(() => AlumnoInscrito)
|
||||
@JoinColumn({ name: 'id_alumno_inscrito' })
|
||||
alumno_inscrito: AlumnoInscrito;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Body,
|
||||
Patch,
|
||||
Param,
|
||||
Delete,
|
||||
} from '@nestjs/common';
|
||||
import { EquipoService } from './equipo.service';
|
||||
import { Equipo } from './entities/equipo.entity';
|
||||
|
||||
@@ -7,13 +15,18 @@ export class EquipoController {
|
||||
constructor(private readonly equipoService: EquipoService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
findAll(): Promise<Equipo[]> {
|
||||
return this.equipoService.findAll();
|
||||
}
|
||||
|
||||
@Get('/student/:id')
|
||||
findOnlyUsable(@Param('id')id:number): Promise<Equipo[]> {
|
||||
return this.equipoService.findOnlyUsable(+id);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: number):Promise<Equipo> {
|
||||
findOne(@Param('id') id: number): Promise<Equipo> {
|
||||
return this.equipoService.findOne(+id);
|
||||
}
|
||||
}
|
||||
//IO
|
||||
//IO
|
||||
|
||||
@@ -2,22 +2,49 @@ import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Equipo } from './entities/equipo.entity';
|
||||
import { AlumnoInscritoService } from 'src/alumno_inscrito/alumno_inscrito.service';
|
||||
|
||||
@Injectable()
|
||||
export class EquipoService {
|
||||
constructor(@InjectRepository(Equipo)
|
||||
private readonly equipoRepository: Repository<Equipo>){}
|
||||
constructor(
|
||||
@InjectRepository(Equipo)
|
||||
private readonly equipoRepository: Repository<Equipo>,
|
||||
// private readonly alumnoInscritoService: AlumnoInscritoService,
|
||||
) {}
|
||||
|
||||
findAll() {
|
||||
return this.equipoRepository.find({relations:['areaUbicacion','plataforma']});
|
||||
return this.equipoRepository.find({
|
||||
relations: ['areaUbicacion', 'plataforma'],
|
||||
});
|
||||
}
|
||||
|
||||
async findOne(id_equipo: number):Promise<Equipo> {
|
||||
const equipo = await this.equipoRepository.findOne({where:{id_equipo}})
|
||||
if(!equipo){
|
||||
throw new NotFoundException("not found");
|
||||
async findOne(id_equipo: number): Promise<Equipo> {
|
||||
const equipo = await this.equipoRepository.findOne({
|
||||
where: { id_equipo },
|
||||
});
|
||||
if (!equipo) {
|
||||
throw new NotFoundException('not found');
|
||||
}
|
||||
return equipo;
|
||||
}
|
||||
|
||||
async findOnlyUsable(id_cuenta: number): Promise<Equipo[]> {
|
||||
const equipos = await this.equipoRepository
|
||||
.createQueryBuilder('equipo')
|
||||
.innerJoinAndSelect('equipo.plataforma', 'plataforma')
|
||||
.innerJoin('plataforma.alumnos_inscritos', 'ai')
|
||||
.innerJoin('ai.alumno', 'alumno')
|
||||
.innerJoin('ai.periodo', 'periodo')
|
||||
.where('alumno.id_cuenta = :id_cuenta', { id_cuenta })
|
||||
.andWhere("periodo.activo = b'1'")
|
||||
.andWhere("equipo.activo = b'1'")
|
||||
.getMany();
|
||||
|
||||
if (equipos.length === 0) {
|
||||
throw new NotFoundException('No usable equipment found');
|
||||
}
|
||||
|
||||
return equipos;
|
||||
}
|
||||
}
|
||||
//IO
|
||||
//IO
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Entity, PrimaryColumn, Column } from 'typeorm';
|
||||
import { BitacoraMesa } from 'src/bitacora_mesa/entities/bitacora_mesa.entity';
|
||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'mesa' })
|
||||
export class Mesa {
|
||||
@@ -7,4 +8,7 @@ export class Mesa {
|
||||
|
||||
@Column({ name: 'activo', type: 'tinyint', default: 1 })
|
||||
activo: boolean;
|
||||
|
||||
@OneToMany(() => BitacoraMesa, (bitacoraMesa) => bitacoraMesa.mesa)
|
||||
bitacoras_mesa: BitacoraMesa[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user