mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-08 21:50:13 +02:00
fixed crypto id on update offer
This commit is contained in:
parent
2787ec3e3e
commit
ab276380d4
@ -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;
|
||||
}
|
||||
|
@ -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: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user