mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-09 06:00:12 +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 { ApiProperty } from '@nestjs/swagger';
|
||||||
import {
|
import { IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||||
IsCreditCard,
|
|
||||||
IsEmail,
|
|
||||||
IsNotEmpty,
|
|
||||||
IsOptional,
|
|
||||||
IsString,
|
|
||||||
} from 'class-validator';
|
|
||||||
export class AuthRegisterDto {
|
export class AuthRegisterDto {
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
type: String,
|
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 {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
|
||||||
Get,
|
Get,
|
||||||
HttpCode,
|
HttpCode,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
Param,
|
|
||||||
Patch,
|
|
||||||
Post,
|
Post,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
@ -38,20 +35,4 @@ export class TradeController {
|
|||||||
) {
|
) {
|
||||||
return this.tradeService.createTrade(user.id, dto);
|
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;
|
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 { GetUser } from '../auth/decorator';
|
||||||
import { JwtGuard } from '../auth/guard';
|
import { JwtGuard } from '../auth/guard';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user