listo motivo carrito
This commit is contained in:
parent
97aa4b0aa9
commit
13dd9a0cfb
@ -188,6 +188,7 @@ export class CarritoController {
|
||||
},
|
||||
})
|
||||
update(@Request() req, @Body() body: UpdateCarritoDto) {
|
||||
const data = { ...body };
|
||||
const operador: Operador = req.user.operador;
|
||||
|
||||
if (
|
||||
@ -198,6 +199,7 @@ export class CarritoController {
|
||||
throw new ForbiddenException(
|
||||
'No tienes los permisos necesarios para realizar esta acción.',
|
||||
);
|
||||
return this.carritoService.update(operador, body);
|
||||
delete data.motivo;
|
||||
return this.carritoService.update(operador, data, body.motivo);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import {
|
||||
ConflictException,
|
||||
ForbiddenException,
|
||||
forwardRef,
|
||||
Inject,
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
@ -10,6 +12,7 @@ import { Carrito } from './entity/carrito.entity';
|
||||
import { Modulo } from '../modulo/entity/modulo.entity';
|
||||
import { Operador } from '../operador/entity/operador.entity';
|
||||
import { TipoCarrito } from '../institucion-tipo-carrito/entity/tipo-carrito.entity';
|
||||
import { CaritoMotivoService } from '../carrito-motivo/carrito-motivo.service';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
import { InstitucionTipoCarritoService } from '../institucion-tipo-carrito/institucion-tipo-carrito.service';
|
||||
import { MarcaService } from '../marca/marca.service';
|
||||
@ -20,6 +23,8 @@ import { ModuloService } from '../modulo/modulo.service';
|
||||
export class CarritoService {
|
||||
constructor(
|
||||
@InjectRepository(Carrito) private repository: Repository<Carrito>,
|
||||
@Inject(forwardRef(() => CaritoMotivoService))
|
||||
private caritoMotivoService: CaritoMotivoService,
|
||||
private institucionService: InstitucionService,
|
||||
private institucionTipoCarritoService: InstitucionTipoCarritoService,
|
||||
private marcaService: MarcaService,
|
||||
@ -178,7 +183,7 @@ export class CarritoService {
|
||||
});
|
||||
}
|
||||
|
||||
async update(operador: Operador, attrs: Partial<Carrito>) {
|
||||
async update(operador: Operador, attrs: Partial<Carrito>, motivo: string) {
|
||||
return this.findById(attrs.id_carrito)
|
||||
.then(async (carrito) => {
|
||||
if (
|
||||
@ -191,6 +196,14 @@ export class CarritoService {
|
||||
Object.assign(carrito, attrs);
|
||||
return this.repository.save(carrito);
|
||||
})
|
||||
.then((carrito) =>
|
||||
this.caritoMotivoService.create(
|
||||
carrito,
|
||||
operador,
|
||||
attrs.activo,
|
||||
motivo,
|
||||
),
|
||||
)
|
||||
.then((_) => ({
|
||||
message: 'Se guardaron los cambios correctamente.',
|
||||
}));
|
||||
|
@ -1,10 +1,20 @@
|
||||
import { IsBoolean, IsInt, IsOptional } from 'class-validator';
|
||||
import {
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsString,
|
||||
MaxLength,
|
||||
} from 'class-validator';
|
||||
|
||||
export class UpdateCarritoDto {
|
||||
@IsInt()
|
||||
id_carrito: number;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
activo?: boolean;
|
||||
activo: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(250)
|
||||
motivo;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user