mirror of
https://gitlab.com/mobicoop/v3/service/configuration.git
synced 2026-01-09 16:32:40 +00:00
add messager presenter
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { AutoMap } from '@automapper/classes';
|
||||
import { Domain } from '../../domain/dtos/domain.enum';
|
||||
|
||||
export class ConfigurationMessagerPresenter {
|
||||
@AutoMap()
|
||||
domain: Domain;
|
||||
|
||||
@AutoMap()
|
||||
key: string;
|
||||
|
||||
@AutoMap()
|
||||
value: string;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Mapper } from '@automapper/core';
|
||||
import { InjectMapper } from '@automapper/nestjs';
|
||||
import { CommandHandler } from '@nestjs/cqrs';
|
||||
import { ConfigurationMessagerPresenter } from '../../adapters/secondaries/configuration-messager.presenter';
|
||||
import { ConfigurationMessager } from '../../adapters/secondaries/configuration.messager';
|
||||
import { ConfigurationRepository } from '../../adapters/secondaries/configuration.repository';
|
||||
import { LoggingMessager } from '../../adapters/secondaries/logging.messager';
|
||||
@@ -28,7 +29,13 @@ export class CreateConfigurationUseCase {
|
||||
const configuration = await this._repository.create(entity);
|
||||
this._configurationMessager.publish(
|
||||
'create',
|
||||
JSON.stringify(configuration),
|
||||
JSON.stringify(
|
||||
this._mapper.map(
|
||||
configuration,
|
||||
Configuration,
|
||||
ConfigurationMessagerPresenter,
|
||||
),
|
||||
),
|
||||
);
|
||||
this._loggingMessager.publish(
|
||||
'configuration.create.info',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Mapper } from '@automapper/core';
|
||||
import { InjectMapper } from '@automapper/nestjs';
|
||||
import { CommandHandler } from '@nestjs/cqrs';
|
||||
import { ConfigurationMessagerPresenter } from '../../adapters/secondaries/configuration-messager.presenter';
|
||||
import { ConfigurationMessager } from '../../adapters/secondaries/configuration.messager';
|
||||
import { ConfigurationRepository } from '../../adapters/secondaries/configuration.repository';
|
||||
import { LoggingMessager } from '../../adapters/secondaries/logging.messager';
|
||||
@@ -31,7 +32,13 @@ export class UpdateConfigurationUseCase {
|
||||
);
|
||||
this._configurationMessager.publish(
|
||||
'update',
|
||||
JSON.stringify(command.updateConfigurationRequest),
|
||||
JSON.stringify(
|
||||
this._mapper.map(
|
||||
configuration,
|
||||
Configuration,
|
||||
ConfigurationMessagerPresenter,
|
||||
),
|
||||
),
|
||||
);
|
||||
this._loggingMessager.publish(
|
||||
'configuration.update.info',
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createMap, forMember, ignore, Mapper } from '@automapper/core';
|
||||
import { AutomapperProfile, InjectMapper } from '@automapper/nestjs';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigurationPresenter } from '../adapters/primaries/configuration.presenter';
|
||||
import { ConfigurationMessagerPresenter } from '../adapters/secondaries/configuration-messager.presenter';
|
||||
import { CreateConfigurationRequest } from '../domain/dtos/create-configuration.request';
|
||||
import { UpdateConfigurationRequest } from '../domain/dtos/update-configuration.request';
|
||||
import { Configuration } from '../domain/entities/configuration';
|
||||
@@ -24,6 +25,8 @@ export class ConfigurationProfile extends AutomapperProfile {
|
||||
Configuration,
|
||||
forMember((dest) => dest.uuid, ignore()),
|
||||
);
|
||||
|
||||
createMap(mapper, Configuration, ConfigurationMessagerPresenter);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user