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
49c98caff0
commit
161ee39828
@ -26,9 +26,13 @@ export class OfferController {
|
|||||||
constructor(private offerService: OfferService) {}
|
constructor(private offerService: OfferService) {}
|
||||||
|
|
||||||
@Get('/all')
|
@Get('/all')
|
||||||
getAllRoles(@GetUser() user: User) {
|
getAllOffers(@GetUser() user: User) {
|
||||||
return this.offerService.getOffers(user.id);
|
return this.offerService.getOffers(user.id);
|
||||||
}
|
}
|
||||||
|
@Get('/search/: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,6 +27,34 @@ 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