feat(SPG-497) Generator Module
parent
1a3ecefa0a
commit
63a849ed7b
|
@ -0,0 +1,246 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = function (plop) {
|
||||
plop.setGenerator('module', {
|
||||
description: 'Create a new module by default',
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'Name: ',
|
||||
validate: function (value) {
|
||||
if (/.+/.test(value)) {
|
||||
return true;
|
||||
}
|
||||
return 'Name is required';
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'list',
|
||||
name: 'base',
|
||||
message: 'Base: ',
|
||||
choices: function () {
|
||||
return ['base', 'base status', 'base core'];
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'list',
|
||||
name: 'location',
|
||||
message: 'Location: ',
|
||||
choices: function () {
|
||||
return ['item related', 'user related', 'season related', 'transaction'];
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
actions: function (data) {
|
||||
if (['base', 'base core'].includes(data.base)) data.orchestrator = 'data'
|
||||
else if (data.base == 'base status') data.orchestrator = 'data transaction'
|
||||
|
||||
const destination = `src/modules/{{dashCase location}}/{{dashCase name}}`;
|
||||
|
||||
const result = [
|
||||
...mappingModule(data.base, destination),
|
||||
...mappingController(data.base, destination),
|
||||
...mappingModel(data.base, destination),
|
||||
...mappingService(destination),
|
||||
...mappingOrchestrator(data.base, destination),
|
||||
...mappingManager(data.base, destination)
|
||||
]
|
||||
|
||||
return result
|
||||
},
|
||||
})
|
||||
};
|
||||
|
||||
function mappingService(destination) {
|
||||
const datas = [];
|
||||
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/data/services`,
|
||||
templateFiles: `src/core/templates/services/*.hbs`,
|
||||
base: 'src/core/templates/services',
|
||||
},
|
||||
)
|
||||
|
||||
return datas;
|
||||
}
|
||||
|
||||
function mappingOrchestrator(base, destination) {
|
||||
const datas = [];
|
||||
|
||||
if (base == 'base status') {
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/domain/usecases`,
|
||||
templateFiles: `src/core/templates/orchestrators/base-status/*.hbs`,
|
||||
base: 'src/core/templates/orchestrators/base-status',
|
||||
},
|
||||
)
|
||||
} else {
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/domain/usecases`,
|
||||
templateFiles: `src/core/templates/orchestrators/base/*.hbs`,
|
||||
base: 'src/core/templates/orchestrators/base',
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/domain/usecases`,
|
||||
templateFiles: `src/core/templates/orchestrators/base-read/*.hbs`,
|
||||
base: 'src/core/templates/orchestrators/base-read',
|
||||
},
|
||||
)
|
||||
|
||||
return datas;
|
||||
}
|
||||
|
||||
function mappingController(base, destination) {
|
||||
const datas = [];
|
||||
|
||||
if (base == 'base status') {
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/infrastructure`,
|
||||
templateFiles: `src/core/templates/controllers/base-status/*.hbs`,
|
||||
base: 'src/core/templates/controllers/base-status',
|
||||
},
|
||||
)
|
||||
} else {
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/infrastructure`,
|
||||
templateFiles: `src/core/templates/controllers/base/*.hbs`,
|
||||
base: 'src/core/templates/controllers/base',
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/infrastructure`,
|
||||
templateFiles: `src/core/templates/controllers/base-read/*.hbs`,
|
||||
base: 'src/core/templates/controllers/base-read',
|
||||
},
|
||||
)
|
||||
|
||||
return datas;
|
||||
}
|
||||
|
||||
function mappingModel(base, destination) {
|
||||
const datas = [];
|
||||
|
||||
if (base == 'base status') {
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/domain/entities/event`,
|
||||
templateFiles: `src/core/templates/events/base-status/*.hbs`,
|
||||
base: 'src/core/templates/events/base-status',
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/data/models`,
|
||||
templateFiles: `src/core/templates/models/*.hbs`,
|
||||
base: 'src/core/templates/models',
|
||||
},
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/domain/entities`,
|
||||
templateFiles: `src/core/templates/entities/*.hbs`,
|
||||
base: 'src/core/templates/entities',
|
||||
},
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/infrastructure/dto`,
|
||||
templateFiles: `src/core/templates/dtos/*.hbs`,
|
||||
base: 'src/core/templates/dtos',
|
||||
},
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: `${destination}/domain/entities/event`,
|
||||
templateFiles: `src/core/templates/events/base/*.hbs`,
|
||||
base: 'src/core/templates/events/base',
|
||||
}
|
||||
)
|
||||
|
||||
return datas;
|
||||
}
|
||||
|
||||
function mappingModule(base, destination) {
|
||||
const datas = [];
|
||||
|
||||
if (base == 'base status') {
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: destination,
|
||||
templateFiles: `src/core/templates/modules/base-status/*.hbs`,
|
||||
base: 'src/core/templates/modules/base-status',
|
||||
}
|
||||
)
|
||||
} else {
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: destination,
|
||||
templateFiles: `src/core/templates/modules/base/*.hbs`,
|
||||
base: 'src/core/templates/modules/base',
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: destination,
|
||||
templateFiles: `src/core/templates/modules/core/*.hbs`,
|
||||
base: 'src/core/templates/modules/core',
|
||||
}
|
||||
)
|
||||
|
||||
return datas;
|
||||
}
|
||||
|
||||
function mappingManager(base, destination) {
|
||||
const datas = [];
|
||||
|
||||
const tujuan = `${destination}/domain/usecases/managers`;
|
||||
if (base == 'base status') {
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: tujuan,
|
||||
templateFiles: `src/core/templates/managers/manager-statuses/*.hbs`,
|
||||
base: 'src/core/templates/managers/manager-statuses',
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
datas.push(
|
||||
{
|
||||
type: 'addMany',
|
||||
destination: tujuan,
|
||||
templateFiles: `src/core/templates/managers/base/*.hbs`,
|
||||
base: 'src/core/templates/managers/base',
|
||||
},
|
||||
)
|
||||
|
||||
return datas;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||
import { Filter{{pascalCase name}}Dto } from './dto/filter-{{dashCase name}}.dto';
|
||||
import { Pagination } from 'src/core/response';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { {{pascalCase name}}Entity } from '../domain/entities/{{dashCase name}}.entity';
|
||||
import { {{pascalCase name}}ReadOrchestrator } from '../domain/usecases/{{dashCase name}}-read.orchestrator';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { Public } from 'src/core/guards';
|
||||
|
||||
@ApiTags(`${MODULE_NAME.{{constantCase name}}.split('-').join(' ')} - read`)
|
||||
@Controller(MODULE_NAME.{{constantCase name}})
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class {{pascalCase name}}ReadController {
|
||||
constructor(private orchestrator: {{pascalCase name}}ReadOrchestrator) {}
|
||||
|
||||
@Get()
|
||||
@Pagination()
|
||||
async index(
|
||||
@Query() params: Filter{{pascalCase name}}Dto,
|
||||
): Promise<PaginationResponse<{{pascalCase name}}Entity>> {
|
||||
return await this.orchestrator.index(params);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async detail(@Param('id') id: string): Promise<{{pascalCase name}}Entity> {
|
||||
return await this.orchestrator.detail(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { {{pascalCase name}}DataOrchestrator } from '../domain/usecases/{{dashCase name}}-data.orchestrator';
|
||||
import { {{pascalCase name}}Dto } from './dto/{{dashCase name}}.dto';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { {{pascalCase name}}Entity } from '../domain/entities/{{dashCase name}}.entity';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
||||
import { Public } from 'src/core/guards';
|
||||
|
||||
@ApiTags(`${MODULE_NAME.{{constantCase name}}.split('-').join(' ')} - data`)
|
||||
@Controller(MODULE_NAME.{{constantCase name}})
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class {{pascalCase name}}DataController {
|
||||
constructor(private orchestrator: {{pascalCase name}}DataOrchestrator) {}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Body() data: {{pascalCase name}}Dto,
|
||||
): Promise<{{pascalCase name}}Entity> {
|
||||
return await this.orchestrator.create(data);
|
||||
}
|
||||
|
||||
@Put('/batch-delete')
|
||||
async batchDeleted(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||
return await this.orchestrator.batchDelete(body.ids);
|
||||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
@Put('/batch-active')
|
||||
async batchActive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||
return await this.orchestrator.batchActive(body.ids);
|
||||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
@Put('/batch-confirm')
|
||||
async batchConfirm(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||
return await this.orchestrator.batchConfirm(body.ids);
|
||||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
@Put('/batch-inactive')
|
||||
async batchInactive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||
return await this.orchestrator.batchInactive(body.ids);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Param('id') dataId: string,
|
||||
@Body() data: {{pascalCase name}}Dto,
|
||||
): Promise<{{pascalCase name}}Entity> {
|
||||
return await this.orchestrator.update(dataId, data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { {{pascalCase name}}DataOrchestrator } from '../domain/usecases/{{dashCase name}}-data.orchestrator';
|
||||
import { {{pascalCase name}}Dto } from './dto/{{dashCase name}}.dto';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { {{pascalCase name}}Entity } from '../domain/entities/{{dashCase name}}.entity';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
||||
import { Public } from 'src/core/guards';
|
||||
|
||||
@ApiTags(`${MODULE_NAME.{{constantCase name}}.split('-').join(' ')} - data`)
|
||||
@Controller(MODULE_NAME.{{constantCase name}})
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class {{pascalCase name}}DataController {
|
||||
constructor(private orchestrator: {{pascalCase name}}DataOrchestrator) {}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Body() data: {{pascalCase name}}Dto,
|
||||
): Promise<{{pascalCase name}}Entity> {
|
||||
return await this.orchestrator.create(data);
|
||||
}
|
||||
|
||||
@Put('/batch-delete')
|
||||
async batchDeleted(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||
return await this.orchestrator.batchDelete(body.ids);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Param('id') dataId: string,
|
||||
@Body() data: Create{{pascalCase name}}Dto,
|
||||
): Promise<{{pascalCase name}}Entity> {
|
||||
return await this.orchestrator.update(dataId, data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
|
||||
import { Filter{{pascalCase name}}Entity } from '../../domain/entities/filter-{{dashCase name}}.entity';
|
||||
|
||||
export class Filter{{pascalCase name}}Dto
|
||||
extends BaseFilterDto
|
||||
implements Filter{{pascalCase name}}Entity {}
|
|
@ -0,0 +1,7 @@
|
|||
import { {{pascalCase base}}Dto } from 'src/core/modules/infrastructure/dto/{{dashCase base}}.dto';
|
||||
import { {{pascalCase name}}Entity } from '../../domain/entities/{{dashCase name}}.entity';
|
||||
|
||||
export class {{pascalCase name}}Dto
|
||||
extends {{pascalCase base}}Dto
|
||||
implements {{pascalCase name}}Entity
|
||||
{}
|
|
@ -0,0 +1,3 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export interface Filter{{pascalCase name}}Entity extends BaseFilterEntity {}
|
|
@ -0,0 +1,4 @@
|
|||
import { {{pascalCase base}}Entity } from 'src/core/modules/domain/entities/{{dashCase base}}.entity';
|
||||
|
||||
export interface {{pascalCase name}}Entity extends {{pascalCase base}}Entity {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from "src/core/strings/constants/interface.constants";
|
||||
|
||||
export class {{pascalCase name}}ChangeStatusEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from "src/core/strings/constants/interface.constants";
|
||||
|
||||
export class {{pascalCase name}}CreatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from "src/core/strings/constants/interface.constants";
|
||||
|
||||
export class {{pascalCase name}}DeletedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from "src/core/strings/constants/interface.constants";
|
||||
|
||||
export class {{pascalCase name}}UpdatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}DeletedEvent } from '../../entities/event/{{dashCase name}}-deleted.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchDelete{{pascalCase name}}Manager extends BaseBatchDeleteManager<{{pascalCase name}}Entity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async validateData(data: {{pascalCase name}}Entity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}DeletedEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
import { Injectable } from "@nestjs/common";
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||
import { {{pascalCase name}}CreatedEvent } from '../../entities/event/{{dashCase name}}-created.event';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class Create{{pascalCase name}}Manager extends BaseCreateManager<{{pascalCase name}}Entity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async generateConfig(): Promise<void> {}
|
||||
|
||||
get uniqueColumns(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}CreatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}DeletedEvent } from '../../entities/event/{{dashCase name}}-deleted.event';
|
||||
|
||||
@Injectable()
|
||||
export class Delete{{pascalCase name}}Manager extends BaseDeleteManager<{{pascalCase name}}Entity> {
|
||||
getResult(): string {
|
||||
return `Success`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}DeletedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class Detail{{pascalCase name}}Manager extends BaseDetailManager<{{pascalCase name}}Entity> {
|
||||
async prepareData(): Promise<void> {
|
||||
this.tableName = TABLE_NAME.USER_PRIVILEGE;
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
joinRelations: [],
|
||||
selectRelations: [],
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get setFindProperties(): any {
|
||||
return {
|
||||
id: this.dataId,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
import {
|
||||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class Index{{pascalCase name}}Manager extends BaseIndexManager<{{pascalCase name}}Entity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
joinRelations: [],
|
||||
selectRelations: [],
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get specificFilter(): Param[] {
|
||||
return [
|
||||
{
|
||||
cols: `${this.tableName}.name`,
|
||||
data: this.filterParam.names,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<{{pascalCase name}}Entity>,
|
||||
): SelectQueryBuilder<{{pascalCase name}}Entity> {
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}UpdatedEvent } from '../../entities/event/{{dashCase name}}-updated.event';
|
||||
|
||||
@Injectable()
|
||||
export class Update{{pascalCase name}}Manager extends BaseUpdateManager<{{pascalCase name}}Entity> {
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get uniqueColumns(): string[] {
|
||||
return ['name'];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}UpdatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}ChangeStatusEvent } from '../../entities/event/{{dashCase name}}-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class Active{{pascalCase name}}Manager extends BaseUpdateStatusManager<{{pascalCase name}}Entity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.name}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}ChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}ChangeStatusEvent } from '../../entities/event/{{dashCase name}}-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchActive{{pascalCase name}}Manager extends BaseBatchUpdateStatusManager<{{pascalCase name}}Entity> {
|
||||
validateData(data: {{pascalCase name}}Entity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}ChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}ChangeStatusEvent } from '../../entities/event/{{dashCase name}}-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchConfirm{{pascalCase name}}Manager extends BaseBatchUpdateStatusManager<{{pascalCase name}}Entity> {
|
||||
validateData(data: {{pascalCase name}}Entity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}ChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}ChangeStatusEvent } from '../../entities/event/{{dashCase name}}-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchInactive{{pascalCase name}}Manager extends BaseBatchUpdateStatusManager<{{pascalCase name}}Entity> {
|
||||
validateData(data: {{pascalCase name}}Entity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}ChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}ChangeStatusEvent } from '../../entities/event/{{dashCase name}}-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class Confirm{{pascalCase name}}Manager extends BaseUpdateStatusManager<{{pascalCase name}}Entity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.name}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}ChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { {{pascalCase name}}Entity } from '../../entities/{{dashCase name}}.entity';
|
||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||
import { {{pascalCase name}}Model } from '../../../data/models/{{dashCase name}}.model';
|
||||
import { {{pascalCase name}}ChangeStatusEvent } from '../../entities/event/{{dashCase name}}-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class Inactive{{pascalCase name}}Manager extends BaseUpdateStatusManager<{{pascalCase name}}Entity> {
|
||||
getResult(): string {
|
||||
return `Success inactive data ${this.result.name}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return {{pascalCase name}}Model;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: {{pascalCase name}}ChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import { TABLE_NAME } from "src/core/strings/constants/table.constants";
|
||||
import { {{pascalCase name}}Entity } from '../../domain/entities/{{dashCase name}}.entity';
|
||||
import { Entity } from "typeorm";
|
||||
import { {{pascalCase base}}Model } from 'src/core/modules/data/model/{{dashCase base}}.model';
|
||||
|
||||
@Entity(TABLE_NAME.{{constantCase name}})
|
||||
export class {{pascalCase name}}Model extends {{pascalCase base}}Model<{{pascalCase name}}Entity> implements {{pascalCase name}}Entity {}
|
|
@ -0,0 +1,57 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { {{pascalCase name}}DataService } from './data/services/{{dashCase name}}-data.service';
|
||||
import { {{pascalCase name}}ReadService } from './data/services/{{dashCase name}}-read.service';
|
||||
import { {{pascalCase name}}ReadController } from './infrastructure/{{dashCase name}}-read.controller';
|
||||
import { {{pascalCase name}}ReadOrchestrator } from './domain/usecases/{{dashCase name}}-read.orchestrator';
|
||||
import { {{pascalCase name}}DataController } from './infrastructure/{{dashCase name}}-data.controller';
|
||||
import { {{pascalCase name}}DataOrchestrator } from './domain/usecases/{{dashCase name}}-data.orchestrator';
|
||||
import { Create{{pascalCase name}}Manager } from './domain/usecases/managers/create-{{dashCase name}}.manager';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { Index{{pascalCase name}}Manager } from './domain/usecases/managers/index-{{dashCase name}}.manager';
|
||||
import { Delete{{pascalCase name}}Manager } from './domain/usecases/managers/delete-{{dashCase name}}.manager';
|
||||
import { Update{{pascalCase name}}Manager } from './domain/usecases/managers/update-{{dashCase name}}.manager';
|
||||
import { Active{{pascalCase name}}Manager } from './domain/usecases/managers/active-{{dashCase name}}.manager';
|
||||
import { Confirm{{pascalCase name}}Manager } from './domain/usecases/managers/confirm-{{dashCase name}}.manager';
|
||||
import { Inactive{{pascalCase name}}Manager } from './domain/usecases/managers/inactive-{{dashCase name}}.manager';
|
||||
import { Detail{{pascalCase name}}Manager } from './domain/usecases/managers/detail-{{dashCase name}}.manager';
|
||||
import { BatchDelete{{pascalCase name}}Manager } from './domain/usecases/managers/batch-delete-{{dashCase name}}.manager';
|
||||
import { BatchActive{{pascalCase name}}Manager } from './domain/usecases/managers/batch-active-{{dashCase name}}.manager';
|
||||
import { BatchConfirm{{pascalCase name}}Manager } from './domain/usecases/managers/batch-confirm-{{dashCase name}}.manager';
|
||||
import { BatchInactive{{pascalCase name}}Manager } from './domain/usecases/managers/batch-inactive-{{dashCase name}}.manager';
|
||||
import { {{pascalCase name}}Model } from './data/models/{{dashCase name}}.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forFeature([{{pascalCase name}}Model], CONNECTION_NAME.DEFAULT),
|
||||
CqrsModule,
|
||||
],
|
||||
controllers: [
|
||||
{{pascalCase name}}DataController,
|
||||
{{pascalCase name}}ReadController,
|
||||
],
|
||||
providers: [
|
||||
Index{{pascalCase name}}Manager,
|
||||
Detail{{pascalCase name}}Manager,
|
||||
Create{{pascalCase name}}Manager,
|
||||
Delete{{pascalCase name}}Manager,
|
||||
Update{{pascalCase name}}Manager,
|
||||
Active{{pascalCase name}}Manager,
|
||||
Confirm{{pascalCase name}}Manager,
|
||||
Inactive{{pascalCase name}}Manager,
|
||||
BatchDelete{{pascalCase name}}Manager,
|
||||
BatchActive{{pascalCase name}}Manager,
|
||||
BatchConfirm{{pascalCase name}}Manager,
|
||||
BatchInactive{{pascalCase name}}Manager,
|
||||
|
||||
{{pascalCase name}}DataService,
|
||||
{{pascalCase name}}ReadService,
|
||||
|
||||
{{pascalCase name}}DataOrchestrator,
|
||||
{{pascalCase name}}ReadOrchestrator,
|
||||
],
|
||||
})
|
||||
export class {{pascalCase name}}Module {}
|
|
@ -0,0 +1,45 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { {{pascalCase name}}DataService } from './data/services/{{dashCase name}}-data.service';
|
||||
import { {{pascalCase name}}ReadService } from './data/services/{{dashCase name}}-read.service';
|
||||
import { {{pascalCase name}}ReadController } from './infrastructure/{{dashCase name}}-read.controller';
|
||||
import { {{pascalCase name}}ReadOrchestrator } from './domain/usecases/{{dashCase name}}-read.orchestrator';
|
||||
import { {{pascalCase name}}DataController } from './infrastructure/{{dashCase name}}-data.controller';
|
||||
import { {{pascalCase name}}DataOrchestrator } from './domain/usecases/{{dashCase name}}-data.orchestrator';
|
||||
import { Create{{pascalCase name}}Manager } from './domain/usecases/managers/create-{{dashCase name}}.manager';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { Index{{pascalCase name}}Manager } from './domain/usecases/managers/index-{{dashCase name}}.manager';
|
||||
import { Delete{{pascalCase name}}Manager } from './domain/usecases/managers/delete-{{dashCase name}}.manager';
|
||||
import { Update{{pascalCase name}}Manager } from './domain/usecases/managers/update-{{dashCase name}}.manager';
|
||||
import { Detail{{pascalCase name}}Manager } from './domain/usecases/managers/detail-{{dashCase name}}.manager';
|
||||
import { BatchDelete{{pascalCase name}}Manager } from './domain/usecases/managers/batch-delete-{{dashCase name}}.manager';
|
||||
import { {{pascalCase name}}Model } from './data/models/{{dashCase name}}.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forFeature([{{pascalCase name}}Model], CONNECTION_NAME.DEFAULT),
|
||||
CqrsModule,
|
||||
],
|
||||
controllers: [
|
||||
{{pascalCase name}}DataController,
|
||||
{{pascalCase name}}ReadController,
|
||||
],
|
||||
providers: [
|
||||
Index{{pascalCase name}}Manager,
|
||||
Detail{{pascalCase name}}Manager,
|
||||
Create{{pascalCase name}}Manager,
|
||||
Delete{{pascalCase name}}Manager,
|
||||
Update{{pascalCase name}}Manager,
|
||||
BatchDelete{{pascalCase name}}Manager,
|
||||
|
||||
{{pascalCase name}}DataService,
|
||||
{{pascalCase name}}ReadService,
|
||||
|
||||
{{pascalCase name}}DataOrchestrator,
|
||||
{{pascalCase name}}ReadOrchestrator,
|
||||
],
|
||||
})
|
||||
export class {{pascalCase name}}Module {}
|
|
@ -0,0 +1,33 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { Index{{pascalCase name}}Manager } from './managers/index-{{dashCase name}}.manager';
|
||||
import { {{pascalCase name}}ReadService } from '../../data/services/{{dashCase name}}-read.service';
|
||||
import { {{pascalCase name}}Entity } from '../entities/{{dashCase name}}.entity';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
|
||||
import { Detail{{pascalCase name}}Manager } from './managers/detail-{{dashCase name}}.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class {{pascalCase name}}ReadOrchestrator extends BaseReadOrchestrator<{{pascalCase name}}Entity> {
|
||||
constructor(
|
||||
private indexManager: Index{{pascalCase name}}Manager,
|
||||
private detailManager: Detail{{pascalCase name}}Manager,
|
||||
private serviceData: {{pascalCase name}}ReadService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async index(params): Promise<PaginationResponse<{{pascalCase name}}Entity>> {
|
||||
this.indexManager.setFilterParam(params);
|
||||
this.indexManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.indexManager.execute();
|
||||
return this.indexManager.getResult();
|
||||
}
|
||||
|
||||
async detail(dataId: string): Promise<{{pascalCase name}}Entity> {
|
||||
this.detailManager.setData(dataId);
|
||||
this.detailManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.detailManager.execute();
|
||||
return this.detailManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { Create{{pascalCase name}}Manager } from './managers/create-{{dashCase name}}.manager';
|
||||
import { {{pascalCase name}}DataService } from '../../data/services/{{dashCase name}}-data.service';
|
||||
import { {{pascalCase name}}Entity } from '../entities/{{dashCase name}}.entity';
|
||||
import { Delete{{pascalCase name}}Manager } from './managers/delete-{{dashCase name}}.manager';
|
||||
import { Update{{pascalCase name}}Manager } from './managers/update-{{dashCase name}}.manager';
|
||||
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
||||
import { Active{{pascalCase name}}Manager } from './managers/active-{{dashCase name}}.manager';
|
||||
import { Inactive{{pascalCase name}}Manager } from './managers/inactive-{{dashCase name}}.manager';
|
||||
import { Confirm{{pascalCase name}}Manager } from './managers/confirm-{{dashCase name}}.manager';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchConfirm{{pascalCase name}}Manager } from './managers/batch-confirm-{{dashCase name}}.manager';
|
||||
import { BatchInactive{{pascalCase name}}Manager } from './managers/batch-inactive-{{dashCase name}}.manager';
|
||||
import { BatchActive{{pascalCase name}}Manager } from './managers/batch-active-{{dashCase name}}.manager';
|
||||
import { BatchDelete{{pascalCase name}}Manager } from './managers/batch-delete-{{dashCase name}}.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class {{pascalCase name}}DataOrchestrator extends Base{{pascalCase orchestrator}}Orchestrator<{{pascalCase name}}Entity> {
|
||||
constructor(
|
||||
private createManager: Create{{pascalCase name}}Manager,
|
||||
private updateManager: Update{{pascalCase name}}Manager,
|
||||
private deleteManager: Delete{{pascalCase name}}Manager,
|
||||
private activeManager: Active{{pascalCase name}}Manager,
|
||||
private confirmManager: Confirm{{pascalCase name}}Manager,
|
||||
private inactiveManager: Inactive{{pascalCase name}}Manager,
|
||||
private batchDeleteManager: BatchDelete{{pascalCase name}}Manager,
|
||||
private batchActiveManager: BatchActive{{pascalCase name}}Manager,
|
||||
private batchConfirmManager: BatchConfirm{{pascalCase name}}Manager,
|
||||
private batchInactiveManager: BatchInactive{{pascalCase name}}Manager,
|
||||
private serviceData: {{pascalCase name}}DataService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async create(data): Promise<{{pascalCase name}}Entity> {
|
||||
this.createManager.setData(data);
|
||||
this.createManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.createManager.execute();
|
||||
await this.createManager.generateConfig();
|
||||
return this.createManager.getResult();
|
||||
}
|
||||
|
||||
async update(dataId, data): Promise<{{pascalCase name}}Entity> {
|
||||
this.updateManager.setData(dataId, data);
|
||||
this.updateManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.updateManager.execute();
|
||||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.deleteManager.execute();
|
||||
return this.deleteManager.getResult();
|
||||
}
|
||||
|
||||
async batchDelete(dataIds: string[]): Promise<BatchResult> {
|
||||
this.batchDeleteManager.setData(dataIds);
|
||||
this.batchDeleteManager.setService(
|
||||
this.serviceData,
|
||||
TABLE_NAME.{{constantCase name}},
|
||||
);
|
||||
await this.batchDeleteManager.execute();
|
||||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.activeManager.execute();
|
||||
return this.activeManager.getResult();
|
||||
}
|
||||
|
||||
async batchActive(dataIds: string[]): Promise<BatchResult> {
|
||||
this.batchActiveManager.setData(dataIds, STATUS.ACTIVE);
|
||||
this.batchActiveManager.setService(
|
||||
this.serviceData,
|
||||
TABLE_NAME.{{constantCase name}},
|
||||
);
|
||||
await this.batchActiveManager.execute();
|
||||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.confirmManager.execute();
|
||||
return this.confirmManager.getResult();
|
||||
}
|
||||
|
||||
async batchConfirm(dataIds: string[]): Promise<BatchResult> {
|
||||
this.batchConfirmManager.setData(dataIds, STATUS.ACTIVE);
|
||||
this.batchConfirmManager.setService(
|
||||
this.serviceData,
|
||||
TABLE_NAME.{{constantCase name}},
|
||||
);
|
||||
await this.batchConfirmManager.execute();
|
||||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(
|
||||
this.serviceData,
|
||||
TABLE_NAME.{{constantCase name}},
|
||||
);
|
||||
await this.inactiveManager.execute();
|
||||
return this.inactiveManager.getResult();
|
||||
}
|
||||
|
||||
async batchInactive(dataIds: string[]): Promise<BatchResult> {
|
||||
this.batchInactiveManager.setData(dataIds, STATUS.INACTIVE);
|
||||
this.batchInactiveManager.setService(
|
||||
this.serviceData,
|
||||
TABLE_NAME.{{constantCase name}},
|
||||
);
|
||||
await this.batchInactiveManager.execute();
|
||||
return this.batchInactiveManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { Create{{pascalCase name}}Manager } from './managers/create-{{dashCase name}}.manager';
|
||||
import { {{pascalCase name}}DataService } from '../../data/services/{{dashCase name}}-data.service';
|
||||
import { {{pascalCase name}}Entity } from '../entities/{{dashCase name}}.entity';
|
||||
import { Delete{{pascalCase name}}Manager } from './managers/delete-{{dashCase name}}.manager';
|
||||
import { Update{{pascalCase name}}Manager } from './managers/update-{{dashCase name}}.manager';
|
||||
import { Base{{pascalCase orchestrator}}Orchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-{{dashCase orchestrator}}.orchestrator';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchDelete{{pascalCase name}}Manager } from './managers/batch-delete-{{dashCase name}}.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class {{pascalCase name}}DataOrchestrator extends Base{{pascalCase orchestrator}}Orchestrator<{{pascalCase name}}Entity> {
|
||||
constructor(
|
||||
private createManager: Create{{pascalCase name}}Manager,
|
||||
private updateManager: Update{{pascalCase name}}Manager,
|
||||
private deleteManager: Delete{{pascalCase name}}Manager,
|
||||
private batchDeleteManager: BatchDelete{{pascalCase name}}Manager,
|
||||
private serviceData: {{pascalCase name}}DataService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async create(data): Promise<{{pascalCase name}}Entity> {
|
||||
this.createManager.setData(data);
|
||||
this.createManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.createManager.execute();
|
||||
await this.createManager.generateConfig();
|
||||
return this.createManager.getResult();
|
||||
}
|
||||
|
||||
async update(dataId, data): Promise<{{pascalCase name}}Entity> {
|
||||
this.updateManager.setData(dataId, data);
|
||||
this.updateManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.updateManager.execute();
|
||||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.deleteManager.execute();
|
||||
return this.deleteManager.getResult();
|
||||
}
|
||||
|
||||
async batchDelete(dataIds: string[]): Promise<BatchResult> {
|
||||
this.batchDeleteManager.setData(dataIds);
|
||||
this.batchDeleteManager.setService(
|
||||
this.serviceData,
|
||||
TABLE_NAME.{{constantCase name}},
|
||||
);
|
||||
await this.batchDeleteManager.execute();
|
||||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||
import { {{pascalCase name}}Entity } from '../../domain/entities/{{dashCase name}}.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { {{pascalCase name}}Model } from '../models/{{dashCase name}}.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class {{pascalCase name}}DataService extends BaseDataService<{{pascalCase name}}Entity> {
|
||||
constructor(
|
||||
@InjectRepository({{pascalCase name}}Model, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<{{pascalCase name}}Model>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { {{pascalCase name}}Entity } from '../../domain/entities/{{dashCase name}}.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { {{pascalCase name}}Model } from '../models/{{dashCase name}}.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
||||
|
||||
@Injectable()
|
||||
export class {{pascalCase name}}ReadService extends BaseReadService<{{pascalCase name}}Entity> {
|
||||
constructor(
|
||||
@InjectRepository({{pascalCase name}}Model, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<{{pascalCase name}}Model>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue