update: add thumbnail url to the template entity

This commit is contained in:
mahyargdz
2025-07-16 09:19:15 +03:30
parent c427a8fff2
commit 2e898050ec
4 changed files with 20 additions and 12 deletions
+2
View File
@@ -479,4 +479,6 @@ export const enum TemplateMessage {
TEMPLATE_BUSINESS_NOT_FOUND = "کسب و کار مالک قالب یافت نشد",
SEARCH_STRING = "نام برای جستجو باید یک رشته باشد",
TEMPLATE_SELECTED_SUCCESSFULLY = "وضعیت قالب با موفقیت تغییر کرد",
TEMPLATE_THUMBNAIL_URL_VALID = "آدرس تصویر قالب باید یک آدرس معتبر باشد",
TEMPLATE_RAW_HTML_REQUIRED = "HTML خام قالب الزامی است",
}
@@ -1,5 +1,5 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator";
import { IsNotEmpty, IsOptional, IsString, IsUrl, MaxLength } from "class-validator";
import { TemplateMessage } from "../../../common/enums/message.enum";
// import { PersonalityDataType } from "../interfaces/structure.interface";
@@ -33,13 +33,15 @@ export class CreateTemplateDto {
})
structure: Record<string, unknown>;
@IsOptional()
@IsNotEmpty({ message: TemplateMessage.TEMPLATE_RAW_HTML_REQUIRED })
@IsString({ message: TemplateMessage.TEMPLATE_RAW_HTML_STRING })
@ApiPropertyOptional({
description: "Raw HTML content of the template (optional)",
example: "<html><body><h1>Template Content</h1></body></html>",
})
rawHtml?: string;
@ApiProperty({ description: "Raw HTML content of the template", example: "<html><body><h1>Template Content</h1></body></html>" })
rawHtml: string;
@IsOptional()
@IsUrl({ protocols: ["http", "https"] }, { message: TemplateMessage.TEMPLATE_THUMBNAIL_URL_VALID })
@ApiPropertyOptional({ description: "Thumbnail URL of the template (optional)", example: "https://example.com/thumbnail.png" })
thumbnailUrl?: string;
// @IsNotEmpty({ message: "شناسه کسب و کار الزامی است" })
// @IsUUID("7", { message: "شناسه کسب و کار باید یک UUID معتبر باشد" })
@@ -10,20 +10,23 @@ import { TemplateRepository } from "../repositories/template.repository";
@Entity({ repository: () => TemplateRepository })
export class Template extends BaseEntity {
@Property({ type: "varchar", length: 255, nullable: false })
name: string;
name!: string;
@Property({ type: "jsonb" })
structure: unknown;
structure!: unknown;
@Property({ type: "text", nullable: true })
rawHtml?: string;
@Property({ type: "text", nullable: false })
rawHtml!: string;
@Property({ type: "uuid", onCreate: () => uuidv7() })
currentVersion: string;
currentVersion!: string;
@Property({ type: "boolean", default: false })
selected: boolean & Opt;
@Property({ type: "varchar", length: 255, nullable: true })
thumbnailUrl?: string;
//--------------------------------------------------
@OneToMany(() => User, (user) => user.template)
@@ -29,6 +29,7 @@ export class TemplatesService {
name: createTemplateDto.name,
structure: createTemplateDto.structure,
rawHtml: createTemplateDto.rawHtml,
thumbnailUrl: createTemplateDto.thumbnailUrl,
currentVersion: uuidv7(),
business,
});