From 2a9cd13cc5e478c1bd32a8d7ff2eadd35f214c72 Mon Sep 17 00:00:00 2001 From: artemkolodko Date: Wed, 29 Jan 2025 10:29:45 +0000 Subject: [PATCH] Update reports dto --- src/app.controller.ts | 4 ---- src/dto/report.dto.ts | 10 +++++++++- src/entities/report.entity.ts | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/app.controller.ts b/src/app.controller.ts index ab882fd..216a727 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -199,10 +199,6 @@ export class AppController { throw new BadRequestException('No token or user address provided') } - if(!dto.type) { - throw new BadRequestException('No type provided') - } - const existedReports = await this.appService.getReports(dto) if(existedReports.length > 0) { throw new BadRequestException('Report already exists') diff --git a/src/dto/report.dto.ts b/src/dto/report.dto.ts index 52abeb1..0a5dd04 100644 --- a/src/dto/report.dto.ts +++ b/src/dto/report.dto.ts @@ -1,11 +1,13 @@ import { ApiProperty } from '@nestjs/swagger'; -import {IsNumber, IsOptional, IsString, Max} from 'class-validator'; +import {IsNumber, IsOptional, IsString, Max, Min} from 'class-validator'; import {Transform, Type} from "class-transformer"; export class AddReportDto { @ApiProperty({ type: Number, required: true }) @Type(() => Number) @IsNumber() + @Min(-1) + @Max(3) type: number; @ApiProperty({ type: String, required: false }) @@ -28,6 +30,12 @@ export class AddReportDto { @IsString() @IsOptional() reporterUserAddress?: string; + + @ApiProperty({ type: String, required: false }) + @Type(() => String) + @IsString() + @IsOptional() + details?: string; } export class GetReportsDto { diff --git a/src/entities/report.entity.ts b/src/entities/report.entity.ts index 8537a0d..9244f76 100644 --- a/src/entities/report.entity.ts +++ b/src/entities/report.entity.ts @@ -28,7 +28,7 @@ export class ReportEntity { @Column({ nullable: true }) reporterUserAddress: string; - @ApiProperty() + @ApiProperty({ required: false }) @Column({ nullable: true }) details: string;