From 49faaf4fa0c01b1b7258002881d4c877b2ad7442 Mon Sep 17 00:00:00 2001 From: Kevsl Date: Wed, 12 Jun 2024 21:26:29 +0200 Subject: [PATCH] fix: fixed quantity display on cryptos --- src/crypto/crypto.controller.ts | 32 ++++++++++++++++---------------- src/crypto/crypto.service.ts | 4 ++-- src/user/user.service.ts | 5 +++++ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/crypto/crypto.controller.ts b/src/crypto/crypto.controller.ts index 20a3316..deada4f 100644 --- a/src/crypto/crypto.controller.ts +++ b/src/crypto/crypto.controller.ts @@ -1,12 +1,12 @@ import { Body, Controller, - Delete, + // Delete, Get, HttpCode, HttpStatus, Param, - Patch, + // Patch, Post, UseGuards, } from '@nestjs/common'; @@ -55,19 +55,19 @@ export class CryptoController { ) { return this.cryptoService.buyCrypto(user.id, dto); } - @HttpCode(HttpStatus.OK) - @Patch('/update/:id') - editCryptoById( - @Param('id') cryptoId: string, - @Body() dto: CryptoDto, - @GetUser() user: User, - ) { - return this.cryptoService.editCryptoById(user.id, cryptoId, dto); - } + // @HttpCode(HttpStatus.OK) + // @Patch('/update/:id') + // editCryptoById( + // @Param('id') cryptoId: string, + // @Body() dto: CryptoDto, + // @GetUser() user: User, + // ) { + // return this.cryptoService.editCryptoById(user.id, cryptoId, dto); + // } - @HttpCode(HttpStatus.NO_CONTENT) - @Delete('/delete/:id') - deleteOfferById(@Param('id') roleId: string, @GetUser() user: User) { - return this.cryptoService.deleteCryptoById(user.id, roleId); - } + // @HttpCode(HttpStatus.NO_CONTENT) + // @Delete('/delete/:id') + // deleteOfferById(@Param('id') roleId: string, @GetUser() user: User) { + // return this.cryptoService.deleteCryptoById(user.id, roleId); + // } } diff --git a/src/crypto/crypto.service.ts b/src/crypto/crypto.service.ts index 6ebbdad..07baabe 100644 --- a/src/crypto/crypto.service.ts +++ b/src/crypto/crypto.service.ts @@ -36,9 +36,9 @@ export class CryptoService { await checkUserHasAccount(userId); if (cryptoId) { - return this.prisma.crypto.findMany({ + return this.prisma.cryptoHistory.findMany({ where: { - id: cryptoId, + id_crypto: cryptoId, }, orderBy: { diff --git a/src/user/user.service.ts b/src/user/user.service.ts index 9c4447b..0147856 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -21,6 +21,7 @@ export class UserService { UserHasCrypto: { select: { Crypto: true, + amount: true, }, }, }, @@ -40,10 +41,14 @@ export class UserService { UserHasCrypto: { select: { Crypto: true, + amount: true, }, }, }, take: 50, + orderBy: { + dollarAvailables: 'desc', + }, }); return user; }