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