forked from Yara724/api
72 lines
1.4 KiB
TypeScript
72 lines
1.4 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
import {
|
|
IsIn,
|
|
IsNotEmpty,
|
|
IsNumber,
|
|
IsOptional,
|
|
IsString,
|
|
ValidateNested,
|
|
} from "class-validator";
|
|
import { Type } from "class-transformer";
|
|
import { Types } from "mongoose";
|
|
|
|
class ClientName {
|
|
@ApiProperty({})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
persian: string;
|
|
|
|
@ApiProperty({})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
english: string;
|
|
}
|
|
class Property {
|
|
@ApiPropertyOptional({})
|
|
@IsOptional()
|
|
@IsString()
|
|
smsApiKey?: string;
|
|
}
|
|
|
|
export class ClientDto {
|
|
@ApiProperty({ required: true })
|
|
@ValidateNested()
|
|
@Type(() => ClientName)
|
|
clientName: ClientName;
|
|
|
|
@ApiProperty({ required: true })
|
|
@IsNumber()
|
|
clientCode: number;
|
|
|
|
@ApiProperty({ required: false })
|
|
@IsOptional()
|
|
@ValidateNested()
|
|
@Type(() => Property)
|
|
property?: Property;
|
|
|
|
@ApiProperty({ examples: ["legal", "genuine"] })
|
|
@IsIn(["legal", "genuine"])
|
|
useExpertMode: "legal" | "genuine";
|
|
}
|
|
export class ClientDtoRs {
|
|
persian: string;
|
|
english: string;
|
|
clientId: Types.ObjectId;
|
|
useExpertsMode: string;
|
|
constructor(readonly client) {
|
|
this.persian = client.clientName.persian;
|
|
this.english = client.clientName.english;
|
|
this.clientId = client._id;
|
|
this.useExpertsMode = client.useExpertMode;
|
|
}
|
|
}
|
|
|
|
export class ClientLists {
|
|
name: string;
|
|
id: Types.ObjectId;
|
|
constructor(client: ClientDto) {
|
|
this.name = client.clientName.persian;
|
|
this.id = client["_id"];
|
|
}
|
|
}
|