2026-09-11 01:09:59 +03:30
|
|
|
import { Type } from 'class-transformer';
|
2026-08-29 21:06:30 +03:30
|
|
|
import {
|
2026-09-15 17:33:05 +03:30
|
|
|
IsBoolean,
|
2026-08-29 21:06:30 +03:30
|
|
|
IsIn,
|
2026-09-11 01:09:59 +03:30
|
|
|
IsNumber,
|
2026-10-06 15:04:46 +03:30
|
|
|
IsObject,
|
2026-09-15 17:33:05 +03:30
|
|
|
IsOptional,
|
2026-08-29 21:06:30 +03:30
|
|
|
IsString,
|
2026-09-14 19:19:09 +03:30
|
|
|
Matches,
|
2026-09-11 01:09:59 +03:30
|
|
|
Max,
|
2026-08-29 21:06:30 +03:30
|
|
|
MaxLength,
|
2026-09-11 01:09:59 +03:30
|
|
|
Min,
|
2026-08-29 21:06:30 +03:30
|
|
|
MinLength,
|
2026-09-15 21:37:58 +03:30
|
|
|
ValidateIf,
|
2026-08-29 21:06:30 +03:30
|
|
|
} from 'class-validator';
|
|
|
|
|
|
|
|
|
|
const INVITE_ROLES = ['admin', 'sales', 'support'] as const;
|
|
|
|
|
const ALL_ROLES = ['owner', 'admin', 'sales', 'support'] as const;
|
|
|
|
|
|
|
|
|
|
export class InviteUserDto {
|
2026-09-14 19:19:09 +03:30
|
|
|
@IsString()
|
|
|
|
|
@Matches(/^09\d{9}$|^\+98\d{10}$|^98\d{10}$|^9\d{9}$/, {
|
|
|
|
|
message: 'شماره موبایل معتبر نیست',
|
|
|
|
|
})
|
|
|
|
|
mobile!: string;
|
2026-08-29 21:06:30 +03:30
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
@MinLength(2)
|
|
|
|
|
@MaxLength(120)
|
|
|
|
|
fullName!: string;
|
|
|
|
|
|
2026-09-15 21:37:58 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@ValidateIf((_, value) => typeof value === 'string' && value.length > 0)
|
2026-08-29 21:06:30 +03:30
|
|
|
@IsString()
|
|
|
|
|
@MinLength(8)
|
|
|
|
|
@MaxLength(72)
|
2026-09-15 21:37:58 +03:30
|
|
|
password?: string;
|
2026-08-29 21:06:30 +03:30
|
|
|
|
2026-09-15 17:33:05 +03:30
|
|
|
@IsOptional()
|
2026-08-29 21:06:30 +03:30
|
|
|
@IsIn(INVITE_ROLES)
|
2026-09-15 17:33:05 +03:30
|
|
|
role?: (typeof INVITE_ROLES)[number];
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
orgRoleId?: string;
|
2026-08-29 21:06:30 +03:30
|
|
|
}
|
|
|
|
|
|
2026-10-04 12:31:07 +03:30
|
|
|
export class UpdateOrgUserDto {
|
|
|
|
|
@IsString()
|
|
|
|
|
@MinLength(2)
|
|
|
|
|
@MaxLength(120)
|
|
|
|
|
fullName!: string;
|
|
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
@Matches(/^09\d{9}$|^\+98\d{10}$|^98\d{10}$|^9\d{9}$/, {
|
|
|
|
|
message: 'شماره موبایل معتبر نیست',
|
|
|
|
|
})
|
|
|
|
|
mobile!: string;
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@ValidateIf((_, value) => typeof value === 'string' && value.length > 0)
|
|
|
|
|
@IsString()
|
|
|
|
|
@MinLength(8)
|
|
|
|
|
@MaxLength(72)
|
|
|
|
|
password?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-29 21:06:30 +03:30
|
|
|
export class UpdateUserRoleDto {
|
2026-09-15 17:33:05 +03:30
|
|
|
@IsOptional()
|
2026-08-29 21:06:30 +03:30
|
|
|
@IsIn(ALL_ROLES)
|
2026-09-15 17:33:05 +03:30
|
|
|
role?: (typeof ALL_ROLES)[number];
|
|
|
|
|
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
orgRoleId?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class UpdateUserStatusDto {
|
|
|
|
|
@Type(() => Boolean)
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
isActive!: boolean;
|
2026-08-29 21:06:30 +03:30
|
|
|
}
|
2026-09-11 01:09:59 +03:30
|
|
|
|
|
|
|
|
export class UpdateUserCommissionDto {
|
|
|
|
|
@Type(() => Number)
|
|
|
|
|
@IsNumber()
|
|
|
|
|
@Min(0)
|
|
|
|
|
@Max(100)
|
|
|
|
|
commissionPercent!: number;
|
|
|
|
|
}
|
2026-09-26 17:15:09 +03:30
|
|
|
|
2026-10-19 13:34:55 +03:30
|
|
|
export class UpdateLogoutTimeDto {
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@ValidateIf((_, value) => value != null && value !== '')
|
|
|
|
|
@IsString()
|
|
|
|
|
@Matches(/^([01]\d|2[0-3]):[0-5]\d$/, { message: 'ساعت خروج معتبر نیست' })
|
|
|
|
|
logoutTime?: string | null;
|
2026-10-21 14:20:15 +03:30
|
|
|
|
|
|
|
|
/** بدون مقدار = بدون تغییر */
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
blockLoginAfterLogout?: boolean;
|
2026-10-19 13:34:55 +03:30
|
|
|
}
|
|
|
|
|
|
2026-09-26 17:15:09 +03:30
|
|
|
export class UpdateUserVisibilityDto {
|
2026-10-06 15:04:46 +03:30
|
|
|
@IsOptional()
|
2026-09-26 17:15:09 +03:30
|
|
|
@IsIn(['own', 'team', 'org'])
|
2026-10-06 15:04:46 +03:30
|
|
|
dataVisibility?: 'own' | 'team' | 'org';
|
|
|
|
|
|
|
|
|
|
/** سطح دید هر بخش؛ null یعنی «مثل پیشفرض». در سرویس اعتبارسنجی میشود. */
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
|
|
|
|
scopes?: Record<string, 'own' | 'team' | 'org' | null>;
|
2026-09-26 17:15:09 +03:30
|
|
|
}
|