is not empty
This commit is contained in:
@@ -65,7 +65,7 @@ export class AuthController {
|
||||
})
|
||||
@ApiBody({
|
||||
description: 'Todas las variables son obligatorias.',
|
||||
examples: { ejemplo: { value: { usuario: '', password: '' } } },
|
||||
examples: { ejemplo: { value: { password: '', usuario: '' } } },
|
||||
})
|
||||
loginUsuario(@Body() body: LoginUsuarioDto) {
|
||||
return this.authService.loginUsuario(body.usuario, body.password);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { PassportModule } from '@nestjs/passport';
|
||||
import { AuthController } from './auth.controller';
|
||||
@@ -15,12 +15,10 @@ import { UsuarioModule } from '../usuario/usuario.module';
|
||||
BcryptModule,
|
||||
JwtModule.registerAsync({
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => {
|
||||
return {
|
||||
secret: configService.get<string>('AUTH_SECRETKEY'),
|
||||
signOptions: { expiresIn: '2h' },
|
||||
};
|
||||
},
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
secret: configService.get<string>('AUTH_SECRETKEY'),
|
||||
signOptions: { expiresIn: '2h' },
|
||||
}),
|
||||
}),
|
||||
ModuloModule,
|
||||
OperadorModule,
|
||||
|
||||
@@ -44,6 +44,13 @@ export class AuthService {
|
||||
.findByOperador(modulo.institucion, operador, false)
|
||||
.then((operador) => {
|
||||
this.validarLogin(operador, password);
|
||||
if (
|
||||
operador.institucion.id_institucion !==
|
||||
modulo.institucion.id_institucion
|
||||
)
|
||||
throw new ConflictException(
|
||||
'Este módulo no pertenece a tu institución, selecciona uno válido.',
|
||||
);
|
||||
|
||||
const payload: JwtPayload = {
|
||||
id_modulo: modulo.id_modulo,
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class LoginAdminDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(40)
|
||||
operador: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
password: string;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { IsInt, IsString } from 'class-validator';
|
||||
import { IsInt, IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class LoginOperadorDto {
|
||||
@IsInt()
|
||||
id_modulo: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(40)
|
||||
operador: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
password: string;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class LoginUsuarioDto {
|
||||
@IsString()
|
||||
password: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(10)
|
||||
usuario: string;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export class JwtPayload {
|
||||
id_tipo_usuario: number;
|
||||
|
||||
id_modulo?: number;
|
||||
|
||||
id_operador?: number;
|
||||
|
||||
id_tipo_usuario: number;
|
||||
|
||||
id_usuario?: number;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Expose, Type } from 'class-transformer';
|
||||
import { OperadorOutputDto } from '../../../operador/dto/output/operador.dto';
|
||||
|
||||
export class AuthOperadorOutputDto {
|
||||
@Expose()
|
||||
token;
|
||||
|
||||
@Expose()
|
||||
@Type(() => OperadorOutputDto)
|
||||
operador;
|
||||
|
||||
@Expose()
|
||||
token;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,10 @@ export class BcryptService {
|
||||
const length = 8;
|
||||
const charset =
|
||||
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
const n = charset.length;
|
||||
let password = '';
|
||||
|
||||
for (let i = 0; i < length; i++)
|
||||
password += charset.charAt(Math.floor(Math.random() * n));
|
||||
password += charset.charAt(Math.floor(Math.random() * charset.length));
|
||||
return password;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export class CarreraProgramaService {
|
||||
.then((existeCarretaPrograma) => {
|
||||
if (existeCarretaPrograma)
|
||||
throw new ConflictException(
|
||||
'Los alumnos de esta carrera ya tienen acceso a este programa.',
|
||||
'Ya se asignó este programa a esta carrera.',
|
||||
);
|
||||
return this.repository.save(
|
||||
this.repository.create({
|
||||
@@ -81,8 +81,7 @@ export class CarreraProgramaService {
|
||||
return this.findById(id_carrera_programa)
|
||||
.then((carreraPrograma) => this.repository.delete(carreraPrograma))
|
||||
.then((_) => ({
|
||||
message:
|
||||
'Se eliminó correctamente la asignación del programa de la carrera.',
|
||||
message: 'Se eliminó correctamente la asignación del programa.',
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,18 @@ export class CarritoController {
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
// @ApiQuery({
|
||||
// description: 'Id de la marca.',
|
||||
// name: 'id_marca',
|
||||
// type: 'string',
|
||||
// required: false,
|
||||
// })
|
||||
// @ApiQuery({
|
||||
// description: 'Id del modelo.',
|
||||
// name: 'id_modelo',
|
||||
// type: 'string',
|
||||
// required: false,
|
||||
// })
|
||||
@ApiQuery({
|
||||
description: 'Id del módulo.',
|
||||
name: 'id_modulo',
|
||||
@@ -130,8 +142,8 @@ export class CarritoController {
|
||||
id_carrito: 1,
|
||||
_activo: true,
|
||||
_carrito: '',
|
||||
_id_modulo: 1,
|
||||
_id_tipo_carrito: 1,
|
||||
// _id_marca: '',
|
||||
// _id_modelo: '',
|
||||
_marca: '',
|
||||
_modelo: '',
|
||||
},
|
||||
@@ -141,12 +153,8 @@ export class CarritoController {
|
||||
update(@Body() body: UpdateCarritoDto) {
|
||||
const data = { ...body };
|
||||
|
||||
delete data.id_modulo;
|
||||
delete data.id_tipo_carrito;
|
||||
return this.carritoService.update(
|
||||
data,
|
||||
body.id_modulo,
|
||||
body.id_tipo_carrito,
|
||||
);
|
||||
// delete data.id_marca;
|
||||
// delete data.id_modelo;
|
||||
return this.carritoService.update(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { CarritoService } from './carrito.service';
|
||||
import { Carrito } from './entity/carrito.entity';
|
||||
import { InstitucionModule } from '../institucion/institucion.module';
|
||||
import { InstitucionTipoCarritoModule } from '../institucion-tipo-carrito/institucion-tipo-carrito.module';
|
||||
import { MarcaModule } from '../marca/marca.module';
|
||||
import { ModeloModule } from '../modelo/modelo.module';
|
||||
import { ModuloModule } from '../modulo/modulo.module';
|
||||
|
||||
@@ -13,6 +14,7 @@ import { ModuloModule } from '../modulo/modulo.module';
|
||||
imports: [
|
||||
InstitucionModule,
|
||||
InstitucionTipoCarritoModule,
|
||||
MarcaModule,
|
||||
ModeloModule,
|
||||
ModuloModule,
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
|
||||
@@ -10,6 +10,8 @@ import { Modulo } from '../modulo/entity/modulo.entity';
|
||||
import { TipoCarrito } from '../institucion-tipo-carrito/entity/tipo-carrito.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
import { InstitucionTipoCarritoService } from '../institucion-tipo-carrito/institucion-tipo-carrito.service';
|
||||
import { MarcaService } from '../marca/marca.service';
|
||||
import { ModeloService } from '../modelo/modelo.service';
|
||||
import { ModuloService } from '../modulo/modulo.service';
|
||||
|
||||
@Injectable()
|
||||
@@ -18,6 +20,8 @@ export class CarritoService {
|
||||
@InjectRepository(Carrito) private repository: Repository<Carrito>,
|
||||
private institucionService: InstitucionService,
|
||||
private institucionTipoCarritoService: InstitucionTipoCarritoService,
|
||||
private marcaService: MarcaService,
|
||||
private modeloService: ModeloService,
|
||||
private moduloService: ModuloService,
|
||||
) {}
|
||||
|
||||
@@ -26,24 +30,23 @@ export class CarritoService {
|
||||
id_tipo_carrito: number,
|
||||
marca: string,
|
||||
modelo: string,
|
||||
// id_marca: number,
|
||||
// id_modelo: number,
|
||||
) {
|
||||
// const marca = await this.marcaService.findById(id_marca);
|
||||
// const modelo = await this.modeloService.findById(id_modelo);
|
||||
const modulo = await this.moduloService.findById(id_modulo);
|
||||
const tipoCarrito =
|
||||
await this.institucionTipoCarritoService.findTipoCarritoById(
|
||||
id_tipo_carrito,
|
||||
);
|
||||
let carrito = '';
|
||||
|
||||
return this.repository
|
||||
.count({ modulo, tipoCarrito })
|
||||
.then((carritos) => {
|
||||
carrito = `C${carritos >= 9 ? '' : '0'}${carritos + 1}`;
|
||||
return this.existeCarrito(modulo, tipoCarrito, carrito);
|
||||
})
|
||||
.then(() =>
|
||||
.then((carritos) =>
|
||||
this.repository.save(
|
||||
this.repository.create({
|
||||
carrito,
|
||||
carrito: `C${carritos >= 9 ? '' : '0'}${carritos + 1}`,
|
||||
marca,
|
||||
modelo,
|
||||
modulo,
|
||||
@@ -56,40 +59,33 @@ export class CarritoService {
|
||||
}));
|
||||
}
|
||||
|
||||
async existeCarrito(
|
||||
id_modulo: number | Modulo,
|
||||
id_tipo_carrito: number | TipoCarrito,
|
||||
carrito: string,
|
||||
) {
|
||||
const modulo =
|
||||
typeof id_modulo === 'number'
|
||||
? await this.moduloService.findById(id_modulo)
|
||||
: id_modulo;
|
||||
const tipoCarrito =
|
||||
typeof id_tipo_carrito === 'number'
|
||||
? await this.institucionTipoCarritoService.findTipoCarritoById(
|
||||
id_tipo_carrito,
|
||||
)
|
||||
: id_tipo_carrito;
|
||||
|
||||
return this.repository
|
||||
.findOne({ modulo, tipoCarrito, carrito })
|
||||
.then((existeCarrito) => {
|
||||
if (existeCarrito)
|
||||
throw new ConflictException(
|
||||
'Ya existe un carrito con este nombre, intenta con otro.',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async findAll(filtros: {
|
||||
pagina: string;
|
||||
activo?: string;
|
||||
carrito?: string;
|
||||
id_institucion?: string;
|
||||
id_marca?: string;
|
||||
id_modelo?: string;
|
||||
id_modulo?: string;
|
||||
id_tipo_carrito?: string;
|
||||
}) {
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
// const marca = filtros.id_marca
|
||||
// ? await this.marcaService.findById(parseInt(filtros.id_marca))
|
||||
// : null;
|
||||
// const modelo = filtros.id_modelo
|
||||
// ? await this.modeloService.findById(parseInt(filtros.id_modelo))
|
||||
// : null;
|
||||
const modulo = filtros.id_modulo
|
||||
? await this.moduloService.findById(parseInt(filtros.id_modulo))
|
||||
: null;
|
||||
const tipoCarrito = filtros.id_tipo_carrito
|
||||
? await this.institucionTipoCarritoService.findTipoCarritoById(
|
||||
parseInt(filtros.id_tipo_carrito),
|
||||
)
|
||||
: null;
|
||||
const query = this.repository
|
||||
.createQueryBuilder('c')
|
||||
.innerJoinAndSelect('c.modulo', 'm')
|
||||
@@ -101,17 +97,6 @@ export class CarritoService {
|
||||
.addOrderBy('c.carrito')
|
||||
.skip((parseInt(filtros.pagina) - 1) * 25)
|
||||
.take(25);
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const modulo = filtros.id_modulo
|
||||
? await this.moduloService.findById(parseInt(filtros.id_modulo))
|
||||
: null;
|
||||
const tipoCarrito = filtros.id_tipo_carrito
|
||||
? await this.institucionTipoCarritoService.findTipoCarritoById(
|
||||
parseInt(filtros.id_tipo_carrito),
|
||||
)
|
||||
: null;
|
||||
|
||||
if (filtros.activo === 'true') query.andWhere('c.activo = 1');
|
||||
if (filtros.activo === 'false') query.andWhere('c.activo = 0');
|
||||
@@ -169,29 +154,25 @@ export class CarritoService {
|
||||
|
||||
async update(
|
||||
attrs: Partial<Carrito>,
|
||||
id_modulo?: number,
|
||||
id_tipo_carrito?: number,
|
||||
// id_marca?: number,
|
||||
// id_modelo?: number,
|
||||
) {
|
||||
const modulo = id_modulo
|
||||
? await this.moduloService.findById(id_modulo)
|
||||
: null;
|
||||
const tipoCarrito = id_modulo
|
||||
? await this.institucionTipoCarritoService.findTipoCarritoById(
|
||||
id_tipo_carrito,
|
||||
)
|
||||
: null;
|
||||
// const marca = id_marca
|
||||
// ? typeof id_marca === 'number'
|
||||
// ? await this.marcaService.findById(id_marca)
|
||||
// : id_marca
|
||||
// : null;
|
||||
// const operador = id_operador
|
||||
// ? typeof id_operador === 'number'
|
||||
// ? await this.operadorService.findById(id_operador)
|
||||
// : id_operador
|
||||
// : null;
|
||||
|
||||
return this.findById(attrs.id_carrito)
|
||||
.then(async (carrito) => {
|
||||
if (attrs.carrito || modulo || tipoCarrito)
|
||||
await this.existeCarrito(
|
||||
modulo ? modulo : carrito.modulo,
|
||||
tipoCarrito ? tipoCarrito : carrito.tipoCarrito,
|
||||
attrs.carrito ? attrs.carrito : carrito.carrito,
|
||||
);
|
||||
Object.assign(carrito, attrs);
|
||||
if (modulo) carrito.modulo = modulo;
|
||||
if (tipoCarrito) carrito.tipoCarrito = tipoCarrito;
|
||||
// if (marca) carrito.marca = marca;
|
||||
// if (modelo) carrito.modelo = modelo;
|
||||
return this.repository.save(carrito);
|
||||
})
|
||||
.then((_) => ({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
IsBooleanString,
|
||||
IsNotEmpty,
|
||||
IsNumberString,
|
||||
IsOptional,
|
||||
IsString,
|
||||
@@ -14,6 +15,7 @@ export class CarritosDto {
|
||||
activo?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
carrito?: string;
|
||||
|
||||
@@ -21,6 +23,14 @@ export class CarritosDto {
|
||||
@IsOptional()
|
||||
id_institucion?: string;
|
||||
|
||||
// @IsNumberString()
|
||||
// @IsOptional()
|
||||
// id_marca?: string;
|
||||
|
||||
// @IsNumberString()
|
||||
// @IsOptional()
|
||||
// id_modelo?: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_modulo?: string;
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import { IsNumber, IsString } from 'class-validator';
|
||||
import { IsInt, IsString } from 'class-validator';
|
||||
|
||||
export class CreateCarritoDto {
|
||||
@IsNumber()
|
||||
@IsInt()
|
||||
id_modulo: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsInt()
|
||||
id_tipo_carrito: number;
|
||||
|
||||
// @IsInt()
|
||||
// id_marca: number;
|
||||
|
||||
// @IsInt()
|
||||
// id_modulo: number;
|
||||
|
||||
@IsString()
|
||||
marca: string;
|
||||
|
||||
|
||||
@@ -8,17 +8,13 @@ export class UpdateCarritoDto {
|
||||
@IsOptional()
|
||||
activo?: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
carrito?: string;
|
||||
// @IsInt()
|
||||
// @IsOptional()
|
||||
// id_marca?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
id_modulo?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
id_tipo_carrito?: number;
|
||||
// @IsInt()
|
||||
// @IsOptional()
|
||||
// id_modelo?: number;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
|
||||
@@ -9,11 +9,11 @@ export class CarritoMinOutputDto {
|
||||
@Expose()
|
||||
carrito;
|
||||
|
||||
@Type(() => ModuloMinOutputDto)
|
||||
@Expose()
|
||||
@Type(() => ModuloMinOutputDto)
|
||||
modulo;
|
||||
|
||||
@Type(() => TipoCarritoOutputDto)
|
||||
@Expose()
|
||||
@Type(() => TipoCarritoOutputDto)
|
||||
tipoCarrito;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { TipoCarritoOutputDto } from '../../../institucion-tipo-carrito/dto/output/tipo-carrito.dto';
|
||||
import { ModuloMinOutputDto } from '../../../modulo/dto/output/modulo-min.dto';
|
||||
import { MarcaOutputDto } from '../../../marca/dto/output/marca.dto';
|
||||
import { ModeloOutputDto } from '../../../modelo/dto/output/modelo.dto';
|
||||
import { ModuloMinOutputDto } from '../../../modulo/dto/output/modulo-min.dto';
|
||||
|
||||
export class CarritoOutputDto {
|
||||
@Expose()
|
||||
@@ -14,17 +15,18 @@ export class CarritoOutputDto {
|
||||
carrito;
|
||||
|
||||
@Expose()
|
||||
// @Type(() => MarcaOutputDto)
|
||||
marca;
|
||||
|
||||
// @Type(() => ModeloOutputDto)
|
||||
@Expose()
|
||||
// @Type(() => ModeloOutputDto)
|
||||
modelo;
|
||||
|
||||
@Type(() => ModuloMinOutputDto)
|
||||
@Expose()
|
||||
@Type(() => ModuloMinOutputDto)
|
||||
modulo;
|
||||
|
||||
@Type(() => TipoCarritoOutputDto)
|
||||
@Expose()
|
||||
@Type(() => TipoCarritoOutputDto)
|
||||
tipoCarrito;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ export class CarritosOutputDto {
|
||||
@Expose()
|
||||
carrito;
|
||||
|
||||
@Type(() => ModuloMinOutputDto)
|
||||
@Expose()
|
||||
@Type(() => ModuloMinOutputDto)
|
||||
modulo;
|
||||
|
||||
@Type(() => TipoCarritoOutputDto)
|
||||
@Expose()
|
||||
@Type(() => TipoCarritoOutputDto)
|
||||
tipoCarrito;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { Equipo } from '../../equipo/entity/equipo.entity';
|
||||
import { Marca } from '../../marca/entity/marca.entity';
|
||||
import { Modelo } from '../../modelo/entity/modelo.entity';
|
||||
import { Modulo } from '../../modulo/entity/modulo.entity';
|
||||
import { TipoCarrito } from '../../institucion-tipo-carrito/entity/tipo-carrito.entity';
|
||||
@@ -22,14 +23,16 @@ export class Carrito {
|
||||
@Column({ type: String, nullable: false, length: 4 })
|
||||
carrito: string;
|
||||
|
||||
// @ManyToOne(() => Marca, (marca) => marca.carritos, { eager: true })
|
||||
// @JoinColumn({ name: 'id_marca' })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
marca: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
modelo: string;
|
||||
// marca: Marca;
|
||||
|
||||
// @ManyToOne(() => Modelo, (modelo) => modelo.carritos, { eager: true })
|
||||
// @JoinColumn({ name: 'id_modelo' })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
modelo: string;
|
||||
// modelo: Modelo;
|
||||
|
||||
@ManyToOne(() => Modulo, (modulo) => modulo.carritos, { eager: true })
|
||||
|
||||
@@ -36,7 +36,7 @@ export class EquipoProgramaService {
|
||||
? await this.institucionProgramaService.findProgramaById(id_programa)
|
||||
: id_programa;
|
||||
|
||||
return this.existeEquipoPrograma(equipo, programa)
|
||||
return this.findEquipoProgramaByEquipoPrograma(equipo, programa)
|
||||
.then((_) =>
|
||||
this.repository.save(this.repository.create({ equipo, programa })),
|
||||
)
|
||||
@@ -60,38 +60,22 @@ export class EquipoProgramaService {
|
||||
return this.create(equipoPrograma.equipo, 1);
|
||||
}
|
||||
});
|
||||
return this.repository
|
||||
.remove(equipoPrograma)
|
||||
.then((_) => ({
|
||||
message: 'Se eliminó correctamente el programa de este equipo.',
|
||||
}));
|
||||
return this.repository.remove(equipoPrograma).then((_) => ({
|
||||
message: 'Se eliminó correctamente el programa de este equipo.',
|
||||
}));
|
||||
}
|
||||
|
||||
eliminarEquipoSinPrograma(equipo: Equipo) {
|
||||
return this.institucionProgramaService
|
||||
.findProgramaById(1)
|
||||
.then((programa) => this.repository.findOne({ equipo, programa }))
|
||||
.then((programa) =>
|
||||
this.findEquipoProgramaByEquipoPrograma(equipo, programa, false),
|
||||
)
|
||||
.then((equipoPrograma) => {
|
||||
if (equipoPrograma) return this.delete(equipoPrograma);
|
||||
});
|
||||
}
|
||||
|
||||
existeEquipoPrograma(
|
||||
equipo: Equipo,
|
||||
programa: Programa,
|
||||
validarExistencia = true,
|
||||
) {
|
||||
return this.repository
|
||||
.findOne({ equipo, programa })
|
||||
.then((equipoPrograma) => {
|
||||
if (validarExistencia && equipoPrograma)
|
||||
throw new ConflictException(
|
||||
'Este programa ya fue asignado a este equipo.',
|
||||
);
|
||||
return equipoPrograma;
|
||||
});
|
||||
}
|
||||
|
||||
findById(id_equipo_programa: number) {
|
||||
return this.repository
|
||||
.findOne({
|
||||
@@ -104,4 +88,20 @@ export class EquipoProgramaService {
|
||||
return equipoPrograma;
|
||||
});
|
||||
}
|
||||
|
||||
findEquipoProgramaByEquipoPrograma(
|
||||
equipo: Equipo,
|
||||
programa: Programa,
|
||||
validarExistencia = true,
|
||||
) {
|
||||
return this.repository
|
||||
.findOne({ equipo, programa })
|
||||
.then((equipoPrograma) => {
|
||||
if (validarExistencia && equipoPrograma)
|
||||
throw new ConflictException(
|
||||
'Este programa ya fue asignado a este equipo.',
|
||||
);
|
||||
return equipoPrograma;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export class EquipoTipoEntradaService {
|
||||
)
|
||||
: id_tipo_entrada;
|
||||
|
||||
return this.existeEquipoTipoEntrada(equipo, tipoEntrada)
|
||||
return this.findEquipoTipoEntradaByEquipoTipoEntrada(equipo, tipoEntrada)
|
||||
.then((_) =>
|
||||
this.repository.save(this.repository.create({ equipo, tipoEntrada })),
|
||||
)
|
||||
@@ -49,7 +49,17 @@ export class EquipoTipoEntradaService {
|
||||
}));
|
||||
}
|
||||
|
||||
existeEquipoTipoEntrada(
|
||||
findById(id_equipo_tipo_entrada: number) {
|
||||
return this.repository
|
||||
.findOne({ id_equipo_tipo_entrada })
|
||||
.then((equipoTipoEntrada) => {
|
||||
if (!equipoTipoEntrada)
|
||||
throw new ConflictException('No existe este id equipo tipo entrada.');
|
||||
return equipoTipoEntrada;
|
||||
});
|
||||
}
|
||||
|
||||
findEquipoTipoEntradaByEquipoTipoEntrada(
|
||||
equipo: Equipo,
|
||||
tipoEntrada: TipoEntrada,
|
||||
validarExistencia = true,
|
||||
@@ -64,14 +74,4 @@ export class EquipoTipoEntradaService {
|
||||
return equipoTipoEntrada;
|
||||
});
|
||||
}
|
||||
|
||||
findById(id_equipo_tipo_entrada: number) {
|
||||
return this.repository
|
||||
.findOne({ id_equipo_tipo_entrada })
|
||||
.then((equipoTipoEntrada) => {
|
||||
if (!equipoTipoEntrada)
|
||||
throw new ConflictException('No existe este id equipo tipo entrada.');
|
||||
return equipoTipoEntrada;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
import { IsNumberString, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsNotEmpty,
|
||||
IsNumberString,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
export class EquiposDto {
|
||||
@IsNumberString()
|
||||
pagina: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
carrito?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
equipo?: string;
|
||||
|
||||
@@ -20,6 +27,14 @@ export class EquiposDto {
|
||||
@IsOptional()
|
||||
id_institucion?: string;
|
||||
|
||||
// @IsInt()
|
||||
// @IsOptional()
|
||||
// id_marca?: number;
|
||||
|
||||
// @IsInt()
|
||||
// @IsOptional()
|
||||
// id_modelo?: number;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_modulo?: string;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { IsInt, IsOptional, IsString } from 'class-validator';
|
||||
import { IsInt, IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class UpdateEquipoDto {
|
||||
@IsInt()
|
||||
id_equipo: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
equipo?: string;
|
||||
|
||||
@@ -12,6 +13,14 @@ export class UpdateEquipoDto {
|
||||
@IsOptional()
|
||||
id_carrito?: number;
|
||||
|
||||
// @IsInt()
|
||||
// @IsOptional()
|
||||
// id_marca?: number;
|
||||
|
||||
// @IsInt()
|
||||
// @IsOptional()
|
||||
// id_modelo?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
id_operador?: number;
|
||||
@@ -29,10 +38,8 @@ export class UpdateEquipoDto {
|
||||
modelo?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(250)
|
||||
@IsOptional()
|
||||
motivo?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
numero_serie?: string;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { CarritoMinOutputDto } from '../../../carrito/dto/output/carrito-min.dto';
|
||||
import { EquipoProgramaOutputDto } from '../../../equipo-programa/dto/output/equipo-programa.dto';
|
||||
import { MarcaOutputDto } from '../../../marca/dto/output/marca.dto';
|
||||
import { ModeloOutputDto } from '../../../modelo/dto/output/modelo.dto';
|
||||
import { EquipoTipoEntradaOutputDto } from '../../../equipo-tipo-entrada/dto/output/equipo-tipo-entrada.dto';
|
||||
import { StatusOutputDto } from '../../../status/dto/output/status.dto';
|
||||
|
||||
@@ -12,9 +14,11 @@ export class EquipoOutputDto {
|
||||
equipo;
|
||||
|
||||
@Expose()
|
||||
// @Type(() => MarcaOutputDto)
|
||||
marca;
|
||||
|
||||
@Expose()
|
||||
// @Type(() => ModeloOutputDto)
|
||||
modelo;
|
||||
|
||||
@Expose()
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
import { Carrito } from '../../carrito/entity/carrito.entity';
|
||||
import { EquipoPrograma } from '../../equipo-programa/entity/equipo-programa.entity';
|
||||
import { EquipoTipoEntrada } from '../../equipo-tipo-entrada/entity/equipo-tipo-entrada.entity';
|
||||
import { Marca } from '../../marca/entity/marca.entity';
|
||||
import { Modelo } from '../../modelo/entity/modelo.entity';
|
||||
import { Motivo } from '../../motivo/entity/motivo.entity';
|
||||
import { Prestamo } from '../../prestamo/entity/prestamo.entity';
|
||||
import { Status } from '../../status/entity/status.entity';
|
||||
@@ -18,7 +20,7 @@ export class Equipo {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_equipo: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 3 })
|
||||
@Column({ type: String, nullable: false, length: 4 })
|
||||
equipo: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
@@ -27,10 +29,10 @@ export class Equipo {
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
modelo: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 25 })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
numero_inventario: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 25 })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
numero_serie: string;
|
||||
|
||||
@Column({ type: Boolean, nullable: false, default: false })
|
||||
@@ -40,6 +42,14 @@ export class Equipo {
|
||||
@JoinColumn({ name: 'id_carrito' })
|
||||
carrito: Carrito;
|
||||
|
||||
// @ManyToOne(() => Marca, (marca) => marca.equipos, { eager: true })
|
||||
// @JoinColumn({ name: 'id_marca' })
|
||||
// marca: Marca;
|
||||
|
||||
// @ManyToOne(() => Modelo, (modelo) => modelo.equipos, { eager: true })
|
||||
// @JoinColumn({ name: 'id_modelo' })
|
||||
// modelo: Modelo;
|
||||
|
||||
@ManyToOne(() => Status, (status) => status.equipos, { eager: true })
|
||||
@JoinColumn({ name: 'id_status' })
|
||||
status: Status;
|
||||
|
||||
@@ -70,12 +70,30 @@ export class EquipoController {
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id del carrito que se quiere usar como filtro.',
|
||||
name: 'id_carrito',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id de la institución que se quiere usar como filtro.',
|
||||
name: 'id_institucion',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
// @ApiQuery({
|
||||
// description: 'Id de la marca que se quiere usar como filtro.',
|
||||
// name: 'id_marca',
|
||||
// type: 'string',
|
||||
// required: false,
|
||||
// })
|
||||
// @ApiQuery({
|
||||
// description: 'Id del modelo que se quiere usar como filtro.',
|
||||
// name: 'id_modelo',
|
||||
// type: 'string',
|
||||
// required: false,
|
||||
// })
|
||||
@ApiQuery({
|
||||
description: 'Id del módulo que se quiere usar como filtro.',
|
||||
name: 'id_modulo',
|
||||
@@ -113,7 +131,7 @@ export class EquipoController {
|
||||
@Put()
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que actualiza lan información de un equipo.',
|
||||
description: 'Endpoint que actualiza la información de un equipo.',
|
||||
})
|
||||
@ApiBearerAuth('jwt')
|
||||
@ApiBody({
|
||||
@@ -125,12 +143,13 @@ export class EquipoController {
|
||||
id_equipo: 1,
|
||||
_equipo: true,
|
||||
_id_carrito: '',
|
||||
// _id_marca: '',
|
||||
// _id_modelo: '',
|
||||
_id_operador: 1,
|
||||
_id_status: 1,
|
||||
_marca: '',
|
||||
_modelo: '',
|
||||
_motivo: '',
|
||||
_numero_serie: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -10,6 +10,8 @@ import { InstitucionModule } from '../institucion/institucion.module';
|
||||
import { InstitucionProgramaModule } from '../institucion-programa/institucion-programa.module';
|
||||
import { InstitucionTipoCarritoModule } from '../institucion-tipo-carrito/institucion-tipo-carrito.module';
|
||||
import { InstitucionTipoEntradaModule } from '../institucion-tipo-entrada/institucion-tipo-entrada.module';
|
||||
import { MarcaModule } from '../marca/marca.module';
|
||||
import { ModeloModule } from '../modelo/modelo.module';
|
||||
import { ModuloModule } from '../modulo/modulo.module';
|
||||
import { MotivoModule } from '../motivo/motivo.module';
|
||||
import { OperadorModule } from '../operador/operador.module';
|
||||
@@ -23,6 +25,8 @@ import { StatusModule } from '../status/status.module';
|
||||
InstitucionProgramaModule,
|
||||
InstitucionTipoCarritoModule,
|
||||
InstitucionTipoEntradaModule,
|
||||
MarcaModule,
|
||||
ModeloModule,
|
||||
ModuloModule,
|
||||
forwardRef(() => MotivoModule),
|
||||
OperadorModule,
|
||||
|
||||
@@ -10,6 +10,8 @@ import { Repository } from 'typeorm';
|
||||
import { Carrito } from '../carrito/entity/carrito.entity';
|
||||
import { Equipo } from './entity/equipo.entity';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
// import { Marca } from '../marca/entity/marca.entity';
|
||||
// import { Modelo } from '../modelo/entity/modelo.entity';
|
||||
import { Modulo } from '../modulo/entity/modulo.entity';
|
||||
import { Operador } from '../operador/entity/operador.entity';
|
||||
import { Programa } from '../institucion-programa/entity/programa.entity';
|
||||
@@ -21,6 +23,8 @@ import { InstitucionService } from '../institucion/institucion.service';
|
||||
import { InstitucionProgramaService } from '../institucion-programa/institucion-programa.service';
|
||||
import { InstitucionTipoCarritoService } from '../institucion-tipo-carrito/institucion-tipo-carrito.service';
|
||||
import { InstitucionTipoEntradaService } from '../institucion-tipo-entrada/institucion-tipo-entrada.service';
|
||||
import { MarcaService } from '../marca/marca.service';
|
||||
import { ModeloService } from '../modelo/modelo.service';
|
||||
import { ModuloService } from '../modulo/modulo.service';
|
||||
import { MotivoService } from '../motivo/motivo.service';
|
||||
import { OperadorService } from '../operador/operador.service';
|
||||
@@ -37,6 +41,8 @@ export class EquipoService {
|
||||
private institucionProgramaService: InstitucionProgramaService,
|
||||
private institucionTipoCarritoService: InstitucionTipoCarritoService,
|
||||
private institucionTipoEntradaService: InstitucionTipoEntradaService,
|
||||
private marcaService: MarcaService,
|
||||
private modeloService: ModeloService,
|
||||
private moduloService: ModuloService,
|
||||
@Inject(forwardRef(() => MotivoService))
|
||||
private motivoService: MotivoService,
|
||||
@@ -49,8 +55,8 @@ export class EquipoService {
|
||||
equipo: string,
|
||||
numero_inventario: string,
|
||||
numero_serie: string,
|
||||
marca: string,
|
||||
modelo: string,
|
||||
marca: string, // Marca,
|
||||
modelo: string, // Modelo,
|
||||
) {
|
||||
const activo = await this.statusService.findById(1);
|
||||
const equipoNuevo = await this.repository.save(
|
||||
@@ -70,26 +76,14 @@ export class EquipoService {
|
||||
.then((_) => equipoNuevo);
|
||||
}
|
||||
|
||||
async existeEquipo(id_carrito: number | Carrito, equipo: string) {
|
||||
const carrito =
|
||||
typeof id_carrito === 'number'
|
||||
? await this.carritoService.findById(id_carrito)
|
||||
: id_carrito;
|
||||
|
||||
return this.repository.findOne({ carrito, equipo }).then((existeEquipo) => {
|
||||
if (existeEquipo)
|
||||
throw new ConflictException(
|
||||
'Ya existe un equipo en este carrito con este nombre, intenta con otro.',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async findAll(filtros: {
|
||||
pagina: string;
|
||||
carrito?: string;
|
||||
equipo?: string;
|
||||
id_carrito?: string;
|
||||
id_institucion?: string;
|
||||
id_marca?: string;
|
||||
id_modelo?: string;
|
||||
id_modulo?: string;
|
||||
id_programa?: string;
|
||||
id_status?: string;
|
||||
@@ -102,6 +96,12 @@ export class EquipoService {
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
// const marca = filtros.id_marca
|
||||
// ? await this.marcaService.findById(parseInt(filtros.id_marca))
|
||||
// : null;
|
||||
// const modelo = filtros.id_modelo
|
||||
// ? await this.modeloService.findById(parseInt(filtros.id_modelo))
|
||||
// : null;
|
||||
const modulo = filtros.id_modulo
|
||||
? await this.moduloService.findById(parseInt(filtros.id_modulo))
|
||||
: null;
|
||||
@@ -150,18 +150,26 @@ export class EquipoService {
|
||||
query.andWhere('e.equipo LIKE :equipo', {
|
||||
equipo: `%${filtros.equipo}%`,
|
||||
});
|
||||
if (carrito)
|
||||
query.andWhere('c.id_carrito = :id_carrito', {
|
||||
id_carrito: carrito.id_carrito,
|
||||
});
|
||||
if (institucion)
|
||||
query.andWhere('m.id_institucion = :id_institucion', {
|
||||
id_institucion: institucion.id_institucion,
|
||||
});
|
||||
// if (marca)
|
||||
// query.andWhere('m.id_marca = :id_marca', {
|
||||
// id_marca: marca.id_marca,
|
||||
// });
|
||||
// if (modelo)
|
||||
// query.andWhere('m.id_modelo = :id_modelo', {
|
||||
// id_modelo: modelo.id_modelo,
|
||||
// });
|
||||
if (modulo)
|
||||
query.andWhere('m.id_modulo = :id_modulo', {
|
||||
id_modulo: modulo.id_modulo,
|
||||
});
|
||||
if (carrito)
|
||||
query.andWhere('c.id_carrito = :id_carrito', {
|
||||
id_carrito: carrito.id_carrito,
|
||||
});
|
||||
if (programa)
|
||||
query.andWhere('ps.id_programa = :id_programa', {
|
||||
id_programa: programa.id_programa,
|
||||
@@ -330,6 +338,8 @@ export class EquipoService {
|
||||
attrs: Partial<Equipo>,
|
||||
id_carrito?: number,
|
||||
id_status?: number,
|
||||
// id_marca?: number,
|
||||
// id_modelo?: number,
|
||||
id_operador?: number | Operador,
|
||||
motivo?: string,
|
||||
) {
|
||||
@@ -341,6 +351,16 @@ export class EquipoService {
|
||||
? await this.operadorService.findById(id_operador)
|
||||
: id_operador
|
||||
: null;
|
||||
// const marca = id_marca
|
||||
// ? typeof id_marca === 'number'
|
||||
// ? await this.marcaService.findById(id_marca)
|
||||
// : id_marca
|
||||
// : null;
|
||||
// const operador = id_operador
|
||||
// ? typeof id_operador === 'number'
|
||||
// ? await this.operadorService.findById(id_operador)
|
||||
// : id_operador
|
||||
// : null;
|
||||
const status = id_status
|
||||
? await this.statusService.findById(id_status)
|
||||
: null;
|
||||
@@ -348,10 +368,16 @@ export class EquipoService {
|
||||
return this.findById(attrs.id_equipo)
|
||||
.then(async (equipo) => {
|
||||
if ((attrs.equipo && attrs.equipo != equipo.equipo) || carrito)
|
||||
await this.existeEquipo(
|
||||
await this.findEquipoByEquipo(
|
||||
carrito ? carrito : equipo.carrito,
|
||||
attrs.equipo ? attrs.equipo : equipo.equipo,
|
||||
);
|
||||
false,
|
||||
).then((existeEquipo) => {
|
||||
if (existeEquipo)
|
||||
throw new ConflictException(
|
||||
'Ya existe un equipo en este carrito con este nombre, intenta con otro.',
|
||||
);
|
||||
});
|
||||
if (
|
||||
status &&
|
||||
(status.id_status >= 4 ||
|
||||
@@ -374,6 +400,8 @@ export class EquipoService {
|
||||
equipo.status = status;
|
||||
}
|
||||
if (carrito) equipo.carrito = carrito;
|
||||
// if (marca) equipo.marca = marca;
|
||||
// if (modelo) equipo.modelo = modelo;
|
||||
return this.repository.save(equipo);
|
||||
})
|
||||
.then((equipo) => ({
|
||||
|
||||
@@ -36,7 +36,7 @@ export class InstitucionDiaService {
|
||||
});
|
||||
}
|
||||
|
||||
findInstitucionDia(institucion: Institucion, id_dia: number) {
|
||||
findByInstitucionDia(institucion: Institucion, id_dia: number) {
|
||||
return this.repository.findOne({ institucion, dia: { id_dia } });
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export class InstitucionDiaService {
|
||||
return this.institucionService
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.findInstitucionDia(institucion, ahora.weekday()),
|
||||
this.findByInstitucionDia(institucion, ahora.weekday()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateInstitucionInfraccionDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(50)
|
||||
infraccion: string;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ export class Infraccion {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_infraccion: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 100 })
|
||||
@Column({ type: String, nullable: false, length: 50 })
|
||||
infraccion: string;
|
||||
|
||||
@OneToMany(
|
||||
|
||||
@@ -35,7 +35,7 @@ export class InstitucionInfraccionController {
|
||||
@ApiOperation({ description: 'Endpoint que crea una infracción.' })
|
||||
@ApiBearerAuth('jwt')
|
||||
@ApiBody({
|
||||
description: 'Es obligatorio mandar la variable infraccion.',
|
||||
description: 'Es obligatorio mandar la variable infracción.',
|
||||
examples: { ejemplo: { value: { infraccion: '' } } },
|
||||
})
|
||||
create(@Body() body: CreateInstitucionInfraccionDto) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateProgramaDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(40)
|
||||
programa: string;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export class Programa {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_programa: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 100 })
|
||||
@Column({ type: String, nullable: false, length: 40 })
|
||||
programa: string;
|
||||
|
||||
@OneToMany(
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateInstitucionTipoCarritoDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(2)
|
||||
letra: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(30)
|
||||
tipo_carrito: string;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ export class TipoCarrito {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_tipo_carrito: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 1 })
|
||||
@Column({ type: String, nullable: false, length: 2 })
|
||||
letra: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 20 })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
tipo_carrito: string;
|
||||
|
||||
@OneToMany(() => Carrito, (carrito) => carrito.tipoCarrito)
|
||||
|
||||
@@ -20,9 +20,9 @@ import { InstitucionTipoCarritoService } from './institucion-tipo-carrito.servic
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { CreateInstitucionTipoCarritoDto } from './dto/input/create.dto';
|
||||
import { UpdateInstitucionTipoCarritoDto } from './dto/input/update.dto';
|
||||
import { TipoCarritoOutputDto } from './dto/output/tipo-carrito.dto';
|
||||
import { InstitucionTiposCarritoOutputDto } from './dto/output/institucion-tipos-carrito.dto';
|
||||
import { InstitucionTiposCarritoMostarOutputDto } from './dto/output/institucion-tipos-carrito-mostar.dto';
|
||||
import { TipoCarritoOutputDto } from './dto/output/tipo-carrito.dto';
|
||||
|
||||
@Controller('institucion-tipo-carrito')
|
||||
@ApiTags('institucion-tipo-carrito')
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { InstitucionTipoCarrito } from './entity/institucion-tipo-carrito.entity';
|
||||
import { TipoCarrito } from './entity/tipo-carrito.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateInstitucionTipoEntradaDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(30)
|
||||
tipo_entrada: string;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class TipoEntrada {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_tipo_entrada: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 20 })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
tipo_entrada: string;
|
||||
|
||||
@OneToMany(
|
||||
|
||||
@@ -2,8 +2,10 @@ import {
|
||||
IsBoolean,
|
||||
IsEmail,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsPhoneNumber,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
@@ -24,6 +26,7 @@ export class UpdateInstitucionDto {
|
||||
dias_multa_retraso?: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
dominio?: string;
|
||||
|
||||
@@ -32,10 +35,11 @@ export class UpdateInstitucionDto {
|
||||
email_institucional?: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
responsable?: string;
|
||||
|
||||
@IsString()
|
||||
@IsPhoneNumber('MX')
|
||||
@IsOptional()
|
||||
telefono?: string;
|
||||
|
||||
@@ -52,6 +56,7 @@ export class UpdateInstitucionDto {
|
||||
tiempo_recoger?: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
ubicacion?: string;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ export class Institucion {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_institucion: number;
|
||||
|
||||
@Column({ type: Boolean, nullable: true, default: false })
|
||||
@Column({ type: Boolean, nullable: false, default: false })
|
||||
activo: boolean;
|
||||
|
||||
@Column({ type: String, nullable: true, length: 4 })
|
||||
@Column({ type: String, nullable: false, length: 4 })
|
||||
clave: string;
|
||||
|
||||
@Column({ type: String, nullable: true, length: 60, default: '' })
|
||||
@Column({ type: String, nullable: true, length: 60 })
|
||||
correo: string;
|
||||
|
||||
@Column({ type: Number, nullable: false, default: 7 })
|
||||
@@ -28,7 +28,7 @@ export class Institucion {
|
||||
@Column({ type: String, nullable: true, length: 40 })
|
||||
dominio: string;
|
||||
|
||||
@Column({ type: Boolean, nullable: true, default: false })
|
||||
@Column({ type: Boolean, nullable: false, default: false })
|
||||
email_institucional: boolean;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 150 })
|
||||
|
||||
@@ -12,9 +12,9 @@ import { InstitucionService } from './institucion.service';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { UpdateInstitucionDto } from './dto/input/update.dto';
|
||||
import { InstitucionOutputDto } from './dto/output/institucion.dto';
|
||||
import { InstitucionMinOutputDto } from './dto/output/institucion-min.dto';
|
||||
import { InstitucionesOutputDto } from './dto/output/instituciones.dto';
|
||||
import { InstitucionesMinOutputDto } from './dto/output/instituciones-min.dto';
|
||||
import { InstitucionMinOutputDto } from './dto/output/institucion-min.dto';
|
||||
|
||||
@Controller('institucion')
|
||||
@ApiTags('institucion')
|
||||
@@ -87,9 +87,9 @@ export class InstitucionController {
|
||||
_email_institucional: true,
|
||||
_responsable: '',
|
||||
_telefono: '',
|
||||
_tiempo_entrega: 7,
|
||||
_tiempo_prestamo: 7,
|
||||
_tiempo_recoger: 7,
|
||||
_tiempo_entrega: 15,
|
||||
_tiempo_prestamo: 120,
|
||||
_tiempo_recoger: 10,
|
||||
_ubicacion: '',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateMarcaDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(30)
|
||||
marca;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(1)
|
||||
tipo;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class MarcaDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(1)
|
||||
tipo;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class Marca {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_marca: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 20 })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
marca: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 1 })
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateModeloDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(30)
|
||||
modelo;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(1)
|
||||
tipo;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class ModeloDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(1)
|
||||
tipo;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class Modelo {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_modelo: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 20 })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
modelo: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 1 })
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { IsInt, IsString } from 'class-validator';
|
||||
import { IsInt, IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateModuloDto {
|
||||
@IsInt()
|
||||
id_institucion: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(30)
|
||||
modulo: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
} from 'class-validator';
|
||||
|
||||
export class UpdateModuloDto {
|
||||
@IsInt()
|
||||
@@ -9,6 +16,8 @@ export class UpdateModuloDto {
|
||||
activo?: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(30)
|
||||
@IsOptional()
|
||||
modulo?: string;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class Modulo {
|
||||
@Column({ type: Boolean, nullable: false, default: false })
|
||||
activo: boolean;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 50 })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
modulo: string;
|
||||
|
||||
@ManyToOne(() => Institucion, (institucion) => institucion.modulos, {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { IsInt, IsString } from 'class-validator';
|
||||
import { IsInt, IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class MultarDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(250)
|
||||
descripcion: string;
|
||||
|
||||
@IsInt()
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { IsNumberString, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsNotEmpty,
|
||||
IsNumberString,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
export class MultasDto {
|
||||
@IsNumberString()
|
||||
@@ -9,6 +14,7 @@ export class MultasDto {
|
||||
id_institucion?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
usuario?: string;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class Multa {
|
||||
@Column({ type: Boolean, nullable: false, default: true })
|
||||
activo: boolean;
|
||||
|
||||
@Column({ type: String, nullable: false })
|
||||
@Column({ type: String, nullable: false, length: 250 })
|
||||
descripcion: string;
|
||||
|
||||
@Column({ type: Date, nullable: false })
|
||||
|
||||
@@ -135,6 +135,9 @@ export class MultaService {
|
||||
id_institucion?: string;
|
||||
usuario?: string;
|
||||
}) {
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const query = this.repository
|
||||
.createQueryBuilder('mu')
|
||||
.innerJoinAndSelect('mu.institucionInfraccion', 'ii')
|
||||
@@ -158,9 +161,6 @@ export class MultaService {
|
||||
.addOrderBy('mu.id_multa', 'DESC')
|
||||
.skip((parseInt(filtros.pagina) - 1) * 25)
|
||||
.take(25);
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
|
||||
if (filtros.usuario)
|
||||
query.andWhere('u.usuario LIKE :usuario', {
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { IsEmail, IsInt, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsEmail,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
} from 'class-validator';
|
||||
|
||||
export class CreateOperadorDto {
|
||||
@IsEmail()
|
||||
@@ -11,12 +18,15 @@ export class CreateOperadorDto {
|
||||
id_tipo_usuario: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(40)
|
||||
nombre: string;
|
||||
|
||||
@IsString()
|
||||
operador: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
password?: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { IsNumberString, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsNotEmpty,
|
||||
IsNumberString,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
export class OperadoresDto {
|
||||
@IsNumberString()
|
||||
@@ -13,6 +18,7 @@ export class OperadoresDto {
|
||||
id_tipo_usuario?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
operador?: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
export class UpdateOperadorDto {
|
||||
@IsInt()
|
||||
@@ -9,6 +15,7 @@ export class UpdateOperadorDto {
|
||||
activo?: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
password?: string;
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ export class Operador {
|
||||
@Column({ type: Boolean, nullable: false, default: false })
|
||||
activo: boolean;
|
||||
|
||||
@Column({ type: String, nullable: true, length: 60 })
|
||||
@Column({ type: String, nullable: true, length: 80 })
|
||||
correo: string;
|
||||
|
||||
@Column({ type: String, nullable: true, length: 100 })
|
||||
nombre: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 50 })
|
||||
@Column({ type: String, nullable: false, length: 40 })
|
||||
operador: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 60 })
|
||||
|
||||
@@ -18,9 +18,9 @@ import {
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { OperadorService } from './operador.service';
|
||||
import { CreateOperadorDto } from './dto/input/create.dto';
|
||||
import { OperadorDto } from './dto/input/operador.dto';
|
||||
import { OperadoresDto } from './dto/input/operadores.dto';
|
||||
import { UpdateOperadorDto } from './dto/input/update.dto';
|
||||
import { OperadorDto } from './dto/input/operador.dto';
|
||||
import { OperadorOutputDto } from './dto/output/operador.dto';
|
||||
|
||||
@Controller('operador')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
IsBoolean,
|
||||
IsNotEmpty,
|
||||
IsNumberString,
|
||||
IsOptional,
|
||||
IsString,
|
||||
@@ -13,10 +14,12 @@ export class ActivosDto {
|
||||
pagina: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
carrito?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
equipo?: string;
|
||||
|
||||
@@ -41,6 +44,7 @@ export class ActivosDto {
|
||||
id_tipo_usuario?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
usuario?: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IsInt, IsString } from 'class-validator';
|
||||
import { IsInt, IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CancelarOperadorDto {
|
||||
@IsInt()
|
||||
@@ -8,5 +8,7 @@ export class CancelarOperadorDto {
|
||||
id_prestamo: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(250)
|
||||
motivo: string;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
IsDateString,
|
||||
IsNotEmpty,
|
||||
IsNumberString,
|
||||
IsOptional,
|
||||
IsString,
|
||||
@@ -10,10 +11,12 @@ export class HistorialDto {
|
||||
pagina: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
carrito?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
equipo?: string;
|
||||
|
||||
@@ -46,6 +49,7 @@ export class HistorialDto {
|
||||
id_tipo_usuario?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
usuario?: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { IsInt, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
} from 'class-validator';
|
||||
|
||||
export class RegresarIdPrestamoDto {
|
||||
@IsInt()
|
||||
@@ -8,6 +14,8 @@ export class RegresarIdPrestamoDto {
|
||||
id_prestamo: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(250)
|
||||
@IsOptional()
|
||||
descripcion?: string;
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { IsInt, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
} from 'class-validator';
|
||||
|
||||
export class RegresarNumeroInventarioDto {
|
||||
@IsInt()
|
||||
@@ -7,11 +13,13 @@ export class RegresarNumeroInventarioDto {
|
||||
@IsString()
|
||||
numero_inventario: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(250)
|
||||
@IsOptional()
|
||||
descripcion?: string;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
id_institucion_infraccion?: number;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
descripcion?: string;
|
||||
}
|
||||
|
||||
@@ -110,10 +110,11 @@ export class PrestamoService {
|
||||
await this.institucionTipoCarritoService.findTipoCarritoById(
|
||||
id_tipo_carrito,
|
||||
);
|
||||
const institucionDia = await this.institucionDiaService.findInstitucionDia(
|
||||
modulo.institucion,
|
||||
ahora.weekday(),
|
||||
);
|
||||
const institucionDia =
|
||||
await this.institucionDiaService.findByInstitucionDia(
|
||||
modulo.institucion,
|
||||
ahora.weekday(),
|
||||
);
|
||||
const horaMax = institucionDia
|
||||
? moment(`${ahora.format('YYYY-MM-DD')} ${institucionDia.hora_fin}`)
|
||||
: null;
|
||||
@@ -129,10 +130,6 @@ export class PrestamoService {
|
||||
)
|
||||
: null;
|
||||
|
||||
if (!usuario.activo)
|
||||
throw new ConflictException(
|
||||
`${this.mensajeNoPoderPedir()} tu cuenta esta desactivada.`,
|
||||
);
|
||||
this.validarInstitucionUsuario(usuario.instituciones, modulo);
|
||||
if (ahora.weekday() === 0 || ahora.weekday() === 6)
|
||||
throw new ConflictException('No hay servicio los días sábado y domingo.');
|
||||
@@ -280,31 +277,6 @@ export class PrestamoService {
|
||||
id_tipo_usuario?: string;
|
||||
usuario?: string;
|
||||
}) {
|
||||
const query = this.repository
|
||||
.createQueryBuilder('p')
|
||||
.innerJoinAndSelect('p.equipo', 'e')
|
||||
.innerJoinAndSelect('p.operadorEntrega', 'oe')
|
||||
.innerJoinAndSelect('p.operadorRegreso', 'or')
|
||||
.innerJoinAndSelect('p.usuario', 'u')
|
||||
.innerJoinAndSelect('e.carrito', 'c')
|
||||
.innerJoinAndSelect('oe.tipoUsuario', 'tuoe')
|
||||
.innerJoinAndSelect('or.tipoUsuario', 'tuor')
|
||||
.innerJoinAndSelect('u.instituciones', 'is')
|
||||
.innerJoinAndSelect('c.modulo', 'm')
|
||||
.innerJoinAndSelect('c.tipoCarrito', 'tc')
|
||||
.innerJoinAndSelect('is.institucionCarrera', 'ic')
|
||||
.innerJoinAndSelect('m.institucion', 'i')
|
||||
.innerJoinAndSelect('ic.carrera', 'ca')
|
||||
.innerJoinAndSelect('ic.institucion', 'in')
|
||||
.innerJoinAndSelect('ca.nivel', 'n')
|
||||
.orderBy('i.institucion')
|
||||
.addOrderBy('m.modulo')
|
||||
.addOrderBy('tc.tipo_carrito')
|
||||
.addOrderBy('c.carrito')
|
||||
.addOrderBy('e.equipo')
|
||||
.addOrderBy('p.id_prestamo', 'DESC')
|
||||
.skip((parseInt(filtros.pagina) - 1) * 25)
|
||||
.take(25);
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
@@ -331,6 +303,31 @@ export class PrestamoService {
|
||||
parseInt(filtros.id_tipo_usuario),
|
||||
)
|
||||
: null;
|
||||
const query = this.repository
|
||||
.createQueryBuilder('p')
|
||||
.innerJoinAndSelect('p.equipo', 'e')
|
||||
.innerJoinAndSelect('p.operadorEntrega', 'oe')
|
||||
.innerJoinAndSelect('p.operadorRegreso', 'or')
|
||||
.innerJoinAndSelect('p.usuario', 'u')
|
||||
.innerJoinAndSelect('e.carrito', 'c')
|
||||
.innerJoinAndSelect('oe.tipoUsuario', 'tuoe')
|
||||
.innerJoinAndSelect('or.tipoUsuario', 'tuor')
|
||||
.innerJoinAndSelect('u.instituciones', 'is')
|
||||
.innerJoinAndSelect('c.modulo', 'm')
|
||||
.innerJoinAndSelect('c.tipoCarrito', 'tc')
|
||||
.innerJoinAndSelect('is.institucionCarrera', 'ic')
|
||||
.innerJoinAndSelect('m.institucion', 'i')
|
||||
.innerJoinAndSelect('ic.carrera', 'ca')
|
||||
.innerJoinAndSelect('ic.institucion', 'in')
|
||||
.innerJoinAndSelect('ca.nivel', 'n')
|
||||
.orderBy('i.institucion')
|
||||
.addOrderBy('m.modulo')
|
||||
.addOrderBy('tc.tipo_carrito')
|
||||
.addOrderBy('c.carrito')
|
||||
.addOrderBy('e.equipo')
|
||||
.addOrderBy('p.id_prestamo', 'DESC')
|
||||
.skip((parseInt(filtros.pagina) - 1) * 25)
|
||||
.take(25);
|
||||
|
||||
if (filtros.activo) {
|
||||
if (typeof filtros.activo === 'boolean') {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
|
||||
|
||||
export class CreateTipoUsuarioDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(30)
|
||||
tipo_usuario: string;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class TipoUsuario {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_tipo_usuario: number;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 20 })
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
tipo_usuario: string;
|
||||
|
||||
@OneToMany(() => Operador, (operador) => operador.tipoUsuario)
|
||||
|
||||
@@ -157,7 +157,7 @@ export class UploadFileService {
|
||||
false,
|
||||
);
|
||||
const existeEquipoTipoEntrada = tipoEntrada
|
||||
? await this.equipoTipoEntradaService.existeEquipoTipoEntrada(
|
||||
? await this.equipoTipoEntradaService.findEquipoTipoEntradaByEquipoTipoEntrada(
|
||||
equipo,
|
||||
tipoEntrada,
|
||||
false,
|
||||
@@ -197,7 +197,7 @@ export class UploadFileService {
|
||||
false,
|
||||
);
|
||||
const existeEquipoPrograma = programa
|
||||
? await this.equipoProgramaService.existeEquipoPrograma(
|
||||
? await this.equipoProgramaService.findEquipoProgramaByEquipoPrograma(
|
||||
equipo,
|
||||
programa,
|
||||
false,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { IsNumberString, IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsNumberString, IsString } from 'class-validator';
|
||||
|
||||
export class DgaeInputDto {
|
||||
@IsNumberString()
|
||||
id_institucion_carrera: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
usuario: string;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { IsNumberString, IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsNumberString, IsString } from 'class-validator';
|
||||
|
||||
export class DgpInputDto {
|
||||
@IsNumberString()
|
||||
id_institucion: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
rfc: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
usuario: string;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UsuarioInputDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
usuario: string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { IsNumberString, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsNotEmpty,
|
||||
IsNumberString,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
export class UsuariosInputDto {
|
||||
@IsNumberString()
|
||||
@@ -17,10 +22,12 @@ export class UsuariosInputDto {
|
||||
id_tipo_usuario?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
nombre?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
usuario?: string;
|
||||
}
|
||||
|
||||
@@ -15,10 +15,7 @@ export class Usuario {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_usuario: number;
|
||||
|
||||
@Column({ type: Boolean, nullable: false, default: true })
|
||||
activo: boolean;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 60, default: '' })
|
||||
@Column({ type: String, nullable: false, length: 60 })
|
||||
correo: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 100 })
|
||||
@@ -27,6 +24,9 @@ export class Usuario {
|
||||
@Column({ type: String, nullable: true, length: 60, default: null })
|
||||
password: string;
|
||||
|
||||
@Column({ type: String, nullable: true, length: 12 })
|
||||
rfc: string;
|
||||
|
||||
@Column({ type: String, nullable: true, length: 10, default: null })
|
||||
telefono: string;
|
||||
|
||||
|
||||
@@ -80,10 +80,10 @@ export class UsuarioService {
|
||||
/* Falta conexión a soap */
|
||||
if (existeUsuario.password)
|
||||
throw new ConflictException('Ya fue regisrado este número de cuenta.');
|
||||
if (!existeUsuario.activo)
|
||||
throw new ConflictException(
|
||||
'No se puede registar con este número de cuenta por que se encuentra desactivado.',
|
||||
);
|
||||
// if (!existeUsuario.activo)
|
||||
// throw new ConflictException(
|
||||
// 'No se puede registar con este número de cuenta por que se encuentra desactivado.',
|
||||
// );
|
||||
return this.institucionUsuarioService.findByUsuarioInstitucionCarrera(
|
||||
existeUsuario,
|
||||
institucionCarrera,
|
||||
@@ -105,10 +105,10 @@ export class UsuarioService {
|
||||
throw new ConflictException(
|
||||
'Ya fue regisrado este número de trabajador.',
|
||||
);
|
||||
if (!existeUsuario.activo)
|
||||
throw new ConflictException(
|
||||
'No se puede registar con este número de trabajador por que se encuentra desactivado.',
|
||||
);
|
||||
// if (!existeUsuario.activo)
|
||||
// throw new ConflictException(
|
||||
// 'No se puede registar con este número de trabajador por que se encuentra desactivado.',
|
||||
// );
|
||||
return this.institucionUsuarioService.findByUsuarioInstitucionCarrera(
|
||||
existeUsuario,
|
||||
institucionCarrera,
|
||||
@@ -125,17 +125,6 @@ export class UsuarioService {
|
||||
nombre?: string;
|
||||
usuario?: string;
|
||||
}) {
|
||||
const query = this.repository
|
||||
.createQueryBuilder('u')
|
||||
.innerJoinAndSelect('u.instituciones', 'is')
|
||||
.innerJoinAndSelect('u.tipoUsuario', 'tu')
|
||||
.innerJoinAndSelect('is.institucionCarrera', 'ic')
|
||||
.innerJoinAndSelect('ic.carrera', 'c')
|
||||
.innerJoinAndSelect('ic.institucion', 'i')
|
||||
.innerJoinAndSelect('c.nivel', 'n')
|
||||
.take(25)
|
||||
.skip((parseInt(filtros.pagina) - 1) * 25)
|
||||
.where('u.password IS NOT NULL');
|
||||
const carrera = filtros.id_carrera
|
||||
? await this.institucionCarreraService.findCarreraByIdCarrera(
|
||||
parseInt(filtros.id_carrera),
|
||||
@@ -149,6 +138,17 @@ export class UsuarioService {
|
||||
parseInt(filtros.id_tipo_usuario),
|
||||
)
|
||||
: null;
|
||||
const query = this.repository
|
||||
.createQueryBuilder('u')
|
||||
.innerJoinAndSelect('u.instituciones', 'is')
|
||||
.innerJoinAndSelect('u.tipoUsuario', 'tu')
|
||||
.innerJoinAndSelect('is.institucionCarrera', 'ic')
|
||||
.innerJoinAndSelect('ic.carrera', 'c')
|
||||
.innerJoinAndSelect('ic.institucion', 'i')
|
||||
.innerJoinAndSelect('c.nivel', 'n')
|
||||
.take(25)
|
||||
.skip((parseInt(filtros.pagina) - 1) * 25)
|
||||
.where('u.password IS NOT NULL');
|
||||
|
||||
if (filtros.usuario)
|
||||
query.andWhere('u.usuario LIKE :usuario', {
|
||||
@@ -199,7 +199,7 @@ export class UsuarioService {
|
||||
usuario: string,
|
||||
validarNoExiste = true,
|
||||
password = false,
|
||||
activos = false,
|
||||
institucionesActivas = false,
|
||||
) {
|
||||
const query = this.repository
|
||||
.createQueryBuilder('u')
|
||||
@@ -211,7 +211,7 @@ export class UsuarioService {
|
||||
.innerJoinAndSelect('c.nivel', 'n')
|
||||
.where('usuario = :usuario', { usuario });
|
||||
|
||||
if (activos) query.andWhere('is.activo = 1');
|
||||
if (institucionesActivas) query.andWhere('is.activo = 1');
|
||||
return query.getOne().then((usuario) => {
|
||||
if (validarNoExiste && (!usuario || (password && !usuario.password)))
|
||||
throw new NotFoundException('No existe este usuario.');
|
||||
|
||||
Reference in New Issue
Block a user