mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-08 21:50:13 +02:00
fixed get my assets
This commit is contained in:
parent
3c0f14b02e
commit
2db99d1354
@ -1,11 +1,5 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import {
|
||||
IsCreditCard,
|
||||
IsEmail,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
import { IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
export class AuthRegisterDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
|
9
src/trade/dto/promoCode.dto.ts
Normal file
9
src/trade/dto/promoCode.dto.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { IsInt, IsString } from 'class-validator';
|
||||
|
||||
export class PromoCodeDto {
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@IsInt()
|
||||
value: number;
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
@ -38,20 +35,4 @@ export class TradeController {
|
||||
) {
|
||||
return this.tradeService.createTrade(user.id, dto);
|
||||
}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Patch('/update/:id')
|
||||
editPromoCodeById(
|
||||
@Param('id') promoCodeId: string,
|
||||
@Body() dto: TradeDto,
|
||||
@GetUser() user: User,
|
||||
) {
|
||||
return this.tradeService.editTradeById(user.id, promoCodeId, dto);
|
||||
}
|
||||
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@Delete('/delete/:id')
|
||||
deletePromoCodeById(@Param('id') promoCodeId: string, @GetUser() user: User) {
|
||||
return this.tradeService.deleteTradeById(user.id, promoCodeId);
|
||||
}
|
||||
}
|
||||
|
@ -145,44 +145,4 @@ export class TradeService {
|
||||
});
|
||||
return trade;
|
||||
}
|
||||
|
||||
async editTradeById(userId: string, tradeId: string, dto: TradeDto) {
|
||||
await checkuserIsAdmin(userId);
|
||||
|
||||
const trade = await this.prisma.trade.findUnique({
|
||||
where: {
|
||||
id: tradeId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!trade || trade.id !== tradeId)
|
||||
throw new ForbiddenException('Access to resources denied');
|
||||
|
||||
return this.prisma.trade.update({
|
||||
where: {
|
||||
id: trade.id,
|
||||
},
|
||||
data: {
|
||||
...dto,
|
||||
},
|
||||
});
|
||||
}
|
||||
async deleteTradeById(userId: string, id: string) {
|
||||
await checkuserIsAdmin(userId);
|
||||
|
||||
const trade = await this.prisma.trade.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!trade || trade.id !== id)
|
||||
throw new ForbiddenException('Access to resources denied');
|
||||
|
||||
await this.prisma.trade.delete({
|
||||
where: {
|
||||
id: trade.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import { GetUser } from '../auth/decorator';
|
||||
import { JwtGuard } from '../auth/guard';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
Loading…
x
Reference in New Issue
Block a user