Skip to content
This repository was archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
fix: fix getModel and getVehicleBodyWork
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielDeSouzza committed Jun 9, 2024
1 parent 1696927 commit 46bd696
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ export class PhysicalCustomerUseCases {
'IS NECESSARY AN ID, CPF, RG OR NATURALPERSON ID',
{ extensions: { code: HttpStatus.BAD_REQUEST } },
);
const physicalCustomerOrder =
const physicalCustomer =
await this.physicalCustomerRepository.findPhysicalCustomer(request);
console.log(request);
if (!physicalCustomerOrder)
throw new GraphQLError('ORDER NOT FOUND', {
if (!physicalCustomer)
throw new GraphQLError('Physical Customer NOT FOUND', {
extensions: { code: HttpStatus.NOT_FOUND },
});

return physicalCustomerOrder;
return physicalCustomer;
}
async getAllPhysicalCustomer(request: GetAllPhysicalCustomerDTO) {
return this.physicalCustomerRepository.findAllPhysicalCustomer(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export class VehicleModelUseCases {
throw new GraphQLError('IS NECESSARY AN ID OR MODEL NAME', {
extensions: { code: HttpStatus.BAD_REQUEST },
});

const model = await this.vehicleModelRepository.findVehicleModel(request);

if (model) return model;

throw new GraphQLError('MODEL NOT FOUND', {
Expand Down Expand Up @@ -104,7 +106,9 @@ export class VehicleModelUseCases {
return this.vehicleModelRepository.createVehicleModel(modelEntity);
}
async updateModel(id: string, data: UpdateVehicleModelDTO) {
const modelExist = await this.getModel({ name: data.name });
const modelExist = await this.vehicleModelRepository.findVehicleModel({
name: data.name,
});

if (modelExist) {
throw new GraphQLError('NAME ALREADY IN USE', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class VehicleBodyworkPrismaDto {
): Prisma.VehicleBodyworkUncheckedUpdateInput {
return {
axles: vehicleBodywork.axles,
id: vehicleBodywork.id,
mass: vehicleBodywork.mass,
name: vehicleBodywork.name,
updated_by: vehicleBodywork.updated_by,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export class VehicleModelResolver {

@Query(() => VehicleModelGraphql)
async getVehicleModel(@Args() request: GetVehicleModelArgs) {
console.log(request);

return await this.vehicleModelUseCase.getModel(request);
}

Expand Down

0 comments on commit 46bd696

Please sign in to comment.