mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
NestJS backend with Prisma, Docker Compose for Postgres/Redis, and deploy docs for the production VM.
80 lines
1.4 KiB
TypeScript
80 lines
1.4 KiB
TypeScript
import { MediaEntityType } from '@prisma/client';
|
|
import { Transform, Type } from 'class-transformer';
|
|
import {
|
|
IsBoolean,
|
|
IsEmail,
|
|
IsEnum,
|
|
IsInt,
|
|
IsOptional,
|
|
IsString,
|
|
Min,
|
|
MinLength,
|
|
} from 'class-validator';
|
|
|
|
export class CreatePublicCommentDto {
|
|
@IsEnum(MediaEntityType)
|
|
entityType!: MediaEntityType;
|
|
|
|
@IsString()
|
|
@MinLength(1)
|
|
entityId!: string;
|
|
|
|
@IsString()
|
|
@MinLength(2)
|
|
authorName!: string;
|
|
|
|
@IsOptional()
|
|
@IsEmail()
|
|
authorEmail?: string;
|
|
|
|
@IsString()
|
|
@MinLength(1)
|
|
text!: string;
|
|
}
|
|
|
|
export class ListPublicCommentsDto {
|
|
@IsEnum(MediaEntityType)
|
|
entityType!: MediaEntityType;
|
|
|
|
@IsString()
|
|
@MinLength(1)
|
|
entityId!: string;
|
|
}
|
|
|
|
export class ListCommentsDto {
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
page?: number;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
pageSize?: number;
|
|
|
|
@IsOptional()
|
|
@IsEnum(MediaEntityType)
|
|
entityType?: MediaEntityType;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
entityId?: string;
|
|
|
|
/** Filter by approval: true = approved, false = pending, omit = all */
|
|
@IsOptional()
|
|
@Transform(({ value }) => {
|
|
if (value === 'true' || value === true) return true;
|
|
if (value === 'false' || value === false) return false;
|
|
return value;
|
|
})
|
|
@IsBoolean()
|
|
isApproved?: boolean;
|
|
}
|
|
|
|
export class UpdateCommentApprovalDto {
|
|
@IsBoolean()
|
|
isApproved!: boolean;
|
|
}
|