Files
shop-api/src/modules/blog/DTO/createBlog.dto.ts
T
mahyargdz be82059172 first
2025-09-14 15:15:03 +03:30

113 lines
4.0 KiB
TypeScript

import { Expose } from "class-transformer";
import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator";
import { ApiProperty } from "../../../common/decorator/swggerDocs";
import { IsValidId } from "../../../common/decorator/validation.decorator";
import { BlogCategoryModel } from "../models/blogCategory.model";
export class CreateBlogDTO {
@Expose()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: "string", description: "farsi title of blog", example: "دیابت | علائم، علل ابتلا، پیشگیری و درمان" })
title_fa: string;
@Expose()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: "string", description: "english slug of blog", example: "diabetes" })
slug: string;
@Expose()
@IsNotEmpty()
@IsValidId(BlogCategoryModel)
@ApiProperty({ type: "string", description: "id of blog category", example: "66eda6397ac110c16462737a" })
category: string;
@Expose()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: "string", description: "description of blog ", example: "دیابت | علائم، علل ابتلا، پیشگیری و درمان" })
description: string;
@Expose()
@IsNotEmpty()
@IsString()
@ApiProperty({
type: "string",
description: "description of blog ",
example:
"دیابت بیماری است که در آن بدن نمی تواند گلوکز لازم برای تامین انرژی سلول های بدن بیمار را تامین کند. در واقع شخصی که به این بیماری مبتلا باشد سطح گلوکز در بدن او بالا میماند و هورمونی به اسم انسولین که قند موجود در بدن را به انرژی تبدیل کند نمیتواند این انتقال را انجام دهد .",
})
content: string;
@Expose()
@IsNotEmpty()
@IsArray()
@IsString({ each: true })
@ApiProperty({ type: "Array", description: "tags of blog ", example: ["diabetes", "test", "sugar"] })
tags: string[];
@Expose()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: "string", description: "image url of blog ", example: "https://cdn.com" })
imageUrl: string;
}
export class UpdateBlogDTO {
@Expose()
@IsOptional()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: "string", description: "farsi title of blog", example: "دیابت | علائم، علل ابتلا، پیشگیری و درمان" })
title_fa?: string;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: "string", description: "english slug of blog", example: "diabetes" })
slug?: string;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsValidId(BlogCategoryModel)
@ApiProperty({ type: "string", description: "id of blog category", example: "66ed83563858f185c68449ff" })
category?: string;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: "string", description: "description of blog ", example: "دیابت | علائم، علل ابتلا، پیشگیری و درمان" })
description?: string;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsString()
@ApiProperty({
type: "string",
description: "description of blog ",
example:
"دیابت بیماری است که در آن بدن نمی تواند گلوکز لازم برای تامین انرژی سلول های بدن بیمار را تامین کند. در واقع شخصی که به این بیماری مبتلا باشد سطح گلوکز در بدن او بالا میماند و هورمونی به اسم انسولین که قند موجود در بدن را به انرژی تبدیل کند نمیتواند این انتقال را انجام دهد .",
})
content?: string;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsArray()
@IsString({ each: true })
@ApiProperty({ type: "Array", description: "tags of blog ", example: ["diabetes", "test", "sugar"] })
tags?: string[];
@Expose()
@IsOptional()
@IsNotEmpty()
@ApiProperty({ type: "string", description: "image url of blog ", example: "https://cdn.com" })
imageUrl?: string;
}