feat: integration save scheduling data log to database
parent
cfb863b7d0
commit
4120e7fc1a
|
@ -110,6 +110,7 @@ import { OtpCheckerGuard } from './core/guards/domain/otp-checker.guard';
|
||||||
import { DataSchedulingModel } from './modules/configuration/data-scheduling/data/models/data-scheduling.model';
|
import { DataSchedulingModel } from './modules/configuration/data-scheduling/data/models/data-scheduling.model';
|
||||||
import { DataSchedulingModule } from './modules/configuration/data-scheduling/data-scheduling.module';
|
import { DataSchedulingModule } from './modules/configuration/data-scheduling/data-scheduling.module';
|
||||||
import { DataSchedulingDefaultModel } from './modules/configuration/data-scheduling/data/models/data-scheduling-default.model';
|
import { DataSchedulingDefaultModel } from './modules/configuration/data-scheduling/data/models/data-scheduling-default.model';
|
||||||
|
import { DataSchedulingLogModel } from './modules/configuration/data-scheduling/data/models/data-scheduling-log.model';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -183,6 +184,7 @@ import { DataSchedulingDefaultModel } from './modules/configuration/data-schedul
|
||||||
// Data Scheduling
|
// Data Scheduling
|
||||||
DataSchedulingModel,
|
DataSchedulingModel,
|
||||||
DataSchedulingDefaultModel,
|
DataSchedulingDefaultModel,
|
||||||
|
DataSchedulingLogModel,
|
||||||
],
|
],
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -38,6 +38,8 @@ import { DataSchedulingUpdatedHandler } from './domain/usecases/handlers/data-sc
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
import { JWT_EXPIRED } from 'src/core/sessions/constants';
|
import { JWT_EXPIRED } from 'src/core/sessions/constants';
|
||||||
import { JWT_SECRET } from 'src/core/sessions/constants';
|
import { JWT_SECRET } from 'src/core/sessions/constants';
|
||||||
|
|
||||||
|
import { DataSchedulingLogService } from './data/services/data-scheduling-log.service';
|
||||||
import { DataSchedulingLogModel } from './data/models/data-scheduling-log.model';
|
import { DataSchedulingLogModel } from './data/models/data-scheduling-log.model';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
@ -74,6 +76,7 @@ import { DataSchedulingLogModel } from './data/models/data-scheduling-log.model'
|
||||||
BatchConfirmDataSchedulingManager,
|
BatchConfirmDataSchedulingManager,
|
||||||
BatchInactiveDataSchedulingManager,
|
BatchInactiveDataSchedulingManager,
|
||||||
|
|
||||||
|
DataSchedulingLogService,
|
||||||
DataSchedulingDataService,
|
DataSchedulingDataService,
|
||||||
DataSchedulingReadService,
|
DataSchedulingReadService,
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
|
import { DataSchedulingLogModel } from '../models/data-scheduling-log.model';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class DataSchedulingLogService {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(DataSchedulingLogModel, CONNECTION_NAME.DEFAULT)
|
||||||
|
private repo: Repository<DataSchedulingLogModel>,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async create(entity: any): Promise<any> {
|
||||||
|
return await this.repo.save(entity);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,10 +6,8 @@ import {
|
||||||
SCHEDULING_LOG_ACTION_ENUM,
|
SCHEDULING_LOG_ACTION_ENUM,
|
||||||
SCHEDULING_LOG_TYPE_ENUM,
|
SCHEDULING_LOG_TYPE_ENUM,
|
||||||
} from '../../entities/data-scheduling.entity';
|
} from '../../entities/data-scheduling.entity';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { DataSchedulingLogModel } from '../../../data/models/data-scheduling-log.model';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
import { DataSchedulingLogService } from '../../../data/services/data-scheduling-log.service';
|
||||||
|
|
||||||
@EventsHandler(DataSchedulingChangeStatusEvent)
|
@EventsHandler(DataSchedulingChangeStatusEvent)
|
||||||
export class DataSchedulingChangeStatusHandler
|
export class DataSchedulingChangeStatusHandler
|
||||||
|
@ -17,10 +15,7 @@ export class DataSchedulingChangeStatusHandler
|
||||||
{
|
{
|
||||||
private readonly logger = new Logger(DataSchedulingChangeStatusHandler.name);
|
private readonly logger = new Logger(DataSchedulingChangeStatusHandler.name);
|
||||||
|
|
||||||
constructor(
|
constructor(private service: DataSchedulingLogService) {}
|
||||||
@InjectRepository(DataSchedulingLogModel)
|
|
||||||
private repository: Repository<DataSchedulingLogModel>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async handle(event: DataSchedulingChangeStatusEvent) {
|
async handle(event: DataSchedulingChangeStatusEvent) {
|
||||||
const oldData = event?.data?.old;
|
const oldData = event?.data?.old;
|
||||||
|
@ -54,7 +49,7 @@ export class DataSchedulingChangeStatusHandler
|
||||||
description: description,
|
description: description,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.repository.save(payload as any);
|
await this.service.create(payload as any);
|
||||||
this.logger.verbose(
|
this.logger.verbose(
|
||||||
`[SCHEDULING LOG] Change status data for ID: ${payload.data_id}`,
|
`[SCHEDULING LOG] Change status data for ID: ${payload.data_id}`,
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,10 +6,8 @@ import {
|
||||||
SCHEDULING_LOG_TYPE_ENUM,
|
SCHEDULING_LOG_TYPE_ENUM,
|
||||||
} from '../../entities/data-scheduling.entity';
|
} from '../../entities/data-scheduling.entity';
|
||||||
import { decryptionTotal } from '../../../infrastructure/helpers';
|
import { decryptionTotal } from '../../../infrastructure/helpers';
|
||||||
import { DataSchedulingLogModel } from '../../../data/models/data-scheduling-log.model';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
import { DataSchedulingLogService } from '../../../data/services/data-scheduling-log.service';
|
||||||
|
|
||||||
@EventsHandler(DataSchedulingCreatedEvent)
|
@EventsHandler(DataSchedulingCreatedEvent)
|
||||||
export class DataSchedulingCreatedHandler
|
export class DataSchedulingCreatedHandler
|
||||||
|
@ -17,10 +15,7 @@ export class DataSchedulingCreatedHandler
|
||||||
{
|
{
|
||||||
private readonly logger = new Logger(DataSchedulingCreatedHandler.name);
|
private readonly logger = new Logger(DataSchedulingCreatedHandler.name);
|
||||||
|
|
||||||
constructor(
|
constructor(private service: DataSchedulingLogService) {}
|
||||||
@InjectRepository(DataSchedulingLogModel)
|
|
||||||
private repository: Repository<DataSchedulingLogModel>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async handle(event: DataSchedulingCreatedEvent) {
|
async handle(event: DataSchedulingCreatedEvent) {
|
||||||
const data = event?.data?.data;
|
const data = event?.data?.data;
|
||||||
|
@ -50,7 +45,7 @@ export class DataSchedulingCreatedHandler
|
||||||
description: description,
|
description: description,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.repository.save(payload as any);
|
await this.service.create(payload as any);
|
||||||
this.logger.verbose(
|
this.logger.verbose(
|
||||||
`[SCHEDULING LOG] Create data for ID: ${payload.data_id}`,
|
`[SCHEDULING LOG] Create data for ID: ${payload.data_id}`,
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,10 +5,8 @@ import {
|
||||||
SCHEDULING_LOG_ACTION_ENUM,
|
SCHEDULING_LOG_ACTION_ENUM,
|
||||||
SCHEDULING_LOG_TYPE_ENUM,
|
SCHEDULING_LOG_TYPE_ENUM,
|
||||||
} from '../../entities/data-scheduling.entity';
|
} from '../../entities/data-scheduling.entity';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { DataSchedulingLogModel } from '../../../data/models/data-scheduling-log.model';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
import { DataSchedulingLogService } from '../../../data/services/data-scheduling-log.service';
|
||||||
|
|
||||||
@EventsHandler(DataSchedulingDeletedEvent)
|
@EventsHandler(DataSchedulingDeletedEvent)
|
||||||
export class DataSchedulingDeletedHandler
|
export class DataSchedulingDeletedHandler
|
||||||
|
@ -16,10 +14,7 @@ export class DataSchedulingDeletedHandler
|
||||||
{
|
{
|
||||||
private readonly logger = new Logger(DataSchedulingDeletedHandler.name);
|
private readonly logger = new Logger(DataSchedulingDeletedHandler.name);
|
||||||
|
|
||||||
constructor(
|
constructor(private service: DataSchedulingLogService) {}
|
||||||
@InjectRepository(DataSchedulingLogModel)
|
|
||||||
private repository: Repository<DataSchedulingLogModel>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async handle(event: DataSchedulingDeletedEvent) {
|
async handle(event: DataSchedulingDeletedEvent) {
|
||||||
const deletedData = event?.data?.data;
|
const deletedData = event?.data?.data;
|
||||||
|
@ -56,7 +51,7 @@ export class DataSchedulingDeletedHandler
|
||||||
description: description,
|
description: description,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.repository.save(payload as any);
|
await this.service.create(payload as any);
|
||||||
this.logger.verbose(
|
this.logger.verbose(
|
||||||
`[SCHEDULING LOG] Delete data for ID: ${payload.data_id}`,
|
`[SCHEDULING LOG] Delete data for ID: ${payload.data_id}`,
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,10 +9,8 @@ import {
|
||||||
decryptionTotal,
|
decryptionTotal,
|
||||||
encryptionTotal,
|
encryptionTotal,
|
||||||
} from '../../../infrastructure/helpers';
|
} from '../../../infrastructure/helpers';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { DataSchedulingLogModel } from '../../../data/models/data-scheduling-log.model';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
import { DataSchedulingLogService } from '../../../data/services/data-scheduling-log.service';
|
||||||
|
|
||||||
@EventsHandler(DataSchedulingUpdatedEvent)
|
@EventsHandler(DataSchedulingUpdatedEvent)
|
||||||
export class DataSchedulingUpdatedHandler
|
export class DataSchedulingUpdatedHandler
|
||||||
|
@ -20,10 +18,7 @@ export class DataSchedulingUpdatedHandler
|
||||||
{
|
{
|
||||||
private readonly logger = new Logger(DataSchedulingUpdatedHandler.name);
|
private readonly logger = new Logger(DataSchedulingUpdatedHandler.name);
|
||||||
|
|
||||||
constructor(
|
constructor(private service: DataSchedulingLogService) {}
|
||||||
@InjectRepository(DataSchedulingLogModel)
|
|
||||||
private repository: Repository<DataSchedulingLogModel>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
// Map for readable labels
|
// Map for readable labels
|
||||||
private readonly labelMap: { [key: string]: string } = {
|
private readonly labelMap: { [key: string]: string } = {
|
||||||
|
@ -82,7 +77,7 @@ export class DataSchedulingUpdatedHandler
|
||||||
description: description,
|
description: description,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.repository.save(payload as any);
|
await this.service.create(payload as any);
|
||||||
this.logger.verbose(
|
this.logger.verbose(
|
||||||
`[SCHEDULING LOG] Update data for ID: ${payload.data_id}`,
|
`[SCHEDULING LOG] Update data for ID: ${payload.data_id}`,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue