WIP adresses inserting troubleshooting
This commit is contained in:
parent
30c70b9f17
commit
c301d1ceba
|
@ -11,6 +11,7 @@ import { Ad } from '../../domain/entities/ad';
|
||||||
import { CreateAdRequest } from '../../domain/dtos/create-ad.request';
|
import { CreateAdRequest } from '../../domain/dtos/create-ad.request';
|
||||||
import { CreateAdCommand } from '../../commands/create-ad.command';
|
import { CreateAdCommand } from '../../commands/create-ad.command';
|
||||||
import { DatabaseException } from '../../../database/exceptions/database.exception';
|
import { DatabaseException } from '../../../database/exceptions/database.exception';
|
||||||
|
import { AddressDTO } from '../../domain/dtos/create.address.dto';
|
||||||
|
|
||||||
@UsePipes(
|
@UsePipes(
|
||||||
new RpcValidationPipe({
|
new RpcValidationPipe({
|
||||||
|
|
|
@ -101,6 +101,6 @@ export class CreateAdRequest {
|
||||||
@Type(() => AddressDTO)
|
@Type(() => AddressDTO)
|
||||||
@HasProperPositionIndexes()
|
@HasProperPositionIndexes()
|
||||||
@ValidateNested({ each: true })
|
@ValidateNested({ each: true })
|
||||||
@AutoMap(() => [AddressDTO])
|
@AutoMap()
|
||||||
addresses: AddressDTO[];
|
addresses: AddressDTO[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { CreateAdRequest } from '../dtos/create-ad.request';
|
||||||
import { Ad } from '../entities/ad';
|
import { Ad } from '../entities/ad';
|
||||||
import { IProvideParams } from '../interfaces/param-provider.interface';
|
import { IProvideParams } from '../interfaces/param-provider.interface';
|
||||||
import { DefaultParams } from '../types/default-params.type';
|
import { DefaultParams } from '../types/default-params.type';
|
||||||
|
import { Address } from '../entities/address';
|
||||||
|
|
||||||
@CommandHandler(CreateAdCommand)
|
@CommandHandler(CreateAdCommand)
|
||||||
export class CreateAdUseCase {
|
export class CreateAdUseCase {
|
||||||
|
@ -25,6 +26,7 @@ export class CreateAdUseCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(command: CreateAdCommand): Promise<Ad> {
|
async execute(command: CreateAdCommand): Promise<Ad> {
|
||||||
|
console.log('before mapping ');
|
||||||
const entity: Ad = this._mapper.map(
|
const entity: Ad = this._mapper.map(
|
||||||
command.createAdRequest,
|
command.createAdRequest,
|
||||||
CreateAdRequest,
|
CreateAdRequest,
|
||||||
|
@ -54,6 +56,12 @@ export class CreateAdUseCase {
|
||||||
typeof entity.strict === 'boolean'
|
typeof entity.strict === 'boolean'
|
||||||
? entity.strict
|
? entity.strict
|
||||||
: (entity.strict = this.defaultParams.STRICT);
|
: (entity.strict = this.defaultParams.STRICT);
|
||||||
|
|
||||||
|
if (typeof entity.addresses[0].position === 'undefined') {
|
||||||
|
for (let i = 0; i < entity.addresses.length; i++) {
|
||||||
|
entity.addresses[i].position = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
console.log('before ***********************************');
|
console.log('before ***********************************');
|
||||||
console.log(entity);
|
console.log(entity);
|
||||||
|
|
|
@ -15,6 +15,7 @@ export class AdProfile extends AutomapperProfile {
|
||||||
|
|
||||||
override get profile() {
|
override get profile() {
|
||||||
return (mapper) => {
|
return (mapper) => {
|
||||||
|
createMap(mapper, Address, AddressDTO);
|
||||||
createMap(mapper, Ad, AdPresenter);
|
createMap(mapper, Ad, AdPresenter);
|
||||||
createMap(
|
createMap(
|
||||||
mapper,
|
mapper,
|
||||||
|
@ -76,6 +77,10 @@ export class AdProfile extends AutomapperProfile {
|
||||||
(destination) => destination.sunTime,
|
(destination) => destination.sunTime,
|
||||||
mapFrom((source) => source.schedule.sun),
|
mapFrom((source) => source.schedule.sun),
|
||||||
),
|
),
|
||||||
|
forMember(
|
||||||
|
(destination) => destination.addresses,
|
||||||
|
mapFrom((source) => source.addresses),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue