marca y modelo arreglado

This commit is contained in:
2022-08-05 07:28:21 -05:00
parent 1002c878ba
commit c4fd8098e2
20 changed files with 165 additions and 166 deletions
+6 -6
View File
@@ -1,6 +1,6 @@
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
// import { Carrito } from '../../carrito/entity/carrito.entity';
// import { Equipo } from '../../equipo/entity/equipo.entity';
import { Carrito } from '../../carrito/entity/carrito.entity';
import { Equipo } from '../../equipo/entity/equipo.entity';
@Entity()
export class Marca {
@@ -13,9 +13,9 @@ export class Marca {
@Column({ type: String, nullable: false, length: 1 })
tipo: string;
// @OneToMany(() => Carrito, (carrito) => carrito.marca)
// carritos: Carrito[];
@OneToMany(() => Carrito, (carrito) => carrito.marca)
carritos: Carrito[];
// @OneToMany(() => Equipo, (equipo) => equipo.marca)
// equipos: Equipo[];
@OneToMany(() => Equipo, (equipo) => equipo.marca)
equipos: Equipo[];
}
+8
View File
@@ -22,6 +22,14 @@ export class MarcaService {
return this.repository.find({ where: { tipo }, order: { tipo: 'ASC' } });
}
findById(id_marca: number, tipo: string, validarExistencia = true) {
return this.repository.findOne({ id_marca, tipo }).then((marca) => {
if (validarExistencia && !marca)
throw new ConflictException('No existe esta marca.');
return marca;
});
}
findByMarca(marca: string, tipo: string, validarExistencia = true) {
return this.repository.findOne({ marca, tipo }).then((marca) => {
if (validarExistencia && !marca)