Files
CRM_Montzar/apps/api/src/platform/dto.ts
T

165 lines
2.7 KiB
TypeScript
Raw Normal View History

2026-09-19 21:54:21 +03:30
import {
IsArray,
2026-09-19 21:54:21 +03:30
IsBoolean,
IsEmail,
IsIn,
IsInt,
IsNumber,
2026-09-19 21:54:21 +03:30
IsOptional,
IsString,
Max,
2026-09-19 21:54:21 +03:30
MaxLength,
Min,
2026-09-19 21:54:21 +03:30
MinLength,
ValidateIf,
} from 'class-validator';
import { USER_ROLES, type UserRole } from '@mento/shared';
export class PlatformLoginDto {
2026-09-19 22:42:51 +03:30
@IsString()
@MinLength(8)
@MaxLength(40)
mobile!: string;
2026-09-19 21:54:21 +03:30
@IsString()
@MinLength(6)
password!: string;
}
2026-09-19 22:42:51 +03:30
export class CreatePlatformAdminDto {
@IsString()
@MinLength(2)
@MaxLength(120)
fullName!: string;
@IsString()
@MinLength(8)
@MaxLength(40)
mobile!: string;
@IsString()
@MinLength(8)
@MaxLength(120)
password!: string;
@IsOptional()
@IsEmail()
email?: string;
}
export class ResetPlatformAdminPasswordDto {
@IsString()
@MinLength(8)
@MaxLength(120)
password!: string;
}
2026-09-19 21:54:21 +03:30
export class UpdatePlatformStatusDto {
@IsBoolean()
isActive!: boolean;
}
export class CreatePlatformOrganizationDto {
@IsString()
@MinLength(2)
@MaxLength(120)
name!: string;
@IsOptional()
@IsString()
@MaxLength(64)
businessField?: string;
@IsString()
@MinLength(2)
@MaxLength(120)
ownerFullName!: string;
@IsEmail()
ownerEmail!: string;
@IsString()
@MinLength(8)
@MaxLength(120)
ownerPassword!: string;
@IsOptional()
@IsString()
@MaxLength(40)
ownerMobile?: string;
}
export class UpdatePlatformOrganizationDto {
@IsOptional()
@IsString()
@MinLength(2)
@MaxLength(120)
name?: string;
@IsOptional()
@IsString()
@MinLength(2)
@MaxLength(64)
slug?: string;
@IsOptional()
@ValidateIf((_, v) => v !== null && v !== undefined)
@IsString()
@MaxLength(64)
businessField?: string | null;
@IsOptional()
@IsBoolean()
isActive?: boolean;
}
export class UpdatePlatformMembershipRoleDto {
@IsIn(USER_ROLES)
role!: UserRole;
}
export class ResetPlatformUserPasswordDto {
@IsString()
@MinLength(8)
@MaxLength(120)
password!: string;
}
export class ApplyBillingPlanDto {
@IsIn(['trial', 'monthly', 'quarterly', 'semiannual', 'yearly', 'lifetime', 'custom'])
planCode!: 'trial' | 'monthly' | 'quarterly' | 'semiannual' | 'yearly' | 'lifetime' | 'custom';
@IsOptional()
@IsInt()
@Min(1)
maxOrganizations?: number;
@IsOptional()
@IsString()
expiresAt?: string;
@IsOptional()
@IsString()
@MaxLength(500)
notes?: string | null;
@IsOptional()
@IsIn(['active', 'expired', 'suspended'])
status?: 'active' | 'expired' | 'suspended';
}
export class SetStorageQuotaDto {
/** گیگابایت؛ null = بدون سقف */
@IsNumber()
@Min(0)
@Max(100_000)
@ValidateIf((_, value) => value !== null)
quotaGb!: number | null;
}
export class UpdateOrgModulesDto {
@IsArray()
@IsString({ each: true })
enabledModules!: string[];
}