fixed crypto id on update offer

This commit is contained in:
Kevsl 2024-06-09 01:22:52 +02:00
parent 2787ec3e3e
commit ab276380d4
2 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsNumber, IsString } from 'class-validator';
import { IsNumber, IsPositive, IsString } from 'class-validator';
export class OfferDto {
@ApiProperty({
type: String,
@ -16,5 +16,6 @@ export class OfferDto {
example: 21,
})
@IsNumber()
@IsPositive()
amount: number;
}

View File

@ -43,8 +43,17 @@ export class OfferService {
},
});
const crypto = await this.prisma.crypto.findUnique({
where: {
id: dto.id_crypto,
},
});
if (!crypto || !crypto.id) {
throw new ForbiddenException('Crypto doesnt exist');
}
if (!offer || offer.id !== offerId)
throw new ForbiddenException('Access to resources denied');
throw new ForbiddenException('Offer id mandatory');
return this.prisma.role.update({
where: {