edit admin
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class NullableServiceTemplateDefaultDuration1789045000000
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'NullableServiceTemplateDefaultDuration1789045000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "service_templates"
|
||||
ALTER COLUMN "defaultDurationMinutes" DROP DEFAULT,
|
||||
ALTER COLUMN "defaultDurationMinutes" DROP NOT NULL
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
UPDATE "service_templates"
|
||||
SET "defaultDurationMinutes" = 30
|
||||
WHERE "defaultDurationMinutes" IS NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "service_templates"
|
||||
ALTER COLUMN "defaultDurationMinutes" SET DEFAULT 30,
|
||||
ALTER COLUMN "defaultDurationMinutes" SET NOT NULL
|
||||
`);
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ export class ServiceTemplateEntity {
|
||||
@Column({ type: 'varchar', nullable: true, length: 400 })
|
||||
description!: string | null;
|
||||
|
||||
@Column({ type: 'int', default: 30 })
|
||||
defaultDurationMinutes!: number;
|
||||
@Column({ type: 'int', nullable: true })
|
||||
defaultDurationMinutes!: number | null;
|
||||
|
||||
@Column({ default: true })
|
||||
isActive!: boolean;
|
||||
|
||||
@@ -134,7 +134,6 @@ export class BusinessServiceRequestsService {
|
||||
title: request.title,
|
||||
categoryId: business.categoryId,
|
||||
description: request.description ?? undefined,
|
||||
defaultDurationMinutes: request.durationMinutes ?? undefined,
|
||||
isActive: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export class CreateBusinessServiceDto {
|
||||
@Min(0)
|
||||
price!: number;
|
||||
|
||||
/** اگر خالی باشد از template.defaultDurationMinutes استفاده میشود */
|
||||
/** مدت خدمت به دقیقه — توسط کسبوکار تعیین میشود */
|
||||
@ApiPropertyOptional({ example: 30, nullable: true })
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import {
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUUID,
|
||||
Matches,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
|
||||
export class CreateServiceTemplateDto {
|
||||
@@ -36,13 +33,6 @@ export class CreateServiceTemplateDto {
|
||||
@MaxLength(500)
|
||||
description?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 30 })
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(1440)
|
||||
defaultDurationMinutes?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: true })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import {
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUUID,
|
||||
Matches,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
|
||||
export class UpdateServiceTemplateDto {
|
||||
@@ -38,13 +35,6 @@ export class UpdateServiceTemplateDto {
|
||||
@MaxLength(500)
|
||||
description?: string | null;
|
||||
|
||||
@ApiPropertyOptional({ example: 30 })
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(1440)
|
||||
defaultDurationMinutes?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: true })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
|
||||
@@ -81,7 +81,7 @@ export class ServiceTemplatesService {
|
||||
slug,
|
||||
categoryId: p.categoryId,
|
||||
description: p.description ?? null,
|
||||
defaultDurationMinutes: p.defaultDurationMinutes ?? 30,
|
||||
defaultDurationMinutes: null,
|
||||
isActive: p.isActive ?? true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user