mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-09 14:00:12 +02:00
added offers by crypto id
This commit is contained in:
parent
9b4194f618
commit
124502a820
@ -29,10 +29,6 @@ export class OfferController {
|
|||||||
getAllOffers(@GetUser() user: User) {
|
getAllOffers(@GetUser() user: User) {
|
||||||
return this.offerService.getOffers(user.id);
|
return this.offerService.getOffers(user.id);
|
||||||
}
|
}
|
||||||
@Get('/crypto/:id')
|
|
||||||
searchOfferByCryptoId(@GetUser() user: User, @Param('id') cryptoId: string) {
|
|
||||||
return this.offerService.getOffersByCryptoId(user.id, cryptoId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@HttpCode(HttpStatus.CREATED)
|
@HttpCode(HttpStatus.CREATED)
|
||||||
@Post('/create')
|
@Post('/create')
|
||||||
|
@ -27,34 +27,6 @@ export class OfferService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOffersByCryptoId(userId: string, cryptoId: string) {
|
|
||||||
await checkUserHasAccount(userId);
|
|
||||||
|
|
||||||
return this.prisma.offer.findMany({
|
|
||||||
where: {
|
|
||||||
Crypto: {
|
|
||||||
id: cryptoId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
orderBy: {
|
|
||||||
amount: 'desc',
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
User: {
|
|
||||||
select: {
|
|
||||||
pseudo: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
amount: true,
|
|
||||||
created_at: true,
|
|
||||||
id_user: true,
|
|
||||||
Crypto: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async createOffer(userId: string, dto: OfferDto) {
|
async createOffer(userId: string, dto: OfferDto) {
|
||||||
await checkUserHasAccount(userId);
|
await checkUserHasAccount(userId);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user