added new Ep
This commit is contained in:
@@ -2,17 +2,13 @@ import {
|
|||||||
BadRequestException,
|
BadRequestException,
|
||||||
Injectable,
|
Injectable,
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
Req,
|
|
||||||
UseGuards,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { AlumnoService } from 'src/alumno/student.service';
|
import { AlumnoService } from 'src/alumno/student.service';
|
||||||
import { DetalleServicioService } from 'src/detalle_servicio/detalle_servicio.service';
|
import { DetalleServicioService } from 'src/detalle_servicio/detalle_servicio.service';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import { chargePrintDto } from './dto/operations.dto';
|
import { chargePrintDto } from './dto/operations.dto';
|
||||||
import { CreateDetalleServicioDto } from 'src/detalle_servicio/dto/create-detalle_servicio.dto';
|
|
||||||
import { UserService } from 'src/user/user.service';
|
import { UserService } from 'src/user/user.service';
|
||||||
import { ReciboService } from 'src/recibo/recibo.service';
|
import { ReciboService } from 'src/recibo/recibo.service';
|
||||||
import { CreateReciboDto } from 'src/recibo/dto/create-recibo.dto';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class OperationsService {
|
export class OperationsService {
|
||||||
|
|||||||
@@ -41,6 +41,18 @@ export class AlumnoService {
|
|||||||
return student;
|
return student;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findOneByName(nombre: string): Promise<Alumno> {
|
||||||
|
const student = await this.studentRepository.findOne({
|
||||||
|
where: { nombre },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!student) {
|
||||||
|
throw new NotFoundException(`Student not found`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return student;
|
||||||
|
}
|
||||||
|
|
||||||
async GetCredit(id_cuenta: number): Promise<Alumno['credito']> {
|
async GetCredit(id_cuenta: number): Promise<Alumno['credito']> {
|
||||||
const student = await this.findOne(id_cuenta);
|
const student = await this.findOne(id_cuenta);
|
||||||
return student.credito;
|
return student.credito;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export class AlumnoInscritoService {
|
|||||||
|
|
||||||
async findByAlumno(id_cuenta: number): Promise<AlumnoInscrito[]> {
|
async findByAlumno(id_cuenta: number): Promise<AlumnoInscrito[]> {
|
||||||
return this.alumnoInscritoRepo.find({
|
return this.alumnoInscritoRepo.find({
|
||||||
where: { alumno: { id_cuenta }, periodo:{id_periodo:24}},
|
where: { alumno: { id_cuenta }, periodo: { id_periodo: 27 } },
|
||||||
relations: ['alumno', 'periodo', 'plataforma'],
|
relations: ['alumno', 'periodo', 'plataforma'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ export class AlumnoSancionController {
|
|||||||
return this.alumnoSancionService.findbyStudent(+id);
|
return this.alumnoSancionService.findbyStudent(+id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete()
|
@Delete(':id_cuenta')
|
||||||
deleteSancion(){
|
async deleteSancionesAlumno(@Param('id_cuenta') id_cuenta: number) {
|
||||||
|
return this.alumnoSancionService.removeByStudent(+id_cuenta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//IO
|
//IO
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ export class AlumnoSancionService {
|
|||||||
private readonly sancionService: SancionService,
|
private readonly sancionService: SancionService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async create(
|
async create(createAlumnoSancionDto: CreateAlumnoSancionDto) {
|
||||||
createAlumnoSancionDto: CreateAlumnoSancionDto,
|
|
||||||
) {
|
|
||||||
const { id_sancion, id_cuenta } = createAlumnoSancionDto;
|
const { id_sancion, id_cuenta } = createAlumnoSancionDto;
|
||||||
|
|
||||||
const alumno = await this.alumnoService.findOne(id_cuenta);
|
const alumno = await this.alumnoService.findOne(id_cuenta);
|
||||||
@@ -39,24 +37,30 @@ export class AlumnoSancionService {
|
|||||||
async findbyStudent(id_cuenta: number): Promise<AlumnoSancion[]> {
|
async findbyStudent(id_cuenta: number): Promise<AlumnoSancion[]> {
|
||||||
const alusancion = await this.alumnosancionRepository.find({
|
const alusancion = await this.alumnosancionRepository.find({
|
||||||
where: { alumno: { id_cuenta } },
|
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) {
|
|
||||||
|
if (alusancion.length === 0) {
|
||||||
throw new NotFoundException(`student without sancion`);
|
throw new NotFoundException(`student without sancion`);
|
||||||
}
|
}
|
||||||
return alusancion;
|
return alusancion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removeByStudent(id_cuenta: number): Promise<{ message: string }> {
|
||||||
|
const sanciones = await this.alumnosancionRepository.find({
|
||||||
|
where: { alumno: { id_cuenta } },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!sanciones || sanciones.length === 0) {
|
||||||
|
throw new NotFoundException(
|
||||||
|
`El alumno con id ${id_cuenta} no tiene sanciones`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.alumnosancionRepository.delete({ alumno: { id_cuenta } });
|
||||||
|
|
||||||
|
return {
|
||||||
|
message: `Todas las sanciones del alumno ${id_cuenta} han sido eliminadas`,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//IO
|
//IO
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export class AlumnoSancion {
|
|||||||
fecha_inicio: Date;
|
fecha_inicio: Date;
|
||||||
|
|
||||||
@ManyToOne(() => Alumno, (student) => student.sanciones, {
|
@ManyToOne(() => Alumno, (student) => student.sanciones, {
|
||||||
eager: true,
|
|
||||||
nullable: false,
|
nullable: false,
|
||||||
})
|
})
|
||||||
@JoinColumn({ name: 'id_cuenta' })
|
@JoinColumn({ name: 'id_cuenta' })
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export class AreaUbicacionService {
|
|||||||
@InjectRepository(AreaUbicacion)
|
@InjectRepository(AreaUbicacion)
|
||||||
private readonly areaUbicacionRepository: Repository<AreaUbicacion>,
|
private readonly areaUbicacionRepository: Repository<AreaUbicacion>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.areaUbicacionRepository.find();
|
return this.areaUbicacionRepository.find();
|
||||||
}
|
}
|
||||||
@@ -18,11 +19,11 @@ export class AreaUbicacionService {
|
|||||||
where: { id_area_ubicacion },
|
where: { id_area_ubicacion },
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!area){
|
if (!area) {
|
||||||
return "this area dosnt exist"
|
return 'this area dosnt exist';
|
||||||
}
|
}
|
||||||
|
|
||||||
return area
|
return area;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//IO
|
//IO
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get } from '@nestjs/common';
|
||||||
import { CarreraService } from './carrera.service';
|
import { CarreraService } from './carrera.service';
|
||||||
|
import { Carrera } from './entities/carrera.entity';
|
||||||
|
|
||||||
@Controller('carrera')
|
@Controller('carrera')
|
||||||
export class CarreraController {
|
export class CarreraController {
|
||||||
constructor(private readonly carreraService: CarreraService) {}
|
constructor(private readonly carreraService: CarreraService) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
findAll(): Promise<Carrera[]> {
|
||||||
return this.carreraService.findAll();
|
return this.carreraService.findAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,25 @@
|
|||||||
import { Equipo } from "src/equipo/entities/equipo.entity";
|
import { Equipo } from 'src/equipo/entities/equipo.entity';
|
||||||
import { Programa } from "src/programa/entities/programa.entity";
|
import { Programa } from 'src/programa/entities/programa.entity';
|
||||||
import { Entity, PrimaryColumn, ManyToOne, JoinColumn } from "typeorm";
|
import { Entity, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm';
|
||||||
|
|
||||||
@Entity("programa_equipo")
|
@Entity('programa_equipo')
|
||||||
export class ProgramaEquipo {
|
export class ProgramaEquipo {
|
||||||
@PrimaryColumn({ name: "id_programa", type: "int" })
|
@PrimaryColumn({ name: 'id_programa', type: 'int' })
|
||||||
id_programa: number;
|
id_programa: number;
|
||||||
|
|
||||||
@PrimaryColumn({ name: "id_equipo", type: "int" })
|
@PrimaryColumn({ name: 'id_equipo', type: 'int' })
|
||||||
id_equipo: number;
|
id_equipo: number;
|
||||||
|
|
||||||
@ManyToOne(() => Programa, (programa) => programa.programaEquipos, {
|
@ManyToOne(() => Programa, (programa) => programa.programaEquipos, {
|
||||||
onUpdate: "CASCADE",
|
eager: true,
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
})
|
})
|
||||||
@JoinColumn({ name: "id_programa" })
|
@JoinColumn({ name: 'id_programa' })
|
||||||
programa: Programa;
|
programa: Programa;
|
||||||
|
|
||||||
@ManyToOne(() => Equipo, (equipo) => equipo.programaEquipos, {
|
@ManyToOne(() => Equipo, (equipo) => equipo.programaEquipos, {
|
||||||
onUpdate: "CASCADE",
|
onUpdate: 'CASCADE',
|
||||||
})
|
})
|
||||||
@JoinColumn({ name: "id_equipo" })
|
@JoinColumn({ name: 'id_equipo' })
|
||||||
equipo: Equipo;
|
equipo: Equipo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
import { Controller, Get, Body, Patch, Param } from '@nestjs/common';
|
||||||
import { ProgramaEquipoService } from './programa_equipo.service';
|
import { ProgramaEquipoService } from './programa_equipo.service';
|
||||||
import { CreateProgramaEquipoDto } from './dto/create-programa_equipo.dto';
|
|
||||||
import { UpdateProgramaEquipoDto } from './dto/update-programa_equipo.dto';
|
import { UpdateProgramaEquipoDto } from './dto/update-programa_equipo.dto';
|
||||||
|
|
||||||
@Controller('programa-equipo')
|
@Controller('programa-equipo')
|
||||||
export class ProgramaEquipoController {
|
export class ProgramaEquipoController {
|
||||||
constructor(private readonly programaEquipoService: ProgramaEquipoService) {}
|
constructor(private readonly programaEquipoService: ProgramaEquipoService) {}
|
||||||
|
|
||||||
@Get()
|
@Get('programas/:id')
|
||||||
findAll() {
|
findAllProgramByNumber(@Param('id') id: number) {
|
||||||
return this.programaEquipoService.findAll();
|
return this.programaEquipoService.findAllProgramByNumber(+id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@@ -18,7 +17,10 @@ export class ProgramaEquipoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(@Param('id') id: string, @Body() updateProgramaEquipoDto: UpdateProgramaEquipoDto) {
|
update(
|
||||||
|
@Param('id') id: string,
|
||||||
|
@Body() updateProgramaEquipoDto: UpdateProgramaEquipoDto,
|
||||||
|
) {
|
||||||
return this.programaEquipoService.update(+id, updateProgramaEquipoDto);
|
return this.programaEquipoService.update(+id, updateProgramaEquipoDto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ export class ProgramaEquipoService {
|
|||||||
private readonly ProgramaEquipoRepository: Repository<ProgramaEquipo>,
|
private readonly ProgramaEquipoRepository: Repository<ProgramaEquipo>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
findAll() {
|
findAllProgramByNumber(id_equipo: number) {
|
||||||
return `This action returns all programaEquipo`;
|
return this.ProgramaEquipoRepository.find({ where: { id_equipo } });
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOne(id_equipo: number) {
|
async findOne(id_equipo: number) {
|
||||||
@@ -24,7 +24,7 @@ export class ProgramaEquipoService {
|
|||||||
if (equipo.length === 0) {
|
if (equipo.length === 0) {
|
||||||
throw new NotFoundException(`machine without programs`);
|
throw new NotFoundException(`machine without programs`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return equipo;
|
return equipo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
import {
|
||||||
|
BadRequestException,
|
||||||
|
Injectable,
|
||||||
|
NotFoundException,
|
||||||
|
} from '@nestjs/common';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
import { changePasswordDto, CreateUserDto, Login } from './dto/create-user.dto';
|
import { changePasswordDto, CreateUserDto, Login } from './dto/create-user.dto';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
@@ -51,18 +55,31 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findOne(id_usuario: number): Promise<User> {
|
async findOne(id_usuario: number): Promise<User> {
|
||||||
const student = await this.userRepository.findOne({
|
const user = await this.userRepository.findOne({
|
||||||
where: { id_usuario },
|
where: { id_usuario },
|
||||||
});
|
});
|
||||||
if (!student) {
|
if (!user) {
|
||||||
throw new NotFoundException(`Student not found`);
|
throw new NotFoundException(`Student not found`);
|
||||||
}
|
}
|
||||||
return student;
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
async findbyUser(usuario: string) {
|
||||||
|
const user = await this.userRepository.findOne({
|
||||||
|
where: { usuario },
|
||||||
|
});
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(data: CreateUserDto) {
|
async create(data: CreateUserDto) {
|
||||||
const { id_perfil, ...rest } = data;
|
const { id_perfil, ...rest } = data;
|
||||||
|
|
||||||
|
const user = await this.findbyUser(data.usuario);
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
throw new BadRequestException('User found, change the user ');
|
||||||
|
}
|
||||||
|
|
||||||
const perfil = await this.perfilRepository.findOne({
|
const perfil = await this.perfilRepository.findOne({
|
||||||
where: { id_perfil },
|
where: { id_perfil },
|
||||||
});
|
});
|
||||||
@@ -73,8 +90,8 @@ export class UserService {
|
|||||||
|
|
||||||
const datauser = { ...rest, perfil };
|
const datauser = { ...rest, perfil };
|
||||||
|
|
||||||
const user = this.userRepository.create(datauser);
|
const usercreate = this.userRepository.create(datauser);
|
||||||
return this.userRepository.save(user);
|
return this.userRepository.save(usercreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
async changePassword(data: changePasswordDto, id_usuario: number) {
|
async changePassword(data: changePasswordDto, id_usuario: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user