mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-09 06:00:12 +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 { 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;
|
||||||
}
|
}
|
||||||
|
@ -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: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user