Merge pull request 'fix/data' (#37) from fix/data into development
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
Reviewed-on: #37pull/38/head devel_10.6.24
commit
00d5eba7ab
|
@ -69,6 +69,7 @@ import { NewsModel } from './modules/web-information/news/data/models/news.model
|
||||||
import { BannerModule } from './modules/web-information/banner/banner.module';
|
import { BannerModule } from './modules/web-information/banner/banner.module';
|
||||||
import { BannerModel } from './modules/web-information/banner/data/models/banner.model';
|
import { BannerModel } from './modules/web-information/banner/data/models/banner.model';
|
||||||
import { MailModule } from './modules/configuration/mail/mail.module';
|
import { MailModule } from './modules/configuration/mail/mail.module';
|
||||||
|
import { PosLogModel } from './modules/configuration/log/data/models/pos-log.model';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -96,6 +97,7 @@ import { MailModule } from './modules/configuration/mail/mail.module';
|
||||||
LogModel,
|
LogModel,
|
||||||
NewsModel,
|
NewsModel,
|
||||||
PaymentMethodModel,
|
PaymentMethodModel,
|
||||||
|
PosLogModel,
|
||||||
RefundModel,
|
RefundModel,
|
||||||
RefundItemModel,
|
RefundItemModel,
|
||||||
SalesPriceFormulaModel,
|
SalesPriceFormulaModel,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { validateRelations } from 'src/core/strings/constants/interface.constants';
|
import { validateRelations } from 'src/core/strings/constants/interface.constants';
|
||||||
import { BaseManager } from '../base.manager';
|
import { BaseManager } from '../base.manager';
|
||||||
|
import { OPERATION } from 'src/core/strings/constants/base.constants';
|
||||||
|
|
||||||
export abstract class BaseCustomManager<Entity> extends BaseManager {
|
export abstract class BaseCustomManager<Entity> extends BaseManager {
|
||||||
protected result: any;
|
protected result: any;
|
||||||
|
@ -23,4 +24,31 @@ export abstract class BaseCustomManager<Entity> extends BaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract getResult(): any;
|
abstract getResult(): any;
|
||||||
|
|
||||||
|
async publishEvents() {
|
||||||
|
if (!this.eventTopics.length) return;
|
||||||
|
for (const topic of this.eventTopics) {
|
||||||
|
let data;
|
||||||
|
if (!topic.data) {
|
||||||
|
data = await this.dataService.getOneByOptions({
|
||||||
|
where: {
|
||||||
|
id: this.result['id'],
|
||||||
|
},
|
||||||
|
relations: topic.relations,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.eventBus.publishAll([
|
||||||
|
new topic.topic({
|
||||||
|
id: data?.['id'] ?? topic?.data?.['id'],
|
||||||
|
old: null,
|
||||||
|
data: data ?? topic.data,
|
||||||
|
user: this.user,
|
||||||
|
description: '',
|
||||||
|
module: this.tableName,
|
||||||
|
op: OPERATION.UPDATE,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ export enum TABLE_NAME {
|
||||||
ITEM_RATE = 'item_rates',
|
ITEM_RATE = 'item_rates',
|
||||||
GATE = 'gates',
|
GATE = 'gates',
|
||||||
LOG = 'logs',
|
LOG = 'logs',
|
||||||
|
LOG_POS = 'logs_pos',
|
||||||
NEWS = 'news',
|
NEWS = 'news',
|
||||||
PAYMENT_METHOD = 'payment_methods',
|
PAYMENT_METHOD = 'payment_methods',
|
||||||
PRICE_FORMULA = 'price_formulas',
|
PRICE_FORMULA = 'price_formulas',
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class PosLog1721736523991 implements MigrationInterface {
|
||||||
|
name = 'PosLog1721736523991';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE "logs_pos" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying NOT NULL DEFAULT 'cash withdrawal', "pos_number" bigint, "total_balance" numeric, "created_at" bigint, "creator_name" character varying, "creator_id" character varying, CONSTRAINT "PK_60df825558a6b6881d7ad770d26" PRIMARY KEY ("id"))`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP TABLE "logs_pos"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1,6 @@
|
||||||
export const DatabaseListen = ['transaction', 'vip_code'];
|
export const DatabaseListen = [
|
||||||
|
'transaction',
|
||||||
|
'vip_code',
|
||||||
|
'pos_activity',
|
||||||
|
'pos_cash_activity',
|
||||||
|
];
|
||||||
|
|
|
@ -17,10 +17,13 @@ import {
|
||||||
} from './domain/managers/season-period.handler';
|
} from './domain/managers/season-period.handler';
|
||||||
import {
|
import {
|
||||||
ItemDeletedHandler,
|
ItemDeletedHandler,
|
||||||
|
ItemPriceUpdatedHandler,
|
||||||
|
ItemRateUpdatedHandler,
|
||||||
ItemUpdatedHandler,
|
ItemUpdatedHandler,
|
||||||
} from './domain/managers/item.handler';
|
} from './domain/managers/item.handler';
|
||||||
import {
|
import {
|
||||||
UserDeletedHandler,
|
UserDeletedHandler,
|
||||||
|
UserPrivilegeUpdateHandler,
|
||||||
UserUpdatedHandler,
|
UserUpdatedHandler,
|
||||||
} from './domain/managers/user.handler';
|
} from './domain/managers/user.handler';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
@ -67,8 +70,11 @@ import { VipCodeCreatedHandler } from './domain/managers/vip-code.handler';
|
||||||
SeasonPeriodUpdatedHandler,
|
SeasonPeriodUpdatedHandler,
|
||||||
ItemUpdatedHandler,
|
ItemUpdatedHandler,
|
||||||
ItemDeletedHandler,
|
ItemDeletedHandler,
|
||||||
|
ItemRateUpdatedHandler,
|
||||||
|
ItemPriceUpdatedHandler,
|
||||||
UserDeletedHandler,
|
UserDeletedHandler,
|
||||||
UserUpdatedHandler,
|
UserUpdatedHandler,
|
||||||
|
UserPrivilegeUpdateHandler,
|
||||||
|
|
||||||
TransactionDataService,
|
TransactionDataService,
|
||||||
UserDataService,
|
UserDataService,
|
||||||
|
|
|
@ -62,7 +62,6 @@ export class CouchService {
|
||||||
const nano = this.nanoInstance;
|
const nano = this.nanoInstance;
|
||||||
const db = nano.use(database);
|
const db = nano.use(database);
|
||||||
const result = await db.get(data.id);
|
const result = await db.get(data.id);
|
||||||
console.log(result, 'dsa');
|
|
||||||
await db.insert({
|
await db.insert({
|
||||||
...data,
|
...data,
|
||||||
_rev: result._rev,
|
_rev: result._rev,
|
||||||
|
|
|
@ -5,6 +5,9 @@ import { ItemDeletedEvent } from 'src/modules/item-related/item/domain/entities/
|
||||||
import { ItemUpdatedEvent } from 'src/modules/item-related/item/domain/entities/event/item-updated.event';
|
import { ItemUpdatedEvent } from 'src/modules/item-related/item/domain/entities/event/item-updated.event';
|
||||||
import { ItemChangeStatusEvent } from 'src/modules/item-related/item/domain/entities/event/item-change-status.event';
|
import { ItemChangeStatusEvent } from 'src/modules/item-related/item/domain/entities/event/item-change-status.event';
|
||||||
import { ItemDataService } from 'src/modules/item-related/item/data/services/item-data.service';
|
import { ItemDataService } from 'src/modules/item-related/item/data/services/item-data.service';
|
||||||
|
import { SeasonPeriodUpdatedEvent } from 'src/modules/season-related/season-period/domain/entities/event/season-period-updated.event';
|
||||||
|
import { SeasonPeriodChangeStatusEvent } from 'src/modules/season-related/season-period/domain/entities/event/season-period-change-status.event';
|
||||||
|
import { ItemRateUpdatedEvent } from 'src/modules/item-related/item-rate/domain/entities/event/item-rate-updated.event';
|
||||||
|
|
||||||
@EventsHandler(ItemDeletedEvent)
|
@EventsHandler(ItemDeletedEvent)
|
||||||
export class ItemDeletedHandler implements IEventHandler<ItemDeletedEvent> {
|
export class ItemDeletedHandler implements IEventHandler<ItemDeletedEvent> {
|
||||||
|
@ -79,3 +82,85 @@ export class ItemUpdatedHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventsHandler(SeasonPeriodChangeStatusEvent, SeasonPeriodUpdatedEvent)
|
||||||
|
export class ItemPriceUpdatedHandler
|
||||||
|
implements IEventHandler<SeasonPeriodChangeStatusEvent>
|
||||||
|
{
|
||||||
|
constructor(
|
||||||
|
private couchService: CouchService,
|
||||||
|
private itemService: ItemDataService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async handle(event: SeasonPeriodChangeStatusEvent) {
|
||||||
|
const data = event.data.data;
|
||||||
|
|
||||||
|
// change status to active
|
||||||
|
if (data.status == STATUS.ACTIVE) {
|
||||||
|
const dataItems = await this.itemService.getManyByOptions({
|
||||||
|
where: {
|
||||||
|
status: STATUS.ACTIVE,
|
||||||
|
},
|
||||||
|
relations: [
|
||||||
|
'item_category',
|
||||||
|
'bundling_items',
|
||||||
|
'bundling_items.item_category',
|
||||||
|
'item_rates',
|
||||||
|
'item_rates.item',
|
||||||
|
'item_rates.season_period',
|
||||||
|
'item_rates.season_period.season_type',
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const dataItem of dataItems) {
|
||||||
|
await this.couchService.updateDoc(
|
||||||
|
{
|
||||||
|
_id: dataItem.id,
|
||||||
|
...dataItem,
|
||||||
|
},
|
||||||
|
'item',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventsHandler(ItemRateUpdatedEvent)
|
||||||
|
export class ItemRateUpdatedHandler
|
||||||
|
implements IEventHandler<ItemRateUpdatedEvent>
|
||||||
|
{
|
||||||
|
constructor(
|
||||||
|
private couchService: CouchService,
|
||||||
|
private itemService: ItemDataService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async handle(event: ItemRateUpdatedEvent) {
|
||||||
|
const data = event.data.data;
|
||||||
|
|
||||||
|
const dataItems = await this.itemService.getManyByOptions({
|
||||||
|
where: {
|
||||||
|
status: STATUS.ACTIVE,
|
||||||
|
id: data.item?.id,
|
||||||
|
},
|
||||||
|
relations: [
|
||||||
|
'item_category',
|
||||||
|
'bundling_items',
|
||||||
|
'bundling_items.item_category',
|
||||||
|
'item_rates',
|
||||||
|
'item_rates.item',
|
||||||
|
'item_rates.season_period',
|
||||||
|
'item_rates.season_period.season_type',
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const dataItem of dataItems) {
|
||||||
|
await this.couchService.updateDoc(
|
||||||
|
{
|
||||||
|
_id: dataItem.id,
|
||||||
|
...dataItem,
|
||||||
|
},
|
||||||
|
'item',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { UserDeletedEvent } from 'src/modules/user-related/user/domain/entities/
|
||||||
import { UserChangeStatusEvent } from 'src/modules/user-related/user/domain/entities/event/user-change-status.event';
|
import { UserChangeStatusEvent } from 'src/modules/user-related/user/domain/entities/event/user-change-status.event';
|
||||||
import { UserUpdatedEvent } from 'src/modules/user-related/user/domain/entities/event/user-updated.event';
|
import { UserUpdatedEvent } from 'src/modules/user-related/user/domain/entities/event/user-updated.event';
|
||||||
import { UserDataService } from 'src/modules/user-related/user/data/services/user-data.service';
|
import { UserDataService } from 'src/modules/user-related/user/data/services/user-data.service';
|
||||||
|
import { UserPrivilegeConfigUpdatedEvent } from 'src/modules/user-related/user-privilege/domain/entities/event/user-privilege-configuration-updated.event';
|
||||||
|
|
||||||
@EventsHandler(UserDeletedEvent)
|
@EventsHandler(UserDeletedEvent)
|
||||||
export class UserDeletedHandler implements IEventHandler<UserDeletedEvent> {
|
export class UserDeletedHandler implements IEventHandler<UserDeletedEvent> {
|
||||||
|
@ -86,3 +87,53 @@ export class UserUpdatedHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventsHandler(UserPrivilegeConfigUpdatedEvent)
|
||||||
|
export class UserPrivilegeUpdateHandler
|
||||||
|
implements IEventHandler<UserPrivilegeConfigUpdatedEvent>
|
||||||
|
{
|
||||||
|
constructor(
|
||||||
|
private couchService: CouchService,
|
||||||
|
private userService: UserDataService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async handle(event: UserPrivilegeConfigUpdatedEvent) {
|
||||||
|
const data = event.data.data;
|
||||||
|
|
||||||
|
const users = await this.userService
|
||||||
|
.getManyByOptions({
|
||||||
|
where: {
|
||||||
|
user_privilege_id: data.user_privilege_id,
|
||||||
|
status: STATUS.ACTIVE,
|
||||||
|
},
|
||||||
|
relations: [
|
||||||
|
'user_privilege',
|
||||||
|
'user_privilege.user_privilege_configurations',
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.then((items) => {
|
||||||
|
return items?.map((item) => {
|
||||||
|
console.log(item, 'dsa');
|
||||||
|
const user_privilege_configurations = item[
|
||||||
|
'user_privilege'
|
||||||
|
]?.user_privilege_configurations?.filter(
|
||||||
|
(config) => config.module == 'POS',
|
||||||
|
);
|
||||||
|
Object.assign(item['user_privilege'], {
|
||||||
|
user_privilege_configurations: user_privilege_configurations,
|
||||||
|
});
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const user of users) {
|
||||||
|
await this.couchService.updateDoc(
|
||||||
|
{
|
||||||
|
_id: user.id,
|
||||||
|
...user,
|
||||||
|
},
|
||||||
|
'user',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
|
import { Column, Entity } from 'typeorm';
|
||||||
|
import { PosLogEntity, PosLogType } from '../../domain/entities/pos-log.entity';
|
||||||
|
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
|
||||||
|
|
||||||
|
@Entity(TABLE_NAME.LOG_POS)
|
||||||
|
export class PosLogModel
|
||||||
|
extends BaseCoreModel<PosLogEntity>
|
||||||
|
implements PosLogEntity
|
||||||
|
{
|
||||||
|
@Column('varchar', { name: 'type', default: PosLogType.cash_witdrawal })
|
||||||
|
type: PosLogType;
|
||||||
|
|
||||||
|
@Column('bigint', { name: 'pos_number', nullable: true })
|
||||||
|
pos_number: number;
|
||||||
|
|
||||||
|
@Column('decimal', { name: 'total_balance', nullable: true })
|
||||||
|
total_balance: number;
|
||||||
|
|
||||||
|
@Column('bigint', { name: 'created_at', nullable: true })
|
||||||
|
created_at: number;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'creator_name', nullable: true })
|
||||||
|
creator_name: string;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'creator_id', nullable: true })
|
||||||
|
creator_id: string;
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||||
|
import { PosLogEntity } from '../../domain/entities/pos-log.entity';
|
||||||
|
import { PosLogModel } from '../models/pos-log.model';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class PosLogService extends BaseDataService<PosLogEntity> {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(PosLogModel, CONNECTION_NAME.DEFAULT)
|
||||||
|
private repo: Repository<PosLogModel>,
|
||||||
|
) {
|
||||||
|
super(repo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entity';
|
||||||
|
|
||||||
|
export interface PosLogEntity extends BaseCoreEntity {
|
||||||
|
type: PosLogType;
|
||||||
|
pos_number: number;
|
||||||
|
total_balance: number;
|
||||||
|
created_at: number;
|
||||||
|
creator_name: string;
|
||||||
|
creator_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum PosLogType {
|
||||||
|
cash_witdrawal = 'cash withdrawal',
|
||||||
|
opening_cash = 'opening_cash',
|
||||||
|
login = 'login',
|
||||||
|
logout = 'logout',
|
||||||
|
}
|
|
@ -1,9 +1,33 @@
|
||||||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
||||||
import { RecordLog } from '../entities/log.event';
|
import { RecordLog } from '../entities/log.event';
|
||||||
|
import { LogService } from '../../data/services/log.service';
|
||||||
|
import { LogModel } from '../../data/models/log.model';
|
||||||
|
|
||||||
@EventsHandler(RecordLog)
|
@EventsHandler(RecordLog)
|
||||||
export class RecordLogHandler implements IEventHandler<RecordLog> {
|
export class RecordLogHandler implements IEventHandler<RecordLog> {
|
||||||
|
constructor(private dataService: LogService) {}
|
||||||
|
|
||||||
async handle(event: RecordLog) {
|
async handle(event: RecordLog) {
|
||||||
// TODO: Implement logic here
|
const data = event.data;
|
||||||
|
|
||||||
|
const queryRunner = this.dataService
|
||||||
|
.getRepository()
|
||||||
|
.manager.connection.createQueryRunner();
|
||||||
|
|
||||||
|
const log = new LogModel();
|
||||||
|
|
||||||
|
Object.assign(log, {
|
||||||
|
data_id: data.id,
|
||||||
|
module: data.module,
|
||||||
|
description: data.description,
|
||||||
|
process: data.op,
|
||||||
|
old_data: data.old,
|
||||||
|
data: data.data,
|
||||||
|
created_at: new Date().getTime(),
|
||||||
|
creator_name: data.user.name,
|
||||||
|
creator_id: data.user.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.dataService.create(queryRunner, LogModel, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
||||||
|
import { ChangeDocEvent } from 'src/modules/configuration/couch/domain/events/change-doc.event';
|
||||||
|
import { PosLogService } from '../../data/services/pos-log.service';
|
||||||
|
import { PosLogModel } from '../../data/models/pos-log.model';
|
||||||
|
import { PosLogType } from '../entities/pos-log.entity';
|
||||||
|
|
||||||
|
@EventsHandler(ChangeDocEvent)
|
||||||
|
export class RecordPosLogHandler implements IEventHandler<ChangeDocEvent> {
|
||||||
|
constructor(private dataService: PosLogService) {}
|
||||||
|
|
||||||
|
async handle(event: ChangeDocEvent) {
|
||||||
|
try {
|
||||||
|
const database = event.data.database;
|
||||||
|
const data = event.data.data;
|
||||||
|
|
||||||
|
if (!['pos_cash_activity', 'pos_activity'].includes(database)) return;
|
||||||
|
|
||||||
|
const queryRunner = this.dataService
|
||||||
|
.getRepository()
|
||||||
|
.manager.connection.createQueryRunner();
|
||||||
|
|
||||||
|
const activity = new PosLogModel();
|
||||||
|
|
||||||
|
Object.assign(activity, {
|
||||||
|
id: data._id,
|
||||||
|
type: PosLogType[data.type],
|
||||||
|
total_balance: data.withdrawal_cash ?? data.opening_cash_balance,
|
||||||
|
pos_number: data.pos_number,
|
||||||
|
creator_id: data.pos_admin?.id,
|
||||||
|
creator_name: data.pos_admin?.name,
|
||||||
|
created_at: data.created_at,
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.dataService.create(queryRunner, PosLogModel, activity);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('error handling pos activity couch');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,12 +9,15 @@ import { RecordErrorLogHandler } from './domain/handlers/error-log.handler';
|
||||||
import { RecordLogHandler } from './domain/handlers/log.handler';
|
import { RecordLogHandler } from './domain/handlers/log.handler';
|
||||||
import { ErrorLogService } from './data/services/error-log.service';
|
import { ErrorLogService } from './data/services/error-log.service';
|
||||||
import { LogService } from './data/services/log.service';
|
import { LogService } from './data/services/log.service';
|
||||||
|
import { PosLogModel } from './data/models/pos-log.model';
|
||||||
|
import { PosLogService } from './data/services/pos-log.service';
|
||||||
|
import { RecordPosLogHandler } from './domain/handlers/pos-log.handler';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
TypeOrmModule.forFeature(
|
TypeOrmModule.forFeature(
|
||||||
[LogModel, ErrorLogModel],
|
[LogModel, ErrorLogModel, PosLogModel],
|
||||||
CONNECTION_NAME.DEFAULT,
|
CONNECTION_NAME.DEFAULT,
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
|
@ -22,9 +25,11 @@ import { LogService } from './data/services/log.service';
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [
|
providers: [
|
||||||
RecordLogHandler,
|
RecordLogHandler,
|
||||||
|
RecordPosLogHandler,
|
||||||
RecordErrorLogHandler,
|
RecordErrorLogHandler,
|
||||||
|
|
||||||
LogService,
|
LogService,
|
||||||
|
PosLogService,
|
||||||
ErrorLogService,
|
ErrorLogService,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||||
|
|
||||||
|
export class UserPrivilegeConfigUpdatedEvent {
|
||||||
|
constructor(public readonly data: IEvent) {}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import {
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
import { BaseCustomManager } from 'src/core/modules/domain/usecase/managers/base-custom.manager';
|
import { BaseCustomManager } from 'src/core/modules/domain/usecase/managers/base-custom.manager';
|
||||||
import { UserPrivilegeConfigurationModel } from 'src/modules/user-related/user-privilege/data/models/user-privilege-configuration.model';
|
import { UserPrivilegeConfigurationModel } from 'src/modules/user-related/user-privilege/data/models/user-privilege-configuration.model';
|
||||||
|
import { UserPrivilegeConfigUpdatedEvent } from '../../../entities/event/user-privilege-configuration-updated.event';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UpdateUserPrivilegeConfigurationManager extends BaseCustomManager<UserPrivilegeConfigurationEntity> {
|
export class UpdateUserPrivilegeConfigurationManager extends BaseCustomManager<UserPrivilegeConfigurationEntity> {
|
||||||
|
@ -24,6 +25,8 @@ export class UpdateUserPrivilegeConfigurationManager extends BaseCustomManager<U
|
||||||
{ id: this.data.id },
|
{ id: this.data.id },
|
||||||
this.data,
|
this.data,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.publishEvents();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +47,11 @@ export class UpdateUserPrivilegeConfigurationManager extends BaseCustomManager<U
|
||||||
}
|
}
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
get eventTopics(): EventTopics[] {
|
||||||
return [];
|
return [
|
||||||
|
{
|
||||||
|
topic: UserPrivilegeConfigUpdatedEvent,
|
||||||
|
data: this.data,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue