added user assets visualisation

This commit is contained in:
Kevsl 2024-06-07 16:00:26 +02:00
parent f4abd98d8c
commit 9e5fcaa0e8
2 changed files with 28 additions and 1 deletions

View File

@ -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()

View File

@ -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({