new ep api to assign and cancel table
This commit is contained in:
@@ -11,7 +11,7 @@ export class AreaUbicacionService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.areaUbicacionRepository.find();
|
return this.areaUbicacionRepository.find({where:{extra:'0'}});
|
||||||
}
|
}
|
||||||
|
|
||||||
findOne(id_area_ubicacion: number) {
|
findOne(id_area_ubicacion: number) {
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ export class BitacoraMesaController {
|
|||||||
constructor(private readonly bitacoraMesaService: BitacoraMesaService) {}
|
constructor(private readonly bitacoraMesaService: BitacoraMesaService) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
create(@Body() createBitacoraMesaDto: CreateBitacoraMesaDto) {
|
assignment(@Body() createBitacoraMesaDto: CreateBitacoraMesaDto) {
|
||||||
return this.bitacoraMesaService.create(createBitacoraMesaDto);
|
return this.bitacoraMesaService.assignment(createBitacoraMesaDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@@ -33,4 +33,12 @@ export class BitacoraMesaController {
|
|||||||
findByCuenta(@Param('id_cuenta') id_cuenta: string) {
|
findByCuenta(@Param('id_cuenta') id_cuenta: string) {
|
||||||
return this.bitacoraMesaService.findByCuenta(+id_cuenta);
|
return this.bitacoraMesaService.findByCuenta(+id_cuenta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Patch('cancelar/:id')
|
||||||
|
cancelationByMachine(
|
||||||
|
@Param('id') id: number,
|
||||||
|
@Body('tiempo_asignado') tiempo_asignado: number,
|
||||||
|
) {
|
||||||
|
return this.bitacoraMesaService.cancelation(id, tiempo_asignado);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,16 @@ export class BitacoraMesaService {
|
|||||||
@InjectRepository(BitacoraMesa)
|
@InjectRepository(BitacoraMesa)
|
||||||
private readonly bitacoraMesaRepository: Repository<BitacoraMesa>,
|
private readonly bitacoraMesaRepository: Repository<BitacoraMesa>,
|
||||||
) {}
|
) {}
|
||||||
create(createBitacoraMesaDto: CreateBitacoraMesaDto) {
|
|
||||||
return 'This action adds a new bitacoraMesa';
|
async assignment(dto: CreateBitacoraMesaDto) {
|
||||||
|
const bitacora = this.bitacoraMesaRepository.create({
|
||||||
|
tiempo_entrada: new Date(),
|
||||||
|
tiempo_asignado: dto.tiempo_asignado,
|
||||||
|
mesa: { id_mesa: dto.id_mesa },
|
||||||
|
alumno_inscrito: { id_alumno_inscrito: dto.id_alumno_inscrito },
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.bitacoraMesaRepository.save(bitacora);
|
||||||
}
|
}
|
||||||
|
|
||||||
findAll() {
|
findAll() {
|
||||||
@@ -33,6 +41,11 @@ export class BitacoraMesaService {
|
|||||||
.leftJoinAndSelect('alumno.carrera', 'carrera')
|
.leftJoinAndSelect('alumno.carrera', 'carrera')
|
||||||
.leftJoinAndSelect('bitacora.mesa', 'mesa')
|
.leftJoinAndSelect('bitacora.mesa', 'mesa')
|
||||||
.where('alumno.id_cuenta = :id_cuenta', { id_cuenta })
|
.where('alumno.id_cuenta = :id_cuenta', { id_cuenta })
|
||||||
|
|
||||||
|
.andWhere(
|
||||||
|
`TIMESTAMPDIFF(SECOND,NOW(),DATE_ADD(bitacora.tiempo_entrada, INTERVAL bitacora.tiempo_asignado MINUTE)) > 0`,
|
||||||
|
)
|
||||||
|
|
||||||
.orderBy('bitacora.tiempo_entrada', 'DESC')
|
.orderBy('bitacora.tiempo_entrada', 'DESC')
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
@@ -42,4 +55,20 @@ export class BitacoraMesaService {
|
|||||||
|
|
||||||
return student;
|
return student;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async cancelation(id_mesa: number, nuevoTiempo: number) {
|
||||||
|
const bitacora = await this.bitacoraMesaRepository.findOne({
|
||||||
|
where: { mesa:{id_mesa} },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!bitacora) {
|
||||||
|
throw new NotFoundException('alumno sin mesa asignada');
|
||||||
|
}
|
||||||
|
|
||||||
|
bitacora.tiempo_asignado -= nuevoTiempo;
|
||||||
|
|
||||||
|
await this.bitacoraMesaRepository.save(bitacora);
|
||||||
|
|
||||||
|
return { message: 'Tiempo cancelado' };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,18 @@
|
|||||||
export class CreateBitacoraMesaDto {}
|
import { IsInt, IsPositive, IsDateString } from 'class-validator';
|
||||||
|
|
||||||
|
export class CreateBitacoraMesaDto {
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
tiempo_asignado: number;
|
||||||
|
|
||||||
|
@IsDateString()
|
||||||
|
tiempo_entrada: string;
|
||||||
|
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
id_mesa: number;
|
||||||
|
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
id_alumno_inscrito: number;
|
||||||
|
}
|
||||||
@@ -17,9 +17,12 @@ export class EquipoService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.equipoRepository.find({
|
return this.equipoRepository
|
||||||
relations: ['areaUbicacion', 'plataforma'],
|
.createQueryBuilder('equipo')
|
||||||
});
|
.innerJoinAndSelect('equipo.areaUbicacion', 'area')
|
||||||
|
.innerJoinAndSelect('equipo.plataforma', 'plataforma')
|
||||||
|
.where('area.extra = :extra', { extra: '0' })
|
||||||
|
.getMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
findActive() {
|
findActive() {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
|||||||
@Entity({ name: 'mesa' })
|
@Entity({ name: 'mesa' })
|
||||||
export class Mesa {
|
export class Mesa {
|
||||||
@PrimaryColumn({ name: 'id_mesa', type: 'int' })
|
@PrimaryColumn({ name: 'id_mesa', type: 'int' })
|
||||||
idMesa: number;
|
id_mesa: number;
|
||||||
|
|
||||||
@Column({ name: 'activo', type: 'tinyint', default: 1 })
|
@Column({ name: 'activo', type: 'tinyint', default: 1 })
|
||||||
activo: boolean;
|
activo: boolean;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export class MesaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateActivo(id: number, updateMesaDto: UpdateMesaDto) {
|
async updateActivo(id: number, updateMesaDto: UpdateMesaDto) {
|
||||||
const mesa = await this.mesaRepository.findOne({ where: { idMesa: id } });
|
const mesa = await this.mesaRepository.findOne({ where: { id_mesa: id } });
|
||||||
if (!mesa) {
|
if (!mesa) {
|
||||||
throw new NotFoundException(`La mesa no fue encontrada`);
|
throw new NotFoundException(`La mesa no fue encontrada`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export class ProgramaService {
|
|||||||
){}
|
){}
|
||||||
|
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.programaRepository.find();
|
return this.programaRepository.find({order:{programa:'ASC'}});
|
||||||
}
|
}
|
||||||
|
|
||||||
findOne(id_programa: number) {
|
findOne(id_programa: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user