feat(SPG-373) REST API CUD Kategori VIP
parent
fd5cb0062d
commit
be7eb23c97
|
@ -22,6 +22,8 @@ import { TenantModule } from './modules/user-related/tenant/tenant.module';
|
|||
import { ItemCategoryModule } from './modules/item-related/item-category/item-category.module';
|
||||
import { ItemCategoryModel } from './modules/item-related/item-category/data/models/item-category.model';
|
||||
import { ConstantModule } from './modules/configuration/constant/constant.module';
|
||||
import { VipCategoryModule } from './modules/transaction/vip-category/vip-category.module';
|
||||
import { VipCategoryModel } from './modules/transaction/vip-category/data/models/vip-category.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -43,6 +45,7 @@ import { ConstantModule } from './modules/configuration/constant/constant.module
|
|||
LogModel,
|
||||
ErrorLogModel,
|
||||
ItemCategoryModel,
|
||||
VipCategoryModel,
|
||||
],
|
||||
synchronize: false,
|
||||
}),
|
||||
|
@ -53,11 +56,16 @@ import { ConstantModule } from './modules/configuration/constant/constant.module
|
|||
CouchModule,
|
||||
LogModule,
|
||||
|
||||
// user
|
||||
TenantModule,
|
||||
UserModule,
|
||||
UserPrivilegeModule,
|
||||
|
||||
// Item
|
||||
ItemCategoryModule,
|
||||
|
||||
// transaction
|
||||
VipCategoryModule,
|
||||
],
|
||||
controllers: [],
|
||||
providers: [
|
||||
|
|
|
@ -4,4 +4,5 @@ export enum MODULE_NAME {
|
|||
USER = 'users',
|
||||
USER_PRIVILEGE = 'user-privileges',
|
||||
USER_PRIVILEGE_CONFIGURATION = 'user-privilege-configurations',
|
||||
VIP_CATEGORY = 'vip-categories',
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@ export enum TABLE_NAME {
|
|||
USER = 'users',
|
||||
USER_PRIVILEGE = 'user_privileges',
|
||||
USER_PRIVILEGE_CONFIGURATION = 'user_privilege_configurations',
|
||||
VIP_CATEGORY = 'vip_categories',
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class VipCategory1718070608814 implements MigrationInterface {
|
||||
name = 'VipCategory1718070608814';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."vip_categories_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "vip_categories" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "status" "public"."vip_categories_status_enum" NOT NULL DEFAULT 'draft', "name" character varying NOT NULL, CONSTRAINT "PK_b4873a565ca593e90eff71a99a3" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "vip_categories"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."vip_categories_status_enum"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { VipCategoryEntity } from '../../domain/entities/vip-category.entity';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
|
||||
@Entity(TABLE_NAME.VIP_CATEGORY)
|
||||
export class VipCategoryModel
|
||||
extends BaseStatusModel<VipCategoryEntity>
|
||||
implements VipCategoryEntity
|
||||
{
|
||||
@Column('varchar', { name: 'name' })
|
||||
name: string;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||
import { VipCategoryEntity } from '../../domain/entities/vip-category.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { VipCategoryModel } from '../models/vip-category.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class VipCategoryDataService extends BaseDataService<VipCategoryEntity> {
|
||||
constructor(
|
||||
@InjectRepository(VipCategoryModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<VipCategoryModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class VipCategoryChangeStatusEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class VipCategoryCreatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class VipCategoryDeletedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class VipCategoryUpdatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||
|
||||
export interface VipCategoryEntity extends BaseStatusEntity {
|
||||
name: string;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryChangeStatusEvent } from '../../entities/event/vip-category-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ActiveVipCategoryManager extends BaseUpdateStatusManager<VipCategoryEntity> {
|
||||
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 validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryChangeStatusEvent } from '../../entities/event/vip-category-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchActiveVipCategoryManager extends BaseBatchUpdateStatusManager<VipCategoryEntity> {
|
||||
validateData(data: VipCategoryEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryChangeStatusEvent } from '../../entities/event/vip-category-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchConfirmVipCategoryManager extends BaseBatchUpdateStatusManager<VipCategoryEntity> {
|
||||
validateData(data: VipCategoryEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryDeletedEvent } from '../../entities/event/vip-category-deleted.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchDeleteVipCategoryManager extends BaseBatchDeleteManager<VipCategoryEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async validateData(data: VipCategoryEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryDeletedEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryChangeStatusEvent } from '../../entities/event/vip-category-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchInactiveVipCategoryManager extends BaseBatchUpdateStatusManager<VipCategoryEntity> {
|
||||
validateData(data: VipCategoryEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryChangeStatusEvent } from '../../entities/event/vip-category-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ConfirmVipCategoryManager extends BaseUpdateStatusManager<VipCategoryEntity> {
|
||||
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 validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||
import { VipCategoryCreatedEvent } from '../../entities/event/vip-category-created.event';
|
||||
|
||||
@Injectable()
|
||||
export class CreateVipCategoryManager extends BaseCreateManager<VipCategoryEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async generateConfig(): Promise<void> {}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [{ column: 'name' }];
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryCreatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryDeletedEvent } from '../../entities/event/vip-category-deleted.event';
|
||||
|
||||
@Injectable()
|
||||
export class DeleteVipCategoryManager extends BaseDeleteManager<VipCategoryEntity> {
|
||||
getResult(): string {
|
||||
return `Success`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryDeletedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryChangeStatusEvent } from '../../entities/event/vip-category-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class InactiveVipCategoryManager extends BaseUpdateStatusManager<VipCategoryEntity> {
|
||||
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 validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
||||
import { VipCategoryEntity } from '../../entities/vip-category.entity';
|
||||
import { VipCategoryModel } from '../../../data/models/vip-category.model';
|
||||
import { VipCategoryUpdatedEvent } from '../../entities/event/vip-category-updated.event';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
@Injectable()
|
||||
export class UpdateVipCategoryManager extends BaseUpdateManager<VipCategoryEntity> {
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [{ column: 'name' }];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return VipCategoryModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: VipCategoryUpdatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateVipCategoryManager } from './managers/create-vip-category.manager';
|
||||
import { VipCategoryDataService } from '../../data/services/vip-category-data.service';
|
||||
import { VipCategoryEntity } from '../entities/vip-category.entity';
|
||||
import { DeleteVipCategoryManager } from './managers/delete-vip-category.manager';
|
||||
import { UpdateVipCategoryManager } from './managers/update-vip-category.manager';
|
||||
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
||||
import { ActiveVipCategoryManager } from './managers/active-vip-category.manager';
|
||||
import { InactiveVipCategoryManager } from './managers/inactive-vip-category.manager';
|
||||
import { ConfirmVipCategoryManager } from './managers/confirm-vip-category.manager';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchConfirmVipCategoryManager } from './managers/batch-confirm-vip-category.manager';
|
||||
import { BatchInactiveVipCategoryManager } from './managers/batch-inactive-vip-category.manager';
|
||||
import { BatchActiveVipCategoryManager } from './managers/batch-active-vip-category.manager';
|
||||
import { BatchDeleteVipCategoryManager } from './managers/batch-delete-vip-category.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class VipCategoryDataOrchestrator extends BaseDataTransactionOrchestrator<VipCategoryEntity> {
|
||||
constructor(
|
||||
private createManager: CreateVipCategoryManager,
|
||||
private updateManager: UpdateVipCategoryManager,
|
||||
private deleteManager: DeleteVipCategoryManager,
|
||||
private activeManager: ActiveVipCategoryManager,
|
||||
private confirmManager: ConfirmVipCategoryManager,
|
||||
private inactiveManager: InactiveVipCategoryManager,
|
||||
private batchDeleteManager: BatchDeleteVipCategoryManager,
|
||||
private batchActiveManager: BatchActiveVipCategoryManager,
|
||||
private batchConfirmManager: BatchConfirmVipCategoryManager,
|
||||
private batchInactiveManager: BatchInactiveVipCategoryManager,
|
||||
private serviceData: VipCategoryDataService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async create(data): Promise<VipCategoryEntity> {
|
||||
this.createManager.setData(data);
|
||||
this.createManager.setService(this.serviceData, TABLE_NAME.VIP_CATEGORY);
|
||||
await this.createManager.execute();
|
||||
await this.createManager.generateConfig();
|
||||
return this.createManager.getResult();
|
||||
}
|
||||
|
||||
async update(dataId, data): Promise<VipCategoryEntity> {
|
||||
this.updateManager.setData(dataId, data);
|
||||
this.updateManager.setService(this.serviceData, TABLE_NAME.VIP_CATEGORY);
|
||||
await this.updateManager.execute();
|
||||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.VIP_CATEGORY);
|
||||
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.VIP_CATEGORY,
|
||||
);
|
||||
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.VIP_CATEGORY);
|
||||
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.VIP_CATEGORY,
|
||||
);
|
||||
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.VIP_CATEGORY);
|
||||
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.VIP_CATEGORY,
|
||||
);
|
||||
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.VIP_CATEGORY);
|
||||
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.VIP_CATEGORY,
|
||||
);
|
||||
await this.batchInactiveManager.execute();
|
||||
return this.batchInactiveManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||
import { VipCategoryEntity } from '../../domain/entities/vip-category.entity';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString } from 'class-validator';
|
||||
|
||||
export class VipCategoryDto extends BaseStatusDto implements VipCategoryEntity {
|
||||
@ApiProperty({
|
||||
name: 'name',
|
||||
type: String,
|
||||
required: true,
|
||||
example: 'Influencer',
|
||||
})
|
||||
@IsString()
|
||||
name: string;
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { VipCategoryDataOrchestrator } from '../domain/usecases/vip-category-data.orchestrator';
|
||||
import { VipCategoryDto } from './dto/vip-category.dto';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { VipCategoryEntity } from '../domain/entities/vip-category.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.VIP_CATEGORY.split('-').join(' ')} - data`)
|
||||
@Controller(MODULE_NAME.VIP_CATEGORY)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class VipCategoryDataController {
|
||||
constructor(private orchestrator: VipCategoryDataOrchestrator) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() data: VipCategoryDto): Promise<VipCategoryEntity> {
|
||||
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: VipCategoryDto,
|
||||
): Promise<VipCategoryEntity> {
|
||||
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,54 @@
|
|||
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 { VipCategoryDataService } from './data/services/vip-category-data.service';
|
||||
import { VipCategoryReadService } from './data/services/vip-category-read.service';
|
||||
import { VipCategoryReadController } from './infrastructure/vip-category-read.controller';
|
||||
import { VipCategoryReadOrchestrator } from './domain/usecases/vip-category-read.orchestrator';
|
||||
import { VipCategoryDataController } from './infrastructure/vip-category-data.controller';
|
||||
import { VipCategoryDataOrchestrator } from './domain/usecases/vip-category-data.orchestrator';
|
||||
import { CreateVipCategoryManager } from './domain/usecases/managers/create-vip-category.manager';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { IndexVipCategoryManager } from './domain/usecases/managers/index-vip-category.manager';
|
||||
import { DeleteVipCategoryManager } from './domain/usecases/managers/delete-vip-category.manager';
|
||||
import { UpdateVipCategoryManager } from './domain/usecases/managers/update-vip-category.manager';
|
||||
import { ActiveVipCategoryManager } from './domain/usecases/managers/active-vip-category.manager';
|
||||
import { ConfirmVipCategoryManager } from './domain/usecases/managers/confirm-vip-category.manager';
|
||||
import { InactiveVipCategoryManager } from './domain/usecases/managers/inactive-vip-category.manager';
|
||||
import { DetailVipCategoryManager } from './domain/usecases/managers/detail-vip-category.manager';
|
||||
import { BatchDeleteVipCategoryManager } from './domain/usecases/managers/batch-delete-vip-category.manager';
|
||||
import { BatchActiveVipCategoryManager } from './domain/usecases/managers/batch-active-vip-category.manager';
|
||||
import { BatchConfirmVipCategoryManager } from './domain/usecases/managers/batch-confirm-vip-category.manager';
|
||||
import { BatchInactiveVipCategoryManager } from './domain/usecases/managers/batch-inactive-vip-category.manager';
|
||||
import { VipCategoryModel } from './data/models/vip-category.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forFeature([VipCategoryModel], CONNECTION_NAME.DEFAULT),
|
||||
CqrsModule,
|
||||
],
|
||||
controllers: [VipCategoryDataController, VipCategoryReadController],
|
||||
providers: [
|
||||
IndexVipCategoryManager,
|
||||
DetailVipCategoryManager,
|
||||
CreateVipCategoryManager,
|
||||
DeleteVipCategoryManager,
|
||||
UpdateVipCategoryManager,
|
||||
ActiveVipCategoryManager,
|
||||
ConfirmVipCategoryManager,
|
||||
InactiveVipCategoryManager,
|
||||
BatchDeleteVipCategoryManager,
|
||||
BatchActiveVipCategoryManager,
|
||||
BatchConfirmVipCategoryManager,
|
||||
BatchInactiveVipCategoryManager,
|
||||
|
||||
VipCategoryDataService,
|
||||
VipCategoryReadService,
|
||||
|
||||
VipCategoryDataOrchestrator,
|
||||
VipCategoryReadOrchestrator,
|
||||
],
|
||||
})
|
||||
export class VipCategoryModule {}
|
Loading…
Reference in New Issue