Compare commits
7 Commits
688be5828d
...
b574d3a39d
Author | SHA1 | Date |
---|---|---|
|
b574d3a39d | |
|
eafd815463 | |
|
5a96282bce | |
|
55d25644dd | |
|
7a3d4b9432 | |
|
af1a642907 | |
|
0d2e49f93a |
|
@ -29,7 +29,7 @@ module.exports = function (plop) {
|
|||
name: 'location',
|
||||
message: 'Location: ',
|
||||
choices: function () {
|
||||
return ['item related', 'user related', 'season related', 'transaction'];
|
||||
return ['item related', 'user related', 'season related', 'transaction', 'web information'];
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
@ -47,7 +47,6 @@ import { TransactionModel } from './modules/transaction/transaction/data/models/
|
|||
import { TransactionItemModel } from './modules/transaction/transaction/data/models/transaction-item.model';
|
||||
import { TransactionTaxModel } from './modules/transaction/transaction/data/models/transaction-tax.model';
|
||||
import { ReconciliationModule } from './modules/transaction/reconciliation/reconciliation.module';
|
||||
|
||||
import { ReportModule } from './modules/reports/report/report.module';
|
||||
import { ReportBookmarkModule } from './modules/reports/report-bookmark/report-bookmark.module';
|
||||
import { ReportExportModule } from './modules/reports/report-export/report-export.module';
|
||||
|
@ -58,6 +57,12 @@ import { MidtransModule } from './modules/configuration/midtrans/midtrans.module
|
|||
import { RefundModule } from './modules/transaction/refund/refund.module';
|
||||
import { RefundModel } from './modules/transaction/refund/data/models/refund.model';
|
||||
import { RefundItemModel } from './modules/transaction/refund/data/models/refund-item.model';
|
||||
import { GateModule } from './modules/web-information/gate/gate.module';
|
||||
import { GateModel } from './modules/web-information/gate/data/models/gate.model';
|
||||
import { TermConditionModule } from './modules/web-information/term-condition/term-condition.module';
|
||||
import { TermConditionModel } from './modules/web-information/term-condition/data/models/term-condition.model';
|
||||
import { FaqModel } from './modules/web-information/faq/data/models/faq.model';
|
||||
import { FaqModule } from './modules/web-information/faq/faq.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -76,6 +81,8 @@ import { RefundItemModel } from './modules/transaction/refund/data/models/refund
|
|||
entities: [
|
||||
...UserPrivilegeModels,
|
||||
ErrorLogModel,
|
||||
FaqModel,
|
||||
GateModel,
|
||||
ItemModel,
|
||||
ItemCategoryModel,
|
||||
ItemRateModel,
|
||||
|
@ -87,6 +94,7 @@ import { RefundItemModel } from './modules/transaction/refund/data/models/refund
|
|||
SeasonPeriodModel,
|
||||
SeasonTypeModel,
|
||||
TaxModel,
|
||||
TermConditionModel,
|
||||
TransactionModel,
|
||||
TransactionItemModel,
|
||||
TransactionTaxModel,
|
||||
|
@ -135,6 +143,11 @@ import { RefundItemModel } from './modules/transaction/refund/data/models/refund
|
|||
SeasonTypeModule,
|
||||
SeasonPeriodModule,
|
||||
|
||||
// web information
|
||||
FaqModule,
|
||||
GateModule,
|
||||
TermConditionModule,
|
||||
|
||||
// report
|
||||
ReportModule,
|
||||
ReportBookmarkModule,
|
||||
|
|
|
@ -48,3 +48,5 @@ export const BLANK_USER = {
|
|||
role: null,
|
||||
user_privilege_id: null,
|
||||
};
|
||||
|
||||
export const EMPTY_UUID = '00000000-0000-0000-0000-000000000000';
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export enum MODULE_NAME {
|
||||
FAQ = 'faqs',
|
||||
GATE = 'gates',
|
||||
ITEM = 'items',
|
||||
ITEM_CATEGORY = 'item-categories',
|
||||
ITEM_RATE = 'item-rates',
|
||||
|
@ -8,6 +10,7 @@ export enum MODULE_NAME {
|
|||
SEASON_TYPE = 'season-types',
|
||||
SEASON_PERIOD = 'season-periods',
|
||||
TAX = 'taxes',
|
||||
TERM_CONDITION = 'term_conditions',
|
||||
TENANT = 'tenants',
|
||||
TRANSACTION = 'transactions',
|
||||
USER = 'users',
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
export enum TABLE_NAME {
|
||||
ERROR_LOG = 'log_errors',
|
||||
FAQ = 'faqs',
|
||||
ITEM = 'items',
|
||||
ITEM_CATEGORY = 'item_categories',
|
||||
ITEM_RATE = 'item_rates',
|
||||
GATE = 'gates',
|
||||
LOG = 'logs',
|
||||
PAYMENT_METHOD = 'payment_methods',
|
||||
PRICE_FORMULA = 'price_formulas',
|
||||
|
@ -11,6 +13,7 @@ export enum TABLE_NAME {
|
|||
SEASON_TYPE = 'season_types',
|
||||
SEASON_PERIOD = 'season_periods',
|
||||
TAX = 'taxes',
|
||||
TERM_CONDITION = 'term_conditions',
|
||||
TENANT = 'tenants',
|
||||
TRANSACTION = 'transactions',
|
||||
TRANSACTION_ITEM = 'transaction_items',
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class Gate1721024987609 implements MigrationInterface {
|
||||
name = 'Gate1721024987609';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."gates_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'partial refund', 'pending', 'proses refund', 'refunded', 'rejected', 'settled', 'waiting')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."gates_type_enum" AS ENUM('gate masuk', 'gate keluar')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "gates" ("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"."gates_status_enum" NOT NULL DEFAULT 'draft', "type" "public"."gates_type_enum" NOT NULL DEFAULT 'gate masuk', "code" character varying, "note" text, "item_id" uuid, CONSTRAINT "PK_2dd58a77462dd2c5695ec4a7975" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "gates" ADD CONSTRAINT "FK_29f020cd153bb079722bcbee830" FOREIGN KEY ("item_id") REFERENCES "items"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "gates" DROP CONSTRAINT "FK_29f020cd153bb079722bcbee830"`,
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "gates"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."gates_type_enum"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."gates_status_enum"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class TermCondition1721029248635 implements MigrationInterface {
|
||||
name = 'TermCondition1721029248635';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."term_conditions_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'partial refund', 'pending', 'proses refund', 'refunded', 'rejected', 'settled', 'waiting')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "term_conditions" ("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"."term_conditions_status_enum" NOT NULL DEFAULT 'draft', "title" character varying, "description" text, CONSTRAINT "PK_fc92769e487820f24ed68337feb" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "term_conditions"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."term_conditions_status_enum"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class FrequentlyAskQuestion1721029454627 implements MigrationInterface {
|
||||
name = 'FrequentlyAskQuestion1721029454627';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."faqs_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'partial refund', 'pending', 'proses refund', 'refunded', 'rejected', 'settled', 'waiting')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "faqs" ("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"."faqs_status_enum" NOT NULL DEFAULT 'draft', "title" character varying, "description" text, CONSTRAINT "PK_2ddf4f2c910f8e8fa2663a67bf0" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "faqs"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."faqs_status_enum"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateRefund1721031712642 implements MigrationInterface {
|
||||
name = 'UpdateRefund1721031712642'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "refunds" ADD "refund_sub_total" numeric`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "refunds" DROP COLUMN "refund_sub_total"`);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import { ItemType } from 'src/modules/item-related/item-category/constants';
|
|||
import { LimitType } from 'src/modules/item-related/item/constants';
|
||||
import { PaymentMethodType } from 'src/modules/transaction/payment-method/constants';
|
||||
import { RefundType } from 'src/modules/transaction/refund/constants';
|
||||
import { GateType } from 'src/modules/web-information/gate/constants';
|
||||
|
||||
@ApiTags('configuration - constant')
|
||||
@Controller('v1/constant')
|
||||
|
@ -50,4 +51,9 @@ export class ConstantController {
|
|||
async refundType(): Promise<any> {
|
||||
return Object.values(RefundType);
|
||||
}
|
||||
|
||||
@Get('gate-type')
|
||||
async gateType(): Promise<any> {
|
||||
return Object.values(GateType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import { LimitType } from '../../constants';
|
|||
import { ItemCategoryModel } from 'src/modules/item-related/item-category/data/models/item-category.model';
|
||||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
||||
import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/item-rate.model';
|
||||
import { GateModel } from 'src/modules/web-information/gate/data/models/gate.model';
|
||||
|
||||
@Entity(TABLE_NAME.ITEM)
|
||||
export class ItemModel
|
||||
|
@ -108,4 +109,11 @@ export class ItemModel
|
|||
onUpdate: 'CASCADE',
|
||||
})
|
||||
item_rates: ItemRateModel[];
|
||||
|
||||
// relasi ke gate
|
||||
@OneToMany(() => GateModel, (model) => model.item, {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
gates: GateModel[];
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ export class RefundModel
|
|||
@Column('date', { name: 'refund_date', nullable: true })
|
||||
refund_date: Date;
|
||||
|
||||
@Column('decimal', { name: 'refund_sub_total', nullable: true })
|
||||
refund_sub_total: number;
|
||||
|
||||
@Column('decimal', { name: 'refund_total', nullable: true })
|
||||
refund_total: number;
|
||||
|
||||
|
|
|
@ -1,18 +1,3 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export interface FilterRefundEntity extends BaseFilterEntity {
|
||||
codes: string[];
|
||||
invoice_codes: string[];
|
||||
bank_names: string[];
|
||||
bank_account_names: string[];
|
||||
bank_account_numbers: string[];
|
||||
contact_names: string[];
|
||||
creator_names: string[];
|
||||
|
||||
refund_date_from: Date;
|
||||
refund_date_to: Date;
|
||||
request_date_from: Date;
|
||||
request_date_to: Date;
|
||||
settlement_date_from: Date;
|
||||
settlement_date_to: Date;
|
||||
}
|
||||
export interface FilterRefundEntity extends BaseFilterEntity {}
|
||||
|
|
|
@ -6,6 +6,7 @@ export interface RefundEntity extends BaseStatusEntity {
|
|||
code: string;
|
||||
request_date: Date;
|
||||
refund_date: Date;
|
||||
refund_sub_total: number;
|
||||
refund_total: number;
|
||||
|
||||
bank_name: string;
|
||||
|
|
|
@ -17,13 +17,13 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
|||
@Injectable()
|
||||
export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
// if (this.data.transaction?.status != STATUS.SETTLED) {
|
||||
// throw new UnprocessableEntityException({
|
||||
// statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
// message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
||||
// error: 'Unprocessable Entity',
|
||||
// });
|
||||
// }
|
||||
if (this.data.transaction?.status != STATUS.SETTLED) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,13 @@ export class RefundDto extends BaseStatusDto implements RefundEntity {
|
|||
@IsString()
|
||||
type: RefundType;
|
||||
|
||||
@ApiProperty({
|
||||
type: Number,
|
||||
required: false,
|
||||
example: 1750000,
|
||||
})
|
||||
refund_sub_total: number;
|
||||
|
||||
@ApiProperty({
|
||||
type: Number,
|
||||
example: 1750000,
|
||||
|
|
|
@ -45,6 +45,7 @@ export function mappingTransaction(data) {
|
|||
name: itemData.item_category_name,
|
||||
},
|
||||
},
|
||||
id: itemData.id,
|
||||
refund: itemData.refund,
|
||||
qty: itemData.qty,
|
||||
qty_remaining: itemData.qty_remaining,
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { FaqEntity } from '../../domain/entities/faq.entity';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
|
||||
@Entity(TABLE_NAME.FAQ)
|
||||
export class FaqModel extends BaseStatusModel<FaqEntity> implements FaqEntity {
|
||||
@Column('varchar', { name: 'title', nullable: true })
|
||||
title: string;
|
||||
|
||||
@Column('text', { name: 'description', nullable: true })
|
||||
description: string;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||
import { FaqEntity } from '../../domain/entities/faq.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { FaqModel } from '../models/faq.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class FaqDataService extends BaseDataService<FaqEntity> {
|
||||
constructor(
|
||||
@InjectRepository(FaqModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<FaqModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { FaqEntity } from '../../domain/entities/faq.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { FaqModel } from '../models/faq.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 FaqReadService extends BaseReadService<FaqEntity> {
|
||||
constructor(
|
||||
@InjectRepository(FaqModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<FaqModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class FaqChangeStatusEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class FaqCreatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class FaqDeletedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class FaqUpdatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||
|
||||
export interface FaqEntity extends BaseStatusEntity {
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export interface FilterFaqEntity extends BaseFilterEntity {}
|
|
@ -0,0 +1,106 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateFaqManager } from './managers/create-faq.manager';
|
||||
import { FaqDataService } from '../../data/services/faq-data.service';
|
||||
import { FaqEntity } from '../entities/faq.entity';
|
||||
import { DeleteFaqManager } from './managers/delete-faq.manager';
|
||||
import { UpdateFaqManager } from './managers/update-faq.manager';
|
||||
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
||||
import { ActiveFaqManager } from './managers/active-faq.manager';
|
||||
import { InactiveFaqManager } from './managers/inactive-faq.manager';
|
||||
import { ConfirmFaqManager } from './managers/confirm-faq.manager';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchConfirmFaqManager } from './managers/batch-confirm-faq.manager';
|
||||
import { BatchInactiveFaqManager } from './managers/batch-inactive-faq.manager';
|
||||
import { BatchActiveFaqManager } from './managers/batch-active-faq.manager';
|
||||
import { BatchDeleteFaqManager } from './managers/batch-delete-faq.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class FaqDataOrchestrator extends BaseDataTransactionOrchestrator<FaqEntity> {
|
||||
constructor(
|
||||
private createManager: CreateFaqManager,
|
||||
private updateManager: UpdateFaqManager,
|
||||
private deleteManager: DeleteFaqManager,
|
||||
private activeManager: ActiveFaqManager,
|
||||
private confirmManager: ConfirmFaqManager,
|
||||
private inactiveManager: InactiveFaqManager,
|
||||
private batchDeleteManager: BatchDeleteFaqManager,
|
||||
private batchActiveManager: BatchActiveFaqManager,
|
||||
private batchConfirmManager: BatchConfirmFaqManager,
|
||||
private batchInactiveManager: BatchInactiveFaqManager,
|
||||
private serviceData: FaqDataService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async create(data): Promise<FaqEntity> {
|
||||
this.createManager.setData(data);
|
||||
this.createManager.setService(this.serviceData, TABLE_NAME.FAQ);
|
||||
await this.createManager.execute();
|
||||
return this.createManager.getResult();
|
||||
}
|
||||
|
||||
async update(dataId, data): Promise<FaqEntity> {
|
||||
this.updateManager.setData(dataId, data);
|
||||
this.updateManager.setService(this.serviceData, TABLE_NAME.FAQ);
|
||||
await this.updateManager.execute();
|
||||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.FAQ);
|
||||
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.FAQ);
|
||||
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.FAQ);
|
||||
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.FAQ);
|
||||
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.FAQ);
|
||||
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.FAQ);
|
||||
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.FAQ);
|
||||
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.FAQ);
|
||||
await this.batchInactiveManager.execute();
|
||||
return this.batchInactiveManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { IndexFaqManager } from './managers/index-faq.manager';
|
||||
import { FaqReadService } from '../../data/services/faq-read.service';
|
||||
import { FaqEntity } from '../entities/faq.entity';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
|
||||
import { DetailFaqManager } from './managers/detail-faq.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class FaqReadOrchestrator extends BaseReadOrchestrator<FaqEntity> {
|
||||
constructor(
|
||||
private indexManager: IndexFaqManager,
|
||||
private detailManager: DetailFaqManager,
|
||||
private serviceData: FaqReadService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async index(params): Promise<PaginationResponse<FaqEntity>> {
|
||||
this.indexManager.setFilterParam(params);
|
||||
this.indexManager.setService(this.serviceData, TABLE_NAME.FAQ);
|
||||
await this.indexManager.execute();
|
||||
return this.indexManager.getResult();
|
||||
}
|
||||
|
||||
async detail(dataId: string): Promise<FaqEntity> {
|
||||
this.detailManager.setData(dataId);
|
||||
this.detailManager.setService(this.serviceData, TABLE_NAME.FAQ);
|
||||
await this.detailManager.execute();
|
||||
return this.detailManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqChangeStatusEvent } from '../../entities/event/faq-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ActiveFaqManager extends BaseUpdateStatusManager<FaqEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.title}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqChangeStatusEvent } from '../../entities/event/faq-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchActiveFaqManager extends BaseBatchUpdateStatusManager<FaqEntity> {
|
||||
validateData(data: FaqEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqChangeStatusEvent } from '../../entities/event/faq-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchConfirmFaqManager extends BaseBatchUpdateStatusManager<FaqEntity> {
|
||||
validateData(data: FaqEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqDeletedEvent } from '../../entities/event/faq-deleted.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchDeleteFaqManager extends BaseBatchDeleteManager<FaqEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async validateData(data: FaqEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqDeletedEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqChangeStatusEvent } from '../../entities/event/faq-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchInactiveFaqManager extends BaseBatchUpdateStatusManager<FaqEntity> {
|
||||
validateData(data: FaqEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 { FaqEntity } from '../../entities/faq.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqChangeStatusEvent } from '../../entities/event/faq-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ConfirmFaqManager extends BaseUpdateStatusManager<FaqEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.title}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||
import { FaqCreatedEvent } from '../../entities/event/faq-created.event';
|
||||
|
||||
@Injectable()
|
||||
export class CreateFaqManager extends BaseCreateManager<FaqEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqCreatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqDeletedEvent } from '../../entities/event/faq-deleted.event';
|
||||
|
||||
@Injectable()
|
||||
export class DeleteFaqManager extends BaseDeleteManager<FaqEntity> {
|
||||
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 FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqDeletedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class DetailFaqManager extends BaseDetailManager<FaqEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: [],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.title`,
|
||||
`${this.tableName}.description`,
|
||||
];
|
||||
}
|
||||
|
||||
get setFindProperties(): any {
|
||||
return {
|
||||
id: this.dataId,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqChangeStatusEvent } from '../../entities/event/faq-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class InactiveFaqManager extends BaseUpdateStatusManager<FaqEntity> {
|
||||
getResult(): string {
|
||||
return `Success inactive data ${this.result.title}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
import {
|
||||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class IndexFaqManager extends BaseIndexManager<FaqEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: [],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.title`,
|
||||
`${this.tableName}.description`,
|
||||
];
|
||||
}
|
||||
|
||||
get specificFilter(): Param[] {
|
||||
return [
|
||||
{
|
||||
cols: `${this.tableName}.name`,
|
||||
data: this.filterParam.names,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<FaqEntity>,
|
||||
): SelectQueryBuilder<FaqEntity> {
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
||||
import { FaqEntity } from '../../entities/faq.entity';
|
||||
import { FaqModel } from '../../../data/models/faq.model';
|
||||
import { FaqUpdatedEvent } from '../../entities/event/faq-updated.event';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
@Injectable()
|
||||
export class UpdateFaqManager extends BaseUpdateManager<FaqEntity> {
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return FaqModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: FaqUpdatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -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 { FaqDataService } from './data/services/faq-data.service';
|
||||
import { FaqReadService } from './data/services/faq-read.service';
|
||||
import { FaqReadController } from './infrastructure/faq-read.controller';
|
||||
import { FaqReadOrchestrator } from './domain/usecases/faq-read.orchestrator';
|
||||
import { FaqDataController } from './infrastructure/faq-data.controller';
|
||||
import { FaqDataOrchestrator } from './domain/usecases/faq-data.orchestrator';
|
||||
import { CreateFaqManager } from './domain/usecases/managers/create-faq.manager';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { IndexFaqManager } from './domain/usecases/managers/index-faq.manager';
|
||||
import { DeleteFaqManager } from './domain/usecases/managers/delete-faq.manager';
|
||||
import { UpdateFaqManager } from './domain/usecases/managers/update-faq.manager';
|
||||
import { ActiveFaqManager } from './domain/usecases/managers/active-faq.manager';
|
||||
import { ConfirmFaqManager } from './domain/usecases/managers/confirm-faq.manager';
|
||||
import { InactiveFaqManager } from './domain/usecases/managers/inactive-faq.manager';
|
||||
import { DetailFaqManager } from './domain/usecases/managers/detail-faq.manager';
|
||||
import { BatchDeleteFaqManager } from './domain/usecases/managers/batch-delete-faq.manager';
|
||||
import { BatchActiveFaqManager } from './domain/usecases/managers/batch-active-faq.manager';
|
||||
import { BatchConfirmFaqManager } from './domain/usecases/managers/batch-confirm-faq.manager';
|
||||
import { BatchInactiveFaqManager } from './domain/usecases/managers/batch-inactive-faq.manager';
|
||||
import { FaqModel } from './data/models/faq.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forFeature([FaqModel], CONNECTION_NAME.DEFAULT),
|
||||
CqrsModule,
|
||||
],
|
||||
controllers: [FaqDataController, FaqReadController],
|
||||
providers: [
|
||||
IndexFaqManager,
|
||||
DetailFaqManager,
|
||||
CreateFaqManager,
|
||||
DeleteFaqManager,
|
||||
UpdateFaqManager,
|
||||
ActiveFaqManager,
|
||||
ConfirmFaqManager,
|
||||
InactiveFaqManager,
|
||||
BatchDeleteFaqManager,
|
||||
BatchActiveFaqManager,
|
||||
BatchConfirmFaqManager,
|
||||
BatchInactiveFaqManager,
|
||||
|
||||
FaqDataService,
|
||||
FaqReadService,
|
||||
|
||||
FaqDataOrchestrator,
|
||||
FaqReadOrchestrator,
|
||||
],
|
||||
})
|
||||
export class FaqModule {}
|
|
@ -0,0 +1,21 @@
|
|||
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||
import { FaqEntity } from '../../domain/entities/faq.entity';
|
||||
import { IsString } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class FaqDto extends BaseStatusDto implements FaqEntity {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: true,
|
||||
example: 'Booking',
|
||||
})
|
||||
@IsString()
|
||||
title: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
example: 'Booking descs',
|
||||
})
|
||||
description: string;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
|
||||
import { FilterFaqEntity } from '../../domain/entities/filter-faq.entity';
|
||||
|
||||
export class FilterFaqDto extends BaseFilterDto implements FilterFaqEntity {}
|
|
@ -0,0 +1,78 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { FaqDataOrchestrator } from '../domain/usecases/faq-data.orchestrator';
|
||||
import { FaqDto } from './dto/faq.dto';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { FaqEntity } from '../domain/entities/faq.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.FAQ.split('-').join(' ')} - data`)
|
||||
@Controller(`v1/${MODULE_NAME.FAQ}`)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class FaqDataController {
|
||||
constructor(private orchestrator: FaqDataOrchestrator) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() data: FaqDto): Promise<FaqEntity> {
|
||||
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: FaqDto,
|
||||
): Promise<FaqEntity> {
|
||||
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,30 @@
|
|||
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||
import { FilterFaqDto } from './dto/filter-faq.dto';
|
||||
import { Pagination } from 'src/core/response';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { FaqEntity } from '../domain/entities/faq.entity';
|
||||
import { FaqReadOrchestrator } from '../domain/usecases/faq-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.FAQ.split('-').join(' ')} - read`)
|
||||
@Controller(`v1/${MODULE_NAME.FAQ}`)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class FaqReadController {
|
||||
constructor(private orchestrator: FaqReadOrchestrator) {}
|
||||
|
||||
@Get()
|
||||
@Pagination()
|
||||
async index(
|
||||
@Query() params: FilterFaqDto,
|
||||
): Promise<PaginationResponse<FaqEntity>> {
|
||||
return await this.orchestrator.index(params);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async detail(@Param('id') id: string): Promise<FaqEntity> {
|
||||
return await this.orchestrator.detail(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export enum GateType {
|
||||
GATE_IN = 'gate masuk',
|
||||
GATE_OUT = 'gate keluar',
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { GateEntity } from '../../domain/entities/gate.entity';
|
||||
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
import { GateType } from '../../constants';
|
||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
||||
|
||||
@Entity(TABLE_NAME.GATE)
|
||||
export class GateModel
|
||||
extends BaseStatusModel<GateEntity>
|
||||
implements GateEntity
|
||||
{
|
||||
@Column('enum', {
|
||||
name: 'type',
|
||||
enum: GateType,
|
||||
default: GateType.GATE_IN,
|
||||
})
|
||||
type: GateType;
|
||||
|
||||
@Column('varchar', { name: 'code', nullable: true })
|
||||
code: string;
|
||||
|
||||
@Column('text', { name: 'note', nullable: true })
|
||||
note: string;
|
||||
|
||||
@Column('varchar', { name: 'item_id', nullable: true })
|
||||
item_id: string;
|
||||
@ManyToOne(() => ItemModel, (model) => model.gates, {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'item_id' })
|
||||
item: ItemModel;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||
import { GateEntity } from '../../domain/entities/gate.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { GateModel } from '../models/gate.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class GateDataService extends BaseDataService<GateEntity> {
|
||||
constructor(
|
||||
@InjectRepository(GateModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<GateModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { GateEntity } from '../../domain/entities/gate.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { GateModel } from '../models/gate.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 GateReadService extends BaseReadService<GateEntity> {
|
||||
constructor(
|
||||
@InjectRepository(GateModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<GateModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class GateChangeStatusEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class GateCreatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class GateDeletedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class GateUpdatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export interface FilterGateEntity extends BaseFilterEntity {
|
||||
codes: string[];
|
||||
types: string[];
|
||||
item_names: string[];
|
||||
notes: string[];
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||
import { GateType } from '../../constants';
|
||||
|
||||
export interface GateEntity extends BaseStatusEntity {
|
||||
type: GateType;
|
||||
code: string;
|
||||
note: string;
|
||||
|
||||
item_id: string;
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateGateManager } from './managers/create-gate.manager';
|
||||
import { GateDataService } from '../../data/services/gate-data.service';
|
||||
import { GateEntity } from '../entities/gate.entity';
|
||||
import { DeleteGateManager } from './managers/delete-gate.manager';
|
||||
import { UpdateGateManager } from './managers/update-gate.manager';
|
||||
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
||||
import { ActiveGateManager } from './managers/active-gate.manager';
|
||||
import { InactiveGateManager } from './managers/inactive-gate.manager';
|
||||
import { ConfirmGateManager } from './managers/confirm-gate.manager';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchConfirmGateManager } from './managers/batch-confirm-gate.manager';
|
||||
import { BatchInactiveGateManager } from './managers/batch-inactive-gate.manager';
|
||||
import { BatchActiveGateManager } from './managers/batch-active-gate.manager';
|
||||
import { BatchDeleteGateManager } from './managers/batch-delete-gate.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class GateDataOrchestrator extends BaseDataTransactionOrchestrator<GateEntity> {
|
||||
constructor(
|
||||
private createManager: CreateGateManager,
|
||||
private updateManager: UpdateGateManager,
|
||||
private deleteManager: DeleteGateManager,
|
||||
private activeManager: ActiveGateManager,
|
||||
private confirmManager: ConfirmGateManager,
|
||||
private inactiveManager: InactiveGateManager,
|
||||
private batchDeleteManager: BatchDeleteGateManager,
|
||||
private batchActiveManager: BatchActiveGateManager,
|
||||
private batchConfirmManager: BatchConfirmGateManager,
|
||||
private batchInactiveManager: BatchInactiveGateManager,
|
||||
private serviceData: GateDataService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async create(data): Promise<GateEntity> {
|
||||
this.createManager.setData(data);
|
||||
this.createManager.setService(this.serviceData, TABLE_NAME.GATE);
|
||||
await this.createManager.execute();
|
||||
return this.createManager.getResult();
|
||||
}
|
||||
|
||||
async update(dataId, data): Promise<GateEntity> {
|
||||
this.updateManager.setData(dataId, data);
|
||||
this.updateManager.setService(this.serviceData, TABLE_NAME.GATE);
|
||||
await this.updateManager.execute();
|
||||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.GATE);
|
||||
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.GATE);
|
||||
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.GATE);
|
||||
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.GATE);
|
||||
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.GATE);
|
||||
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.GATE);
|
||||
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.GATE);
|
||||
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.GATE);
|
||||
await this.batchInactiveManager.execute();
|
||||
return this.batchInactiveManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { IndexGateManager } from './managers/index-gate.manager';
|
||||
import { GateReadService } from '../../data/services/gate-read.service';
|
||||
import { GateEntity } from '../entities/gate.entity';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
|
||||
import { DetailGateManager } from './managers/detail-gate.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class GateReadOrchestrator extends BaseReadOrchestrator<GateEntity> {
|
||||
constructor(
|
||||
private indexManager: IndexGateManager,
|
||||
private detailManager: DetailGateManager,
|
||||
private serviceData: GateReadService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async index(params): Promise<PaginationResponse<GateEntity>> {
|
||||
this.indexManager.setFilterParam(params);
|
||||
this.indexManager.setService(this.serviceData, TABLE_NAME.GATE);
|
||||
await this.indexManager.execute();
|
||||
return this.indexManager.getResult();
|
||||
}
|
||||
|
||||
async detail(dataId: string): Promise<GateEntity> {
|
||||
this.detailManager.setData(dataId);
|
||||
this.detailManager.setService(this.serviceData, TABLE_NAME.GATE);
|
||||
await this.detailManager.execute();
|
||||
return this.detailManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateChangeStatusEvent } from '../../entities/event/gate-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ActiveGateManager extends BaseUpdateStatusManager<GateEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data gate ${this.result.code}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateChangeStatusEvent } from '../../entities/event/gate-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchActiveGateManager extends BaseBatchUpdateStatusManager<GateEntity> {
|
||||
validateData(data: GateEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateChangeStatusEvent } from '../../entities/event/gate-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchConfirmGateManager extends BaseBatchUpdateStatusManager<GateEntity> {
|
||||
validateData(data: GateEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateDeletedEvent } from '../../entities/event/gate-deleted.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchDeleteGateManager extends BaseBatchDeleteManager<GateEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async validateData(data: GateEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateDeletedEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateChangeStatusEvent } from '../../entities/event/gate-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchInactiveGateManager extends BaseBatchUpdateStatusManager<GateEntity> {
|
||||
validateData(data: GateEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 { GateEntity } from '../../entities/gate.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateChangeStatusEvent } from '../../entities/event/gate-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ConfirmGateManager extends BaseUpdateStatusManager<GateEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data gate ${this.result.code}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
import {
|
||||
HttpStatus,
|
||||
Injectable,
|
||||
UnprocessableEntityException,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||
import { GateCreatedEvent } from '../../entities/event/gate-created.event';
|
||||
import { validateItemGate } from './helpers/validate-item-gate.helper';
|
||||
|
||||
@Injectable()
|
||||
export class CreateGateManager extends BaseCreateManager<GateEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
await validateItemGate(this.dataService, this.data);
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateCreatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateDeletedEvent } from '../../entities/event/gate-deleted.event';
|
||||
|
||||
@Injectable()
|
||||
export class DeleteGateManager extends BaseDeleteManager<GateEntity> {
|
||||
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 GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateDeletedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class DetailGateManager extends BaseDetailManager<GateEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: ['item'],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.type`,
|
||||
`${this.tableName}.code`,
|
||||
`${this.tableName}.note`,
|
||||
|
||||
'item.id',
|
||||
'item.name',
|
||||
'item.status',
|
||||
'item.item_type',
|
||||
'item.base_price',
|
||||
'item.hpp',
|
||||
];
|
||||
}
|
||||
|
||||
get setFindProperties(): any {
|
||||
return {
|
||||
id: this.dataId,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { HttpStatus, UnprocessableEntityException } from '@nestjs/common';
|
||||
import { EMPTY_UUID } from 'src/core/strings/constants/base.constants';
|
||||
import { In, Not } from 'typeorm';
|
||||
|
||||
export async function validateItemGate(dataService, data, id?) {
|
||||
// validate same code
|
||||
const existCode = await dataService.getOneByOptions({
|
||||
where: {
|
||||
code: data.code,
|
||||
id: Not(In([id ?? EMPTY_UUID])),
|
||||
},
|
||||
});
|
||||
|
||||
if (existCode) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! Gate with code ${data.code} already exist`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
||||
// validate type item
|
||||
const existType = await dataService.getOneByOptions({
|
||||
where: {
|
||||
item_id: data.item.id,
|
||||
type: data.type,
|
||||
id: Not(In([id ?? EMPTY_UUID])),
|
||||
},
|
||||
});
|
||||
|
||||
if (existType) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! Gate type ${data.type} with item ${data.item.name} already exist`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateChangeStatusEvent } from '../../entities/event/gate-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class InactiveGateManager extends BaseUpdateStatusManager<GateEntity> {
|
||||
getResult(): string {
|
||||
return `Success inactive data gate ${this.result.code}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
import {
|
||||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class IndexGateManager extends BaseIndexManager<GateEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: ['item'],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.type`,
|
||||
`${this.tableName}.code`,
|
||||
`${this.tableName}.note`,
|
||||
|
||||
'item.id',
|
||||
'item.name',
|
||||
'item.status',
|
||||
'item.item_type',
|
||||
'item.base_price',
|
||||
'item.hpp',
|
||||
];
|
||||
}
|
||||
|
||||
get specificFilter(): Param[] {
|
||||
return [
|
||||
{
|
||||
cols: `${this.tableName}.code`,
|
||||
data: this.filterParam.codes,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.type`,
|
||||
data: this.filterParam.types,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.note`,
|
||||
data: this.filterParam.notes,
|
||||
},
|
||||
{
|
||||
cols: `item.name`,
|
||||
data: this.filterParam.item_names,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<GateEntity>,
|
||||
): SelectQueryBuilder<GateEntity> {
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
||||
import { GateEntity } from '../../entities/gate.entity';
|
||||
import { GateModel } from '../../../data/models/gate.model';
|
||||
import { GateUpdatedEvent } from '../../entities/event/gate-updated.event';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { validateItemGate } from './helpers/validate-item-gate.helper';
|
||||
|
||||
@Injectable()
|
||||
export class UpdateGateManager extends BaseUpdateManager<GateEntity> {
|
||||
async validateProcess(): Promise<void> {
|
||||
await validateItemGate(this.dataService, this.data, this.dataId);
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return GateModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: GateUpdatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -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 { GateDataService } from './data/services/gate-data.service';
|
||||
import { GateReadService } from './data/services/gate-read.service';
|
||||
import { GateReadController } from './infrastructure/gate-read.controller';
|
||||
import { GateReadOrchestrator } from './domain/usecases/gate-read.orchestrator';
|
||||
import { GateDataController } from './infrastructure/gate-data.controller';
|
||||
import { GateDataOrchestrator } from './domain/usecases/gate-data.orchestrator';
|
||||
import { CreateGateManager } from './domain/usecases/managers/create-gate.manager';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { IndexGateManager } from './domain/usecases/managers/index-gate.manager';
|
||||
import { DeleteGateManager } from './domain/usecases/managers/delete-gate.manager';
|
||||
import { UpdateGateManager } from './domain/usecases/managers/update-gate.manager';
|
||||
import { ActiveGateManager } from './domain/usecases/managers/active-gate.manager';
|
||||
import { ConfirmGateManager } from './domain/usecases/managers/confirm-gate.manager';
|
||||
import { InactiveGateManager } from './domain/usecases/managers/inactive-gate.manager';
|
||||
import { DetailGateManager } from './domain/usecases/managers/detail-gate.manager';
|
||||
import { BatchDeleteGateManager } from './domain/usecases/managers/batch-delete-gate.manager';
|
||||
import { BatchActiveGateManager } from './domain/usecases/managers/batch-active-gate.manager';
|
||||
import { BatchConfirmGateManager } from './domain/usecases/managers/batch-confirm-gate.manager';
|
||||
import { BatchInactiveGateManager } from './domain/usecases/managers/batch-inactive-gate.manager';
|
||||
import { GateModel } from './data/models/gate.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forFeature([GateModel], CONNECTION_NAME.DEFAULT),
|
||||
CqrsModule,
|
||||
],
|
||||
controllers: [GateDataController, GateReadController],
|
||||
providers: [
|
||||
IndexGateManager,
|
||||
DetailGateManager,
|
||||
CreateGateManager,
|
||||
DeleteGateManager,
|
||||
UpdateGateManager,
|
||||
ActiveGateManager,
|
||||
ConfirmGateManager,
|
||||
InactiveGateManager,
|
||||
BatchDeleteGateManager,
|
||||
BatchActiveGateManager,
|
||||
BatchConfirmGateManager,
|
||||
BatchInactiveGateManager,
|
||||
|
||||
GateDataService,
|
||||
GateReadService,
|
||||
|
||||
GateDataOrchestrator,
|
||||
GateReadOrchestrator,
|
||||
],
|
||||
})
|
||||
export class GateModule {}
|
|
@ -0,0 +1,30 @@
|
|||
import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
|
||||
import { FilterGateEntity } from '../../domain/entities/filter-gate.entity';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
|
||||
export class FilterGateDto extends BaseFilterDto implements FilterGateEntity {
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
codes: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
types: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
item_names: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
notes: string[];
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||
import { GateEntity } from '../../domain/entities/gate.entity';
|
||||
import { GateType } from '../../constants';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsObject, IsString } from 'class-validator';
|
||||
import { Exclude } from 'class-transformer';
|
||||
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
|
||||
|
||||
export class GateDto extends BaseStatusDto implements GateEntity {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: true,
|
||||
example: GateType.GATE_IN,
|
||||
})
|
||||
@IsString()
|
||||
type: GateType;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: true,
|
||||
example: '41245',
|
||||
})
|
||||
code: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
example: '41245',
|
||||
})
|
||||
note: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: Object,
|
||||
required: true,
|
||||
example: {
|
||||
id: 'uuid',
|
||||
name: 'whana',
|
||||
},
|
||||
})
|
||||
@IsObject()
|
||||
item: ItemEntity;
|
||||
|
||||
@Exclude()
|
||||
item_id: string;
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { GateDataOrchestrator } from '../domain/usecases/gate-data.orchestrator';
|
||||
import { GateDto } from './dto/gate.dto';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { GateEntity } from '../domain/entities/gate.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.GATE.split('-').join(' ')} - data`)
|
||||
@Controller(`v1/${MODULE_NAME.GATE}`)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class GateDataController {
|
||||
constructor(private orchestrator: GateDataOrchestrator) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() data: GateDto): Promise<GateEntity> {
|
||||
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: GateDto,
|
||||
): Promise<GateEntity> {
|
||||
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,30 @@
|
|||
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||
import { FilterGateDto } from './dto/filter-gate.dto';
|
||||
import { Pagination } from 'src/core/response';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { GateEntity } from '../domain/entities/gate.entity';
|
||||
import { GateReadOrchestrator } from '../domain/usecases/gate-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.GATE.split('-').join(' ')} - read`)
|
||||
@Controller(`v1/${MODULE_NAME.GATE}`)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class GateReadController {
|
||||
constructor(private orchestrator: GateReadOrchestrator) {}
|
||||
|
||||
@Get()
|
||||
@Pagination()
|
||||
async index(
|
||||
@Query() params: FilterGateDto,
|
||||
): Promise<PaginationResponse<GateEntity>> {
|
||||
return await this.orchestrator.index(params);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async detail(@Param('id') id: string): Promise<GateEntity> {
|
||||
return await this.orchestrator.detail(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { TermConditionEntity } from '../../domain/entities/term-condition.entity';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
|
||||
@Entity(TABLE_NAME.TERM_CONDITION)
|
||||
export class TermConditionModel
|
||||
extends BaseStatusModel<TermConditionEntity>
|
||||
implements TermConditionEntity
|
||||
{
|
||||
@Column('varchar', { name: 'title', nullable: true })
|
||||
title: string;
|
||||
|
||||
@Column('text', { name: 'description', nullable: true })
|
||||
description: string;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||
import { TermConditionEntity } from '../../domain/entities/term-condition.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { TermConditionModel } from '../models/term-condition.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class TermConditionDataService extends BaseDataService<TermConditionEntity> {
|
||||
constructor(
|
||||
@InjectRepository(TermConditionModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<TermConditionModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { TermConditionEntity } from '../../domain/entities/term-condition.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { TermConditionModel } from '../models/term-condition.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 TermConditionReadService extends BaseReadService<TermConditionEntity> {
|
||||
constructor(
|
||||
@InjectRepository(TermConditionModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<TermConditionModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class TermConditionChangeStatusEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class TermConditionCreatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class TermConditionDeletedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class TermConditionUpdatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export interface FilterTermConditionEntity extends BaseFilterEntity {}
|
|
@ -0,0 +1,6 @@
|
|||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||
|
||||
export interface TermConditionEntity extends BaseStatusEntity {
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionChangeStatusEvent } from '../../entities/event/term-condition-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ActiveTermConditionManager extends BaseUpdateStatusManager<TermConditionEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.title}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionChangeStatusEvent } from '../../entities/event/term-condition-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchActiveTermConditionManager extends BaseBatchUpdateStatusManager<TermConditionEntity> {
|
||||
validateData(data: TermConditionEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionChangeStatusEvent } from '../../entities/event/term-condition-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchConfirmTermConditionManager extends BaseBatchUpdateStatusManager<TermConditionEntity> {
|
||||
validateData(data: TermConditionEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionDeletedEvent } from '../../entities/event/term-condition-deleted.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchDeleteTermConditionManager extends BaseBatchDeleteManager<TermConditionEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async validateData(data: TermConditionEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionDeletedEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionChangeStatusEvent } from '../../entities/event/term-condition-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchInactiveTermConditionManager extends BaseBatchUpdateStatusManager<TermConditionEntity> {
|
||||
validateData(data: TermConditionEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionChangeStatusEvent } from '../../entities/event/term-condition-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ConfirmTermConditionManager extends BaseUpdateStatusManager<TermConditionEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.title}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||
import { TermConditionCreatedEvent } from '../../entities/event/term-condition-created.event';
|
||||
|
||||
@Injectable()
|
||||
export class CreateTermConditionManager extends BaseCreateManager<TermConditionEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionCreatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionDeletedEvent } from '../../entities/event/term-condition-deleted.event';
|
||||
|
||||
@Injectable()
|
||||
export class DeleteTermConditionManager extends BaseDeleteManager<TermConditionEntity> {
|
||||
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 TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionDeletedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class DetailTermConditionManager extends BaseDetailManager<TermConditionEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: [],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.title`,
|
||||
`${this.tableName}.description`,
|
||||
];
|
||||
}
|
||||
|
||||
get setFindProperties(): any {
|
||||
return {
|
||||
id: this.dataId,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionChangeStatusEvent } from '../../entities/event/term-condition-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class InactiveTermConditionManager extends BaseUpdateStatusManager<TermConditionEntity> {
|
||||
getResult(): string {
|
||||
return `Success inactive data ${this.result.title}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
import {
|
||||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class IndexTermConditionManager extends BaseIndexManager<TermConditionEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: [],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.title`,
|
||||
`${this.tableName}.description`,
|
||||
];
|
||||
}
|
||||
|
||||
get specificFilter(): Param[] {
|
||||
return [
|
||||
{
|
||||
cols: `${this.tableName}.name`,
|
||||
data: this.filterParam.names,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<TermConditionEntity>,
|
||||
): SelectQueryBuilder<TermConditionEntity> {
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
||||
import { TermConditionEntity } from '../../entities/term-condition.entity';
|
||||
import { TermConditionModel } from '../../../data/models/term-condition.model';
|
||||
import { TermConditionUpdatedEvent } from '../../entities/event/term-condition-updated.event';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
@Injectable()
|
||||
export class UpdateTermConditionManager extends BaseUpdateManager<TermConditionEntity> {
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TermConditionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TermConditionUpdatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue