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