forked from Yara724/api
Fix addClient bug
This commit is contained in:
@@ -99,19 +99,34 @@ export class ClientService {
|
||||
try {
|
||||
const newClient = await this.clientDbService.create({
|
||||
clientCode: client.clientCode,
|
||||
|
||||
clientName: {
|
||||
persian: client.clientName.persian,
|
||||
english: client.clientName.english || null,
|
||||
persian:
|
||||
typeof client.clientName === "string"
|
||||
? client.clientName
|
||||
: client.clientName?.persian,
|
||||
|
||||
english:
|
||||
typeof client.clientName === "string"
|
||||
? null
|
||||
: (client.clientName?.english ?? null),
|
||||
},
|
||||
|
||||
property: {
|
||||
smsApiKey: client.property.smsApiKey || null,
|
||||
smsApiKey: client.property?.smsApiKey ?? null,
|
||||
},
|
||||
useExpertMode: client.useExpertMode || null,
|
||||
|
||||
useExpertMode: client.useExpertMode ?? null,
|
||||
});
|
||||
if (newClient) return new ClientDtoRs(newClient);
|
||||
else throw new GoneException("database not connected");
|
||||
|
||||
if (!newClient) {
|
||||
throw new GoneException("database not connected");
|
||||
}
|
||||
|
||||
return new ClientDtoRs(newClient);
|
||||
} catch (er) {
|
||||
throw new BadGatewayException(er.errors);
|
||||
console.error("ADD CLIENT ERROR:", er);
|
||||
throw er;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { IsIn, IsNotEmpty, IsNumber, IsOptional, IsString, ValidateNested } from "class-validator";
|
||||
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";
|
||||
|
||||
@@ -15,9 +22,8 @@ class ClientName {
|
||||
english: string;
|
||||
}
|
||||
class Property {
|
||||
@ApiProperty({})
|
||||
@ApiPropertyOptional({})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
smsApiKey: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user