FRED2
This commit is contained in:
@@ -2,10 +2,6 @@ import { IsBoolean, IsInt, IsNotEmpty, IsNumber, IsString, IsOptional, Length} f
|
||||
|
||||
export class profesorDto{
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_profesor: number;
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_usuario: number;
|
||||
@@ -78,10 +74,10 @@ export class profesorDto{
|
||||
fotografia: string;
|
||||
|
||||
@IsBoolean()
|
||||
@IsNotEmpty()
|
||||
activo: boolean = false;
|
||||
@IsOptional()
|
||||
activo: boolean;
|
||||
|
||||
@IsBoolean()
|
||||
@IsNotEmpty()
|
||||
mostrar: boolean = true;
|
||||
@IsOptional()
|
||||
mostrar: boolean;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { IsOptional, IsString, IsInt, IsBoolean } from 'class-validator';
|
||||
|
||||
export class ProfesorFilterDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
nombre?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id_categoria?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id_carrera?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
extension?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id_adscripcion?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id_edificio?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
activo?: boolean;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
@@ -16,7 +16,7 @@ import { User } from 'src/users/entities/user.entity';
|
||||
|
||||
@Entity()
|
||||
export class Profesor {
|
||||
@PrimaryColumn({ type: 'int', nullable: false })
|
||||
@PrimaryGeneratedColumn()
|
||||
id_profesor: number;
|
||||
|
||||
@Column({ type: 'int',nullable: false })
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put } from '@nestjs/common';
|
||||
import { ProfesorService } from './profesor.service';
|
||||
import { profesorDto } from './dto/profesorDto.dto';
|
||||
import { ProfesorFilterDto } from './dto/profesorFilterDto.dto';
|
||||
|
||||
@Controller('profesor')
|
||||
export class ProfesorController {
|
||||
@@ -33,7 +32,7 @@ export class ProfesorController {
|
||||
}
|
||||
|
||||
@Post('filter')
|
||||
async filter(@Body() data: ProfesorFilterDto) {
|
||||
async filter(@Body() data: profesorDto) {
|
||||
return this.profesorService.filter(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Profesor } from './entities/profesor.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { profesorDto } from './dto/profesorDto.dto';
|
||||
import { ProfesorFilterDto } from './dto/profesorFilterDto.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ProfesorService {
|
||||
@@ -67,7 +66,7 @@ export class ProfesorService {
|
||||
}
|
||||
|
||||
//brings teachers by filter
|
||||
async filter(filterDto: ProfesorFilterDto): Promise<Profesor[]> {
|
||||
async filter(filterDto: profesorDto): Promise<Profesor[]> {
|
||||
const query = this.profesorRepository.createQueryBuilder('profesor');
|
||||
|
||||
if (filterDto.nombre) {
|
||||
@@ -78,11 +77,6 @@ export class ProfesorService {
|
||||
query.andWhere('profesor.id_categoria = :id_categoria', { id_categoria: filterDto.id_categoria });
|
||||
}
|
||||
|
||||
if (filterDto.id_carrera !== undefined) {
|
||||
query.innerJoin('profesor.asignaturaCarreraProfesores', 'acp')
|
||||
.andWhere('acp.id_carrera = :id_carrera', { id_carrera: filterDto.id_carrera });
|
||||
}
|
||||
|
||||
if (filterDto.extension) {
|
||||
query.andWhere('profesor.extension like :extension', { extension: `%${filterDto.extension}%` });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user