mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-09 06:00:12 +02:00
added user assets visualisation
This commit is contained in:
parent
f4abd98d8c
commit
9e5fcaa0e8
@ -18,6 +18,14 @@ export class UserController {
|
|||||||
) {
|
) {
|
||||||
return this.userService.GetMyAssets(user.id);
|
return this.userService.GetMyAssets(user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('/users-assets')
|
||||||
|
GetAlLAssets(
|
||||||
|
@GetUser()
|
||||||
|
user: User,
|
||||||
|
) {
|
||||||
|
return this.userService.GetUsersAssets(user.id);
|
||||||
|
}
|
||||||
@Get('/my-trades')
|
@Get('/my-trades')
|
||||||
GetMyTrades(
|
GetMyTrades(
|
||||||
@GetUser()
|
@GetUser()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { checkUserHasAccount } from 'src/utils/checkUser';
|
import { checkUserHasAccount, checkuserIsAdmin } from 'src/utils/checkUser';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserService {
|
export class UserService {
|
||||||
@ -24,6 +24,25 @@ export class UserService {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async GetUsersAssets(userId: string) {
|
||||||
|
await checkuserIsAdmin(userId);
|
||||||
|
|
||||||
|
const user = await this.prisma.user.findMany({
|
||||||
|
select: {
|
||||||
|
firstName: true,
|
||||||
|
lastName: true,
|
||||||
|
pseudo: true,
|
||||||
|
dollarAvailables: true,
|
||||||
|
UserHasCrypto: {
|
||||||
|
select: {
|
||||||
|
Crypto: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
async GetMyTrades(userId: string) {
|
async GetMyTrades(userId: string) {
|
||||||
await checkUserHasAccount(userId);
|
await checkUserHasAccount(userId);
|
||||||
const user = await this.prisma.trade.findMany({
|
const user = await this.prisma.trade.findMany({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user