Merge branch 'Axel' of https://github.com/IO420/api-nexus into Lino
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
import { BadRequestException, Injectable } from '@nestjs/common';
|
||||||
import { StudentService } 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';
|
||||||
@@ -9,7 +9,7 @@ import { CreateDetalleServicioDto } from 'src/detalle_servicio/dto/create-detall
|
|||||||
export class OperationsService {
|
export class OperationsService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly dataSource: DataSource,
|
private readonly dataSource: DataSource,
|
||||||
private readonly studentService: StudentService,
|
private readonly alumnoService: AlumnoService,
|
||||||
private readonly detalleServicioService: DetalleServicioService,
|
private readonly detalleServicioService: DetalleServicioService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ export class OperationsService {
|
|||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const credit = await this.studentService.GetCredit(id_cuenta);
|
const credit = await this.alumnoService.GetCredit(id_cuenta);
|
||||||
|
|
||||||
if (credit < monto) {
|
if (credit < monto) {
|
||||||
throw new BadRequestException('Crédito insuficiente');
|
throw new BadRequestException('Crédito insuficiente');
|
||||||
@@ -34,9 +34,12 @@ export class OperationsService {
|
|||||||
fecha_operacion: new Date(),
|
fecha_operacion: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.detalleServicioService.Create(detalleData, queryRunner.manager);
|
await this.detalleServicioService.Create(
|
||||||
|
detalleData,
|
||||||
|
queryRunner.manager,
|
||||||
|
);
|
||||||
|
|
||||||
await this.studentService.UpdateCredit(
|
await this.alumnoService.UpdateCredit(
|
||||||
id_cuenta,
|
id_cuenta,
|
||||||
monto,
|
monto,
|
||||||
queryRunner.manager,
|
queryRunner.manager,
|
||||||
|
|||||||
@@ -21,3 +21,5 @@ export class CreateStudentDto {
|
|||||||
@IsString()
|
@IsString()
|
||||||
correo: string;
|
correo: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Hubo pedos con la base , revisar
|
||||||
|
|||||||
@@ -1,4 +1,30 @@
|
|||||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
import { AlumnoSancion } from 'src/alumno_sancion/entities/alumno_sancion.entity';
|
||||||
|
import { DetalleServicio } from 'src/detalle_servicio/entities/detalle_servicio.entity';
|
||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from 'typeorm';
|
||||||
|
|
||||||
|
@Entity({ name: 'carrea' })
|
||||||
|
export class Carrera {
|
||||||
|
@PrimaryGeneratedColumn({ name: 'id_carrera', type: 'int', unsigned: true })
|
||||||
|
id_carrera: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
name: 'nombre_carrea',
|
||||||
|
type: 'varchar',
|
||||||
|
length: 100,
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
nombre_carrea: string;
|
||||||
|
|
||||||
|
@OneToMany(() => Student, (id_carrera) => id_carrera.id_cuenta)
|
||||||
|
id_carreras: Student[];
|
||||||
|
}
|
||||||
|
|
||||||
@Entity({ name: 'alumno' })
|
@Entity({ name: 'alumno' })
|
||||||
export class Student {
|
export class Student {
|
||||||
@@ -54,9 +80,22 @@ export class Student {
|
|||||||
})
|
})
|
||||||
fecha_registro: Date;
|
fecha_registro: Date;
|
||||||
|
|
||||||
@Column({ name: 'id_carrera', type: 'int', nullable: false })
|
|
||||||
id_carrera: number;
|
|
||||||
|
|
||||||
@Column({ name: 'generacion', type: 'int', width: 4, nullable: true })
|
@Column({ name: 'generacion', type: 'int', width: 4, nullable: true })
|
||||||
generacion: number | null;
|
generacion: number | null;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => DetalleServicio,
|
||||||
|
(id_detalle_servicio) => id_detalle_servicio.id_cuenta,
|
||||||
|
)
|
||||||
|
detalles_servicio: DetalleServicio[];
|
||||||
|
|
||||||
|
@ManyToOne(() => Carrera, (id_cuenta) => id_cuenta.id_carreras, {
|
||||||
|
eager: true,
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
@JoinColumn({ name: 'id_carrera' })
|
||||||
|
id_periodos: Carrera;
|
||||||
|
|
||||||
|
@OneToMany(() => AlumnoSancion, (id_cuenta) => id_cuenta.id_alumno_sancion)
|
||||||
|
id_cuentas: AlumnoSancion[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,24 @@
|
|||||||
import {
|
import { Controller, Get, Post, Body, Param } from '@nestjs/common';
|
||||||
Controller,
|
import { AlumnoService } from './student.service';
|
||||||
Get,
|
|
||||||
Post,
|
|
||||||
Body,
|
|
||||||
Param,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { StudentService } from './student.service';
|
|
||||||
import { CreateStudentDto } from './dto/create-student.dto';
|
import { CreateStudentDto } from './dto/create-student.dto';
|
||||||
import { Student } from './entities/student.entity';
|
import { Student } from './entities/student.entity';
|
||||||
|
|
||||||
@Controller('student')
|
@Controller('student')
|
||||||
export class StudentController {
|
export class StudentController {
|
||||||
constructor(private readonly studentService: StudentService) {}
|
constructor(private readonly alumnoService: AlumnoService) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
async create(@Body() createStudentDto: CreateStudentDto): Promise<Student> {
|
async create(@Body() createStudentDto: CreateStudentDto): Promise<Student> {
|
||||||
return this.studentService.create(createStudentDto);
|
return this.alumnoService.create(createStudentDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
async findAll(): Promise<Student[]> {
|
async findAll(): Promise<Student[]> {
|
||||||
return this.studentService.findAll();
|
return this.alumnoService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: number) {
|
findOne(@Param('id') id: number) {
|
||||||
return this.studentService.findOne(+id);
|
return this.alumnoService.findOne(+id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { StudentService } from './student.service';
|
import { AlumnoService } from './student.service';
|
||||||
import { StudentController } from './student.controller';
|
import { StudentController } from './student.controller';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { Student } from './entities/student.entity';
|
import { Student } from './entities/student.entity';
|
||||||
@@ -7,6 +7,6 @@ import { Student } from './entities/student.entity';
|
|||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Student])],
|
imports: [TypeOrmModule.forFeature([Student])],
|
||||||
controllers: [StudentController],
|
controllers: [StudentController],
|
||||||
providers: [StudentService],
|
providers: [AlumnoService],
|
||||||
})
|
})
|
||||||
export class StudentModule {}
|
export class StudentModule {}
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ import { EntityManager, Repository } from 'typeorm';
|
|||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class StudentService {
|
export class AlumnoService {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(Student)
|
@InjectRepository(Student)
|
||||||
private readonly studentRepository: Repository<Student>,
|
private readonly studentRepository: Repository<Student>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async create(createStudentDto: CreateStudentDto): Promise<Student> {
|
async create(createStudentDto: CreateStudentDto): Promise<Student> {
|
||||||
|
//Hubo pedos con la base , revisar
|
||||||
const student = this.studentRepository.create(createStudentDto);
|
const student = this.studentRepository.create(createStudentDto);
|
||||||
return await this.studentRepository.save(student);
|
return await this.studentRepository.save(student);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AlumnoSancionController } from './alumno_sancion.controller';
|
||||||
|
import { AlumnoSancionService } from './alumno_sancion.service';
|
||||||
|
|
||||||
|
describe('AlumnoSancionController', () => {
|
||||||
|
let controller: AlumnoSancionController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [AlumnoSancionController],
|
||||||
|
providers: [AlumnoSancionService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<AlumnoSancionController>(AlumnoSancionController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||||
|
import { AlumnoSancionService } from './alumno_sancion.service';
|
||||||
|
import { CreateAlumnoSancionDto } from './dto/create-alumno_sancion.dto';
|
||||||
|
import { UpdateAlumnoSancionDto } from './dto/update-alumno_sancion.dto';
|
||||||
|
|
||||||
|
@Controller('alumno-sancion')
|
||||||
|
export class AlumnoSancionController {
|
||||||
|
constructor(private readonly alumnoSancionService: AlumnoSancionService) {}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() createAlumnoSancionDto: CreateAlumnoSancionDto) {
|
||||||
|
return this.alumnoSancionService.create(createAlumnoSancionDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll() {
|
||||||
|
return this.alumnoSancionService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.alumnoSancionService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() updateAlumnoSancionDto: UpdateAlumnoSancionDto) {
|
||||||
|
return this.alumnoSancionService.update(+id, updateAlumnoSancionDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.alumnoSancionService.remove(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { AlumnoSancionService } from './alumno_sancion.service';
|
||||||
|
import { AlumnoSancionController } from './alumno_sancion.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [AlumnoSancionController],
|
||||||
|
providers: [AlumnoSancionService],
|
||||||
|
})
|
||||||
|
export class AlumnoSancionModule {}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AlumnoSancionService } from './alumno_sancion.service';
|
||||||
|
|
||||||
|
describe('AlumnoSancionService', () => {
|
||||||
|
let service: AlumnoSancionService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [AlumnoSancionService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<AlumnoSancionService>(AlumnoSancionService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||||
|
import { CreateAlumnoSancionDto } from './dto/create-alumno_sancion.dto';
|
||||||
|
import { UpdateAlumnoSancionDto } from './dto/update-alumno_sancion.dto';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { AlumnoSancion } from './entities/alumno_sancion.entity';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
import { Student } from 'src/alumno/entities/student.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AlumnoSancionService {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(AlumnoSancion)
|
||||||
|
private readonly alumnosancionRepository: Repository<AlumnoSancion>,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
create(createAlumnoSancionDto: CreateAlumnoSancionDto) {
|
||||||
|
return 'This action adds a new alumnoSancion';
|
||||||
|
}
|
||||||
|
|
||||||
|
findAll() {
|
||||||
|
return `This action returns all alumnoSancion`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id_cuenta: CreateAlumnoSancionDto): Promise<AlumnoSancion> {
|
||||||
|
const alusancion = await this.alumnosancionRepository.findOne({
|
||||||
|
where: { id_cuenta },
|
||||||
|
});
|
||||||
|
if (!alusancion) {
|
||||||
|
throw new NotFoundException(`Student with ID ${id_cuenta} not found`);
|
||||||
|
}
|
||||||
|
return alusancion;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(id: number, updateAlumnoSancionDto: UpdateAlumnoSancionDto) {
|
||||||
|
return `This action updates a #${id} alumnoSancion`;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove(id: number) {
|
||||||
|
return `This action removes a #${id} alumnoSancion`;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { IsDateString, IsInt, IsNotEmpty, IsOptional } from 'class-validator';
|
||||||
|
|
||||||
|
export class CreateAlumnoSancionDto {
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsInt()
|
||||||
|
id_sancion: number;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsInt()
|
||||||
|
id_cuenta: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsDateString()
|
||||||
|
fecha_inicio?: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateAlumnoSancionDto } from './create-alumno_sancion.dto';
|
||||||
|
|
||||||
|
export class UpdateAlumnoSancionDto extends PartialType(CreateAlumnoSancionDto) {}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { Student } from 'src/alumno/entities/student.entity';
|
||||||
|
import { Sancion } from 'src/sancion/entities/sancion.entity';
|
||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from 'typeorm';
|
||||||
|
|
||||||
|
@Entity({ name: 'alumno_sancion' })
|
||||||
|
export class AlumnoSancion {
|
||||||
|
@PrimaryGeneratedColumn({ name: 'id_alumno_sancion', type: 'int' })
|
||||||
|
id_alumno_sancion: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
name: 'fecha_inicio',
|
||||||
|
type: 'timestamp',
|
||||||
|
default: () => 'CURRENT_TIMESTAMP',
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
fecha_inicio: Date;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => Student,
|
||||||
|
(id_alumno_sancion) => id_alumno_sancion.id_cuentas,
|
||||||
|
{
|
||||||
|
eager: true,
|
||||||
|
nullable: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
@JoinColumn({ name: 'id_cuenta' })
|
||||||
|
id_cuenta: Student;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => Sancion,
|
||||||
|
(id_alumno_sancion) => id_alumno_sancion.id_sanciones,
|
||||||
|
{
|
||||||
|
eager: true,
|
||||||
|
nullable: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
@JoinColumn({ name: 'id_sancion' })
|
||||||
|
id_sancion: Sancion;
|
||||||
|
}
|
||||||
+15
-2
@@ -13,6 +13,9 @@ import { Student } from './alumno/entities/student.entity';
|
|||||||
import { DetalleServicio } from './detalle_servicio/entities/detalle_servicio.entity';
|
import { DetalleServicio } from './detalle_servicio/entities/detalle_servicio.entity';
|
||||||
import { Periodo } from './periodo/entities/periodo.entity';
|
import { Periodo } from './periodo/entities/periodo.entity';
|
||||||
import { Servicio } from './servicio/entities/servicio.entity';
|
import { Servicio } from './servicio/entities/servicio.entity';
|
||||||
|
import { SancionModule } from './sancion/sancion.module';
|
||||||
|
import { AlumnoSancionModule } from './alumno_sancion/alumno_sancion.module';
|
||||||
|
import { AlumnoSancion } from './alumno_sancion/entities/alumno_sancion.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -29,8 +32,16 @@ import { Servicio } from './servicio/entities/servicio.entity';
|
|||||||
username: configService.get<string>('DB_USER'),
|
username: configService.get<string>('DB_USER'),
|
||||||
password: configService.get<string>('DB_PASSWORD'),
|
password: configService.get<string>('DB_PASSWORD'),
|
||||||
database: configService.get<string>('DB_NAME'),
|
database: configService.get<string>('DB_NAME'),
|
||||||
entities: [User,Student,DetalleServicio,Periodo,Servicio,Perfil],
|
entities: [
|
||||||
synchronize: false,//Never change to true in production!
|
User,
|
||||||
|
Student,
|
||||||
|
DetalleServicio,
|
||||||
|
Periodo,
|
||||||
|
Servicio,
|
||||||
|
Perfil,
|
||||||
|
AlumnoSancion,
|
||||||
|
],
|
||||||
|
synchronize: false, //Never change to true in production!
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
UserModule,
|
UserModule,
|
||||||
@@ -39,6 +50,8 @@ import { Servicio } from './servicio/entities/servicio.entity';
|
|||||||
PeriodoModule,
|
PeriodoModule,
|
||||||
ServicioModule,
|
ServicioModule,
|
||||||
StudentModule,
|
StudentModule,
|
||||||
|
SancionModule,
|
||||||
|
AlumnoSancionModule,
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService],
|
providers: [AppService],
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
import { Student } from 'src/alumno/entities/student.entity';
|
||||||
|
import { Periodo } from 'src/periodo/entities/periodo.entity';
|
||||||
|
import { Servicio } from 'src/servicio/entities/servicio.entity';
|
||||||
|
import { User } from 'src/user/entities/user.entity';
|
||||||
|
import {
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from 'typeorm';
|
||||||
|
|
||||||
@Entity({ name: 'detalle_servicio' })
|
@Entity({ name: 'detalle_servicio' })
|
||||||
export class DetalleServicio {
|
export class DetalleServicio {
|
||||||
@@ -28,15 +38,28 @@ export class DetalleServicio {
|
|||||||
})
|
})
|
||||||
fecha_operacion: Date;
|
fecha_operacion: Date;
|
||||||
|
|
||||||
@Column({ name: 'id_cuenta', type: 'int', nullable: false })
|
@ManyToOne(() => Student, (id_cuenta) => id_cuenta.detalles_servicio, {
|
||||||
id_cuenta: number;
|
eager: true,
|
||||||
|
})
|
||||||
|
@JoinColumn({ name: 'id_cuenta' })
|
||||||
|
id_cuenta: Student;
|
||||||
|
|
||||||
@Column({ name: 'id_servicio', type: 'int', nullable: false })
|
@ManyToOne(() => Servicio, (id_servicio) => id_servicio.detalles_servicio, {
|
||||||
id_servicio: number;
|
eager: true,
|
||||||
|
})
|
||||||
|
@JoinColumn({ name: 'id_servicio' })
|
||||||
|
id_servicio: Servicio;
|
||||||
|
|
||||||
@Column({ name: 'id_usuario', type: 'int', nullable: false })
|
@ManyToOne(() => User, (id_perfil) => id_perfil.detalles_servicio, {
|
||||||
id_usuario: number;
|
eager: true,
|
||||||
|
})
|
||||||
|
@JoinColumn({ name: 'id_usuario' })
|
||||||
|
id_perfil: User;
|
||||||
|
|
||||||
@Column({ name: 'id_perido', type: 'int', default: null })
|
@ManyToOne(() => Periodo, (id_periodo) => id_periodo.detalles_servicio, {
|
||||||
id_periodo: number;
|
eager: true,
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
@JoinColumn({ name: 'id_periodo' })
|
||||||
|
id_periodo: Periodo;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
import { DetalleServicio } from 'src/detalle_servicio/entities/detalle_servicio.entity';
|
||||||
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
|
|
||||||
@Entity({ name: 'periodo' })
|
@Entity({ name: 'periodo' })
|
||||||
export class Periodo {
|
export class Periodo {
|
||||||
@@ -20,4 +21,10 @@ export class Periodo {
|
|||||||
default: () => "b'1'",
|
default: () => "b'1'",
|
||||||
})
|
})
|
||||||
activo: boolean;
|
activo: boolean;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => DetalleServicio,
|
||||||
|
(id_detalle_servicio) => id_detalle_servicio.id_periodo,
|
||||||
|
)
|
||||||
|
detalles_servicio: DetalleServicio[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { IsInt, IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||||
|
|
||||||
|
export class CreateSancionDto {
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsString()
|
||||||
|
@MaxLength(45)
|
||||||
|
sancion: string;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsInt()
|
||||||
|
duracion: number;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/mapped-types';
|
||||||
|
import { CreateSancionDto } from './create-sancion.dto';
|
||||||
|
|
||||||
|
export class UpdateSancionDto extends PartialType(CreateSancionDto) {}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { AlumnoSancion } from 'src/alumno_sancion/entities/alumno_sancion.entity';
|
||||||
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
|
|
||||||
|
@Entity({ name: 'sancion' })
|
||||||
|
export class Sancion {
|
||||||
|
@PrimaryGeneratedColumn({ name: 'id_sancion', type: 'int' })
|
||||||
|
id_sancion: number;
|
||||||
|
|
||||||
|
@Column({ name: 'sancion', type: 'varchar', length: 45, nullable: false })
|
||||||
|
sancion: string;
|
||||||
|
|
||||||
|
@Column({ name: 'duracion', type: 'int', nullable: false })
|
||||||
|
duracion: number;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => AlumnoSancion,
|
||||||
|
(id_sanncion) => id_sanncion.id_alumno_sancion,
|
||||||
|
)
|
||||||
|
id_sanciones: AlumnoSancion[];
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { SancionController } from './sancion.controller';
|
||||||
|
import { SancionService } from './sancion.service';
|
||||||
|
|
||||||
|
describe('SancionController', () => {
|
||||||
|
let controller: SancionController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [SancionController],
|
||||||
|
providers: [SancionService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<SancionController>(SancionController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||||
|
import { SancionService } from './sancion.service';
|
||||||
|
import { CreateSancionDto } from './dto/create-sancion.dto';
|
||||||
|
import { UpdateSancionDto } from './dto/update-sancion.dto';
|
||||||
|
|
||||||
|
@Controller('sancion')
|
||||||
|
export class SancionController {
|
||||||
|
constructor(private readonly sancionService: SancionService) {}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() createSancionDto: CreateSancionDto) {
|
||||||
|
return this.sancionService.create(createSancionDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
findAll() {
|
||||||
|
return this.sancionService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
findOne(@Param('id') id: string) {
|
||||||
|
return this.sancionService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
update(@Param('id') id: string, @Body() updateSancionDto: UpdateSancionDto) {
|
||||||
|
return this.sancionService.update(+id, updateSancionDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string) {
|
||||||
|
return this.sancionService.remove(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { SancionService } from './sancion.service';
|
||||||
|
import { SancionController } from './sancion.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [SancionController],
|
||||||
|
providers: [SancionService],
|
||||||
|
})
|
||||||
|
export class SancionModule {}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { SancionService } from './sancion.service';
|
||||||
|
|
||||||
|
describe('SancionService', () => {
|
||||||
|
let service: SancionService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [SancionService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<SancionService>(SancionService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { CreateSancionDto } from './dto/create-sancion.dto';
|
||||||
|
import { UpdateSancionDto } from './dto/update-sancion.dto';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SancionService {
|
||||||
|
create(createSancionDto: CreateSancionDto) {
|
||||||
|
return 'This action adds a new sancion';
|
||||||
|
}
|
||||||
|
|
||||||
|
findAll() {
|
||||||
|
return `This action returns all sancion`;
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(id: number) {
|
||||||
|
return `This action returns a #${id} sancion`;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(id: number, updateSancionDto: UpdateSancionDto) {
|
||||||
|
return `This action updates a #${id} sancion`;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove(id: number) {
|
||||||
|
return `This action removes a #${id} sancion`;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
|
import { DetalleServicio } from 'src/detalle_servicio/entities/detalle_servicio.entity';
|
||||||
|
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
|
||||||
|
|
||||||
@Entity({ name: 'servicio' })
|
@Entity({ name: 'servicio' })
|
||||||
export class Servicio {
|
export class Servicio {
|
||||||
@@ -7,4 +8,9 @@ export class Servicio {
|
|||||||
|
|
||||||
@Column({ type: 'varchar', length: 45, nullable: false })
|
@Column({ type: 'varchar', length: 45, nullable: false })
|
||||||
servicio: string;
|
servicio: string;
|
||||||
|
@OneToMany(
|
||||||
|
() => DetalleServicio,
|
||||||
|
(id_detalle_servicio) => id_detalle_servicio.id_servicio,
|
||||||
|
)
|
||||||
|
detalles_servicio: DetalleServicio[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { DetalleServicio } from 'src/detalle_servicio/entities/detalle_servicio.entity';
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
@@ -51,4 +52,10 @@ export class User {
|
|||||||
@ManyToOne(() => Perfil, (perfil) => perfil.usuarios, { eager: true })
|
@ManyToOne(() => Perfil, (perfil) => perfil.usuarios, { eager: true })
|
||||||
@JoinColumn({ name: 'id_perfil' })
|
@JoinColumn({ name: 'id_perfil' })
|
||||||
perfil: Perfil;
|
perfil: Perfil;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => DetalleServicio,
|
||||||
|
(id_detalle_servicio) => id_detalle_servicio.id_perfil,
|
||||||
|
)
|
||||||
|
detalles_servicio: DetalleServicio[];
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user