chore: add cover url field to the danak service entity

This commit is contained in:
mahyargdz
2025-04-23 14:36:20 +03:30
parent 10a7653451
commit c2949ba06a
4 changed files with 11 additions and 5 deletions
+2
View File
@@ -195,6 +195,8 @@ export const enum ServiceMessage {
REVIEW_STATUS_REQUIRED = "وضعیت نظر سرویس مورد نیاز است",
SHOW_IN_SLIDER_REQUIRED = "وضعیت نمایش در اسلایدر سرویس مورد نیاز است",
SHOW_IN_SLIDER_BOOLEAN = "وضعیت نمایش در اسلایدر سرویس باید یک بولین باشد",
COVER_URL_REQUIRED = "آدرس عکس کاور سرویس مورد نیاز است",
COVER_URL_SHOULD_BE_URL = "آدرس عکس کاور سرویس باید یک آدرس یو آر ال باشد",
}
export const enum AnnouncementMessage {
@@ -97,4 +97,9 @@ export class CreateServiceDto {
@IsString({ each: true })
@ApiProperty({ description: "The images of the service", example: ["https://example.com/image1.png", "https://example.com/image2.png"] })
images: string[];
@IsNotEmpty({ message: ServiceMessage.COVER_URL_REQUIRED })
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.COVER_URL_SHOULD_BE_URL })
@ApiProperty({ description: "The cover url of the service", example: "https://example.com/cover.png" })
coverUrl: string;
}
@@ -54,6 +54,8 @@ export class DanakService extends BaseEntity {
@Column({ type: "varchar", length: 255, nullable: false })
icon: string;
@Column({ type: "varchar", length: 255, nullable: true })
coverUrl: string;
//-------------------------------------
@ManyToOne(() => DanakServiceCategory, (danakServiceCategory) => danakServiceCategory.danakServices, {
nullable: false,
@@ -382,7 +382,7 @@ export class DanakServicesService {
async getDanakServicesSlider() {
const danakServices = await this.danakServicesRepository.find({
where: { showInSlider: true, isActive: true, deletedAt: IsNull(), category: { isActive: true, deletedAt: IsNull() } },
relations: { category: true, images: true },
relations: { category: true },
select: {
id: true,
name: true,
@@ -394,15 +394,12 @@ export class DanakServicesService {
isActive: true,
isDanakSuggest: true,
showInSlider: true,
coverUrl: true,
metaDescription: true,
category: {
id: true,
title: true,
},
images: {
id: true,
imageUrl: true,
},
},
order: { createdAt: "DESC" },
withDeleted: false,