feat: update subscription and service entities with enhancements

- Update message enum for better error handling
- Enhance service creation DTO with new fields
- Modify danak-service entity structure
- Update subscription DTOs and entities
- Improve user subscription entity model
This commit is contained in:
mahyargdz
2025-08-19 09:32:25 +03:30
parent 72b1edbe25
commit 43a3714284
5 changed files with 21 additions and 6 deletions
+4 -1
View File
@@ -208,7 +208,10 @@ export const enum ServiceMessage {
SERVICE_ALREADY_EXISTS_WITH_THIS_SLUG = "سرویسی با این اسلاگ قبلا ثبت شده است", SERVICE_ALREADY_EXISTS_WITH_THIS_SLUG = "سرویسی با این اسلاگ قبلا ثبت شده است",
PAGE_TITLE_REQUIRED = "عنوان صفحه سرویس مورد نیاز است", PAGE_TITLE_REQUIRED = "عنوان صفحه سرویس مورد نیاز است",
PAGE_TITLE_STRING = "عنوان صفحه سرویس باید یک رشته باشد", PAGE_TITLE_STRING = "عنوان صفحه سرویس باید یک رشته باشد",
PAGE_TITLE_LENGTH = "عنوان صفحه سرویس باید بین ۳ تا ۱۵۰۰ کاراکتر باشد", PAGE_TITLE_LENGTH = "عنوان صفحه سرویس باید بین ۳ تا ۵۰۰ کاراکتر باشد",
PAGE_DESCRIPTION_REQUIRED = "توضیحات صفحه سرویس مورد نیاز است",
PAGE_DESCRIPTION_STRING = "توضیحات صفحه سرویس باید یک رشته باشد",
PAGE_DESCRIPTION_LENGTH = "توضیحات صفحه سرویس باید بین ۱۰ تا ۵۰۰ کاراکتر باشد",
} }
export const enum AnnouncementMessage { export const enum AnnouncementMessage {
@@ -37,10 +37,17 @@ export class CreateServiceDto {
@IsOptional() @IsOptional()
@IsNotEmpty({ message: ServiceMessage.PAGE_TITLE_REQUIRED }) @IsNotEmpty({ message: ServiceMessage.PAGE_TITLE_REQUIRED })
@IsString({ message: ServiceMessage.PAGE_TITLE_STRING }) @IsString({ message: ServiceMessage.PAGE_TITLE_STRING })
@Length(3, 1500, { message: ServiceMessage.PAGE_TITLE_LENGTH }) @Length(3, 500, { message: ServiceMessage.PAGE_TITLE_LENGTH })
@ApiProperty({ description: "The page title of the service", example: "Service Page Title" }) @ApiProperty({ description: "The page title of the service", example: "Service Page Title" })
pageTitle?: string; pageTitle?: string;
@IsOptional()
@IsNotEmpty({ message: ServiceMessage.PAGE_DESCRIPTION_REQUIRED })
@IsString({ message: ServiceMessage.PAGE_DESCRIPTION_STRING })
@Length(10, 500, { message: ServiceMessage.PAGE_DESCRIPTION_LENGTH })
@ApiProperty({ description: "The page description of the service", example: "Service Page Description" })
pageDescription?: string;
@IsNotEmpty({ message: ServiceMessage.DESCRIPTION_REQUIRED }) @IsNotEmpty({ message: ServiceMessage.DESCRIPTION_REQUIRED })
@IsString({ message: ServiceMessage.DESCRIPTION_STRING }) @IsString({ message: ServiceMessage.DESCRIPTION_STRING })
@Length(10, 500, { message: ServiceMessage.DESCRIPTION_LENGTH }) @Length(10, 500, { message: ServiceMessage.DESCRIPTION_LENGTH })
@@ -22,6 +22,9 @@ export class DanakService extends BaseEntity {
@Column({ type: "text", nullable: true }) @Column({ type: "text", nullable: true })
pageTitle: string | null; pageTitle: string | null;
@Column({ type: "text", nullable: true })
pageDescription: string | null;
@Column({ type: "varchar", length: 150, nullable: true, unique: true }) @Column({ type: "varchar", length: 150, nullable: true, unique: true })
@Index() @Index()
slug: string | null; slug: string | null;
@@ -15,11 +15,13 @@ export class SubscribeServiceDto {
@ApiProperty({ description: "Name of business", example: "Test 1" }) @ApiProperty({ description: "Name of business", example: "Test 1" })
businessName: string; businessName: string;
@IsOptional()
@IsNotEmpty({ message: SubscriptionMessage.BUSINESS_PHONE_REQUIRED }) @IsNotEmpty({ message: SubscriptionMessage.BUSINESS_PHONE_REQUIRED })
@IsPhoneNumber("IR", { message: SubscriptionMessage.BUSINESS_PHONE_INVALID }) @IsPhoneNumber("IR", { message: SubscriptionMessage.BUSINESS_PHONE_INVALID })
@ApiProperty({ description: "Phone number of the business", example: "+98 234 567 8901", required: false }) @ApiProperty({ description: "Phone number of the business", example: "+98 234 567 8901", required: false })
businessPhone: string; businessPhone: string;
@IsOptional()
@IsNotEmpty({ message: SubscriptionMessage.BUSINESS_DESCRIPTION_REQUIRED }) @IsNotEmpty({ message: SubscriptionMessage.BUSINESS_DESCRIPTION_REQUIRED })
@IsString({ message: SubscriptionMessage.BUSINESS_DESCRIPTION_STRING }) @IsString({ message: SubscriptionMessage.BUSINESS_DESCRIPTION_STRING })
@Length(5, 500, { message: SubscriptionMessage.BUSINESS_DESCRIPTION_LENGTH }) @Length(5, 500, { message: SubscriptionMessage.BUSINESS_DESCRIPTION_LENGTH })
@@ -22,11 +22,11 @@ export class UserSubscription extends BaseEntity {
@Column({ type: "varchar", length: 250, nullable: false }) @Column({ type: "varchar", length: 250, nullable: false })
businessName: string; businessName: string;
@Column({ type: "varchar", length: 50, nullable: false }) @Column({ type: "varchar", length: 50, nullable: true })
businessPhone: string; businessPhone: string | null;
@Column({ type: "text", nullable: false }) @Column({ type: "text", nullable: true })
description: string; description: string | null;
@Column({ type: "varchar", length: 250, unique: true, nullable: true }) @Column({ type: "varchar", length: 250, unique: true, nullable: true })
slug: string; slug: string;