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 })
|
@Column({ type: 'varchar', nullable: true, length: 400 })
|
||||||
description!: string | null;
|
description!: string | null;
|
||||||
|
|
||||||
@Column({ type: 'int', default: 30 })
|
@Column({ type: 'int', nullable: true })
|
||||||
defaultDurationMinutes!: number;
|
defaultDurationMinutes!: number | null;
|
||||||
|
|
||||||
@Column({ default: true })
|
@Column({ default: true })
|
||||||
isActive!: boolean;
|
isActive!: boolean;
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ export class BusinessServiceRequestsService {
|
|||||||
title: request.title,
|
title: request.title,
|
||||||
categoryId: business.categoryId,
|
categoryId: business.categoryId,
|
||||||
description: request.description ?? undefined,
|
description: request.description ?? undefined,
|
||||||
defaultDurationMinutes: request.durationMinutes ?? undefined,
|
|
||||||
isActive: true,
|
isActive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export class CreateBusinessServiceDto {
|
|||||||
@Min(0)
|
@Min(0)
|
||||||
price!: number;
|
price!: number;
|
||||||
|
|
||||||
/** اگر خالی باشد از template.defaultDurationMinutes استفاده میشود */
|
/** مدت خدمت به دقیقه — توسط کسبوکار تعیین میشود */
|
||||||
@ApiPropertyOptional({ example: 30, nullable: true })
|
@ApiPropertyOptional({ example: 30, nullable: true })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsInt()
|
@IsInt()
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsInt,
|
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
IsUUID,
|
IsUUID,
|
||||||
Matches,
|
Matches,
|
||||||
Max,
|
|
||||||
MaxLength,
|
MaxLength,
|
||||||
Min,
|
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
|
||||||
export class CreateServiceTemplateDto {
|
export class CreateServiceTemplateDto {
|
||||||
@@ -36,13 +33,6 @@ export class CreateServiceTemplateDto {
|
|||||||
@MaxLength(500)
|
@MaxLength(500)
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
||||||
@ApiPropertyOptional({ example: 30 })
|
|
||||||
@IsOptional()
|
|
||||||
@IsInt()
|
|
||||||
@Min(1)
|
|
||||||
@Max(1440)
|
|
||||||
defaultDurationMinutes?: number;
|
|
||||||
|
|
||||||
@ApiPropertyOptional({ example: true })
|
@ApiPropertyOptional({ example: true })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsInt,
|
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
IsUUID,
|
IsUUID,
|
||||||
Matches,
|
Matches,
|
||||||
Max,
|
|
||||||
MaxLength,
|
MaxLength,
|
||||||
Min,
|
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
|
||||||
export class UpdateServiceTemplateDto {
|
export class UpdateServiceTemplateDto {
|
||||||
@@ -38,13 +35,6 @@ export class UpdateServiceTemplateDto {
|
|||||||
@MaxLength(500)
|
@MaxLength(500)
|
||||||
description?: string | null;
|
description?: string | null;
|
||||||
|
|
||||||
@ApiPropertyOptional({ example: 30 })
|
|
||||||
@IsOptional()
|
|
||||||
@IsInt()
|
|
||||||
@Min(1)
|
|
||||||
@Max(1440)
|
|
||||||
defaultDurationMinutes?: number;
|
|
||||||
|
|
||||||
@ApiPropertyOptional({ example: true })
|
@ApiPropertyOptional({ example: true })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export class ServiceTemplatesService {
|
|||||||
slug,
|
slug,
|
||||||
categoryId: p.categoryId,
|
categoryId: p.categoryId,
|
||||||
description: p.description ?? null,
|
description: p.description ?? null,
|
||||||
defaultDurationMinutes: p.defaultDurationMinutes ?? 30,
|
defaultDurationMinutes: null,
|
||||||
isActive: p.isActive ?? true,
|
isActive: p.isActive ?? true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user