feat(SPG-440) REST API CUD FAQ
parent
55d25644dd
commit
5a96282bce
|
@ -61,6 +61,8 @@ 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: [
|
||||
|
@ -79,6 +81,7 @@ import { TermConditionModel } from './modules/web-information/term-condition/dat
|
|||
entities: [
|
||||
...UserPrivilegeModels,
|
||||
ErrorLogModel,
|
||||
FaqModel,
|
||||
GateModel,
|
||||
ItemModel,
|
||||
ItemCategoryModel,
|
||||
|
@ -141,6 +144,7 @@ import { TermConditionModel } from './modules/web-information/term-condition/dat
|
|||
SeasonPeriodModule,
|
||||
|
||||
// web information
|
||||
FaqModule,
|
||||
GateModule,
|
||||
TermConditionModule,
|
||||
|
||||
|
|
|
@ -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,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,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,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,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,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,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,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);
|
||||
}
|
||||
}
|
|
@ -2,14 +2,13 @@ import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.d
|
|||
import { GateEntity } from '../../domain/entities/gate.entity';
|
||||
import { GateType } from '../../constants';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { string } from 'mathjs';
|
||||
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,
|
||||
type: String,
|
||||
required: true,
|
||||
example: GateType.GATE_IN,
|
||||
})
|
||||
|
@ -17,14 +16,14 @@ export class GateDto extends BaseStatusDto implements GateEntity {
|
|||
type: GateType;
|
||||
|
||||
@ApiProperty({
|
||||
type: string,
|
||||
type: String,
|
||||
required: true,
|
||||
example: '41245',
|
||||
})
|
||||
code: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: string,
|
||||
type: String,
|
||||
required: false,
|
||||
example: '41245',
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue