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 { ApiProperty } from '@nestjs/swagger';
import { IsNumber, IsString } from 'class-validator'; import { IsNumber, IsPositive, IsString } from 'class-validator';
export class OfferDto { export class OfferDto {
@ApiProperty({ @ApiProperty({
type: String, type: String,
@ -16,5 +16,6 @@ export class OfferDto {
example: 21, example: 21,
}) })
@IsNumber() @IsNumber()
@IsPositive()
amount: number; 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) if (!offer || offer.id !== offerId)
throw new ForbiddenException('Access to resources denied'); throw new ForbiddenException('Offer id mandatory');
return this.prisma.role.update({ return this.prisma.role.update({
where: { where: {