feat(SPG-379) REST API CUD Metode Pembayaran
parent
d9d22779f0
commit
0ce8c8402e
|
@ -35,6 +35,8 @@ import { TaxModel } from './modules/transaction/tax/data/models/tax.model';
|
|||
import { SalesPriceFormulaModule } from './modules/transaction/sales-price-formula/sales-price-formula.module';
|
||||
import { SalesPriceFormulaModel } from './modules/transaction/sales-price-formula/data/models/sales-price-formula.model';
|
||||
import { ProfitShareFormulaModule } from './modules/transaction/profit-share-formula/profit-share-formula.module';
|
||||
import { PaymentMethodModule } from './modules/transaction/payment-method/payment-method.module';
|
||||
import { PaymentMethodModel } from './modules/transaction/payment-method/data/models/payment-method.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -56,6 +58,7 @@ import { ProfitShareFormulaModule } from './modules/transaction/profit-share-for
|
|||
ItemModel,
|
||||
ItemCategoryModel,
|
||||
LogModel,
|
||||
PaymentMethodModel,
|
||||
SalesPriceFormulaModel,
|
||||
SeasonTypeModel,
|
||||
TaxModel,
|
||||
|
@ -82,6 +85,7 @@ import { ProfitShareFormulaModule } from './modules/transaction/profit-share-for
|
|||
ItemModule,
|
||||
|
||||
// transaction
|
||||
PaymentMethodModule,
|
||||
ProfitShareFormulaModule,
|
||||
SalesPriceFormulaModule,
|
||||
TaxModule,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
export enum MODULE_NAME {
|
||||
ITEM = 'items',
|
||||
ITEM_CATEGORY = 'item-categories',
|
||||
PAYMENT_METHOD = 'payment-methods',
|
||||
SEASON_TYPE = 'season-types',
|
||||
TAX = 'taxes',
|
||||
TENANT = 'tenants',
|
||||
|
|
|
@ -3,6 +3,7 @@ export enum TABLE_NAME {
|
|||
ITEM = 'items',
|
||||
ITEM_CATEGORY = 'item_categories',
|
||||
LOG = 'logs',
|
||||
PAYMENT_METHOD = 'payment_methods',
|
||||
PRICE_FORMULA = 'price_formulas',
|
||||
SEASON_TYPE = 'season_types',
|
||||
TAX = 'taxes',
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class PaymentMethod1718167285807 implements MigrationInterface {
|
||||
name = 'PaymentMethod1718167285807';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."payment_methods_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."payment_methods_type_enum" AS ENUM('bank transfer', 'e-wallet', 'edc')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "payment_methods" ("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"."payment_methods_status_enum" NOT NULL DEFAULT 'draft', "issuer_name" character varying NOT NULL, "account_number" character varying, "account_name" character varying, "qr_image" character varying, "note" character varying, "type" "public"."payment_methods_type_enum" NOT NULL DEFAULT 'bank transfer', CONSTRAINT "PK_34f9b8c6dfb4ac3559f7e2820d1" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "payment_methods"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."payment_methods_type_enum"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."payment_methods_status_enum"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
export enum PaymentMethodType {
|
||||
TRANSFER_BANK = 'bank transfer',
|
||||
E_WALLET = 'e-wallet',
|
||||
EDC = 'edc',
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { PaymentMethodEntity } from '../../domain/entities/payment-method.entity';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
import { PaymentMethodType } from '../../constants';
|
||||
|
||||
@Entity(TABLE_NAME.PAYMENT_METHOD)
|
||||
export class PaymentMethodModel
|
||||
extends BaseStatusModel<PaymentMethodEntity>
|
||||
implements PaymentMethodEntity
|
||||
{
|
||||
@Column('varchar', { name: 'issuer_name' })
|
||||
issuer_name: string;
|
||||
|
||||
@Column('varchar', { name: 'account_number', nullable: true })
|
||||
account_number: string;
|
||||
|
||||
@Column('varchar', { name: 'account_name', nullable: true })
|
||||
account_name: string;
|
||||
|
||||
@Column('varchar', { name: 'qr_image', nullable: true })
|
||||
qr_image: string;
|
||||
|
||||
@Column('varchar', { name: 'note', nullable: true })
|
||||
note: string;
|
||||
|
||||
@Column('enum', {
|
||||
name: 'type',
|
||||
enum: PaymentMethodType,
|
||||
default: PaymentMethodType.TRANSFER_BANK,
|
||||
})
|
||||
type: PaymentMethodType;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||
import { PaymentMethodEntity } from '../../domain/entities/payment-method.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { PaymentMethodModel } from '../models/payment-method.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentMethodDataService extends BaseDataService<PaymentMethodEntity> {
|
||||
constructor(
|
||||
@InjectRepository(PaymentMethodModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<PaymentMethodModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class PaymentMethodChangeStatusEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class PaymentMethodCreatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class PaymentMethodDeletedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class PaymentMethodUpdatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||
import { PaymentMethodType } from '../../constants';
|
||||
|
||||
export interface PaymentMethodEntity extends BaseStatusEntity {
|
||||
issuer_name: string;
|
||||
account_number: string;
|
||||
account_name: string;
|
||||
qr_image: string;
|
||||
type: PaymentMethodType;
|
||||
note: string;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodChangeStatusEvent } from '../../entities/event/payment-method-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ActivePaymentMethodManager extends BaseUpdateStatusManager<PaymentMethodEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.account_name}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodChangeStatusEvent } from '../../entities/event/payment-method-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchActivePaymentMethodManager extends BaseBatchUpdateStatusManager<PaymentMethodEntity> {
|
||||
validateData(data: PaymentMethodEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodChangeStatusEvent } from '../../entities/event/payment-method-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchConfirmPaymentMethodManager extends BaseBatchUpdateStatusManager<PaymentMethodEntity> {
|
||||
validateData(data: PaymentMethodEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodDeletedEvent } from '../../entities/event/payment-method-deleted.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchDeletePaymentMethodManager extends BaseBatchDeleteManager<PaymentMethodEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async validateData(data: PaymentMethodEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodDeletedEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodChangeStatusEvent } from '../../entities/event/payment-method-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchInactivePaymentMethodManager extends BaseBatchUpdateStatusManager<PaymentMethodEntity> {
|
||||
validateData(data: PaymentMethodEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodChangeStatusEvent } from '../../entities/event/payment-method-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ConfirmPaymentMethodManager extends BaseUpdateStatusManager<PaymentMethodEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.account_name}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||
import { PaymentMethodCreatedEvent } from '../../entities/event/payment-method-created.event';
|
||||
|
||||
@Injectable()
|
||||
export class CreatePaymentMethodManager extends BaseCreateManager<PaymentMethodEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [{ column: 'account_number' }, { column: 'account_name' }];
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodCreatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodDeletedEvent } from '../../entities/event/payment-method-deleted.event';
|
||||
|
||||
@Injectable()
|
||||
export class DeletePaymentMethodManager extends BaseDeleteManager<PaymentMethodEntity> {
|
||||
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 PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodDeletedEvent,
|
||||
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 { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodChangeStatusEvent } from '../../entities/event/payment-method-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class InactivePaymentMethodManager extends BaseUpdateStatusManager<PaymentMethodEntity> {
|
||||
getResult(): string {
|
||||
return `Success inactive data ${this.result.account_name}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodChangeStatusEvent,
|
||||
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 { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import { PaymentMethodModel } from '../../../data/models/payment-method.model';
|
||||
import { PaymentMethodUpdatedEvent } from '../../entities/event/payment-method-updated.event';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
@Injectable()
|
||||
export class UpdatePaymentMethodManager extends BaseUpdateManager<PaymentMethodEntity> {
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [{ column: 'account_number' }, { column: 'account_name' }];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return PaymentMethodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: PaymentMethodUpdatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreatePaymentMethodManager } from './managers/create-payment-method.manager';
|
||||
import { PaymentMethodDataService } from '../../data/services/payment-method-data.service';
|
||||
import { PaymentMethodEntity } from '../entities/payment-method.entity';
|
||||
import { DeletePaymentMethodManager } from './managers/delete-payment-method.manager';
|
||||
import { UpdatePaymentMethodManager } from './managers/update-payment-method.manager';
|
||||
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
||||
import { ActivePaymentMethodManager } from './managers/active-payment-method.manager';
|
||||
import { InactivePaymentMethodManager } from './managers/inactive-payment-method.manager';
|
||||
import { ConfirmPaymentMethodManager } from './managers/confirm-payment-method.manager';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchConfirmPaymentMethodManager } from './managers/batch-confirm-payment-method.manager';
|
||||
import { BatchInactivePaymentMethodManager } from './managers/batch-inactive-payment-method.manager';
|
||||
import { BatchActivePaymentMethodManager } from './managers/batch-active-payment-method.manager';
|
||||
import { BatchDeletePaymentMethodManager } from './managers/batch-delete-payment-method.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentMethodDataOrchestrator extends BaseDataTransactionOrchestrator<PaymentMethodEntity> {
|
||||
constructor(
|
||||
private createManager: CreatePaymentMethodManager,
|
||||
private updateManager: UpdatePaymentMethodManager,
|
||||
private deleteManager: DeletePaymentMethodManager,
|
||||
private activeManager: ActivePaymentMethodManager,
|
||||
private confirmManager: ConfirmPaymentMethodManager,
|
||||
private inactiveManager: InactivePaymentMethodManager,
|
||||
private batchDeleteManager: BatchDeletePaymentMethodManager,
|
||||
private batchActiveManager: BatchActivePaymentMethodManager,
|
||||
private batchConfirmManager: BatchConfirmPaymentMethodManager,
|
||||
private batchInactiveManager: BatchInactivePaymentMethodManager,
|
||||
private serviceData: PaymentMethodDataService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async create(data): Promise<PaymentMethodEntity> {
|
||||
this.createManager.setData(data);
|
||||
this.createManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
|
||||
await this.createManager.execute();
|
||||
return this.createManager.getResult();
|
||||
}
|
||||
|
||||
async update(dataId, data): Promise<PaymentMethodEntity> {
|
||||
this.updateManager.setData(dataId, data);
|
||||
this.updateManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
|
||||
await this.updateManager.execute();
|
||||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
|
||||
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.PAYMENT_METHOD,
|
||||
);
|
||||
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.PAYMENT_METHOD);
|
||||
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.PAYMENT_METHOD,
|
||||
);
|
||||
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.PAYMENT_METHOD);
|
||||
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.PAYMENT_METHOD,
|
||||
);
|
||||
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.PAYMENT_METHOD,
|
||||
);
|
||||
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.PAYMENT_METHOD,
|
||||
);
|
||||
await this.batchInactiveManager.execute();
|
||||
return this.batchInactiveManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||
import { PaymentMethodEntity } from '../../domain/entities/payment-method.entity';
|
||||
import { PaymentMethodType } from '../../constants';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString, ValidateIf } from 'class-validator';
|
||||
|
||||
export class PaymentMethodDto
|
||||
extends BaseStatusDto
|
||||
implements PaymentMethodEntity
|
||||
{
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: true,
|
||||
example: PaymentMethodType.TRANSFER_BANK,
|
||||
})
|
||||
@IsString()
|
||||
type: PaymentMethodType;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: true,
|
||||
example: 'BCA',
|
||||
})
|
||||
@IsString()
|
||||
issuer_name: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
example: '1232334235',
|
||||
})
|
||||
@IsString()
|
||||
@ValidateIf((body) => body.account_number)
|
||||
account_number: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
example: 'Skyworld',
|
||||
})
|
||||
@IsString()
|
||||
@ValidateIf((body) => body.account_name)
|
||||
account_name: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
example: '...',
|
||||
})
|
||||
@IsString()
|
||||
@ValidateIf((body) => body.qr_image)
|
||||
qr_image: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
example: 'gate 1',
|
||||
})
|
||||
@IsString()
|
||||
@ValidateIf((body) => body.note)
|
||||
note: string;
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { PaymentMethodDataOrchestrator } from '../domain/usecases/payment-method-data.orchestrator';
|
||||
import { PaymentMethodDto } from './dto/payment-method.dto';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { PaymentMethodEntity } from '../domain/entities/payment-method.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.PAYMENT_METHOD.split('-').join(' ')} - data`)
|
||||
@Controller(MODULE_NAME.PAYMENT_METHOD)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class PaymentMethodDataController {
|
||||
constructor(private orchestrator: PaymentMethodDataOrchestrator) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() data: PaymentMethodDto): Promise<PaymentMethodEntity> {
|
||||
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: PaymentMethodDto,
|
||||
): Promise<PaymentMethodEntity> {
|
||||
return await this.orchestrator.update(dataId, data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { PaymentMethodDataService } from './data/services/payment-method-data.service';
|
||||
import { PaymentMethodReadService } from './data/services/payment-method-read.service';
|
||||
import { PaymentMethodReadController } from './infrastructure/payment-method-read.controller';
|
||||
import { PaymentMethodReadOrchestrator } from './domain/usecases/payment-method-read.orchestrator';
|
||||
import { PaymentMethodDataController } from './infrastructure/payment-method-data.controller';
|
||||
import { PaymentMethodDataOrchestrator } from './domain/usecases/payment-method-data.orchestrator';
|
||||
import { CreatePaymentMethodManager } from './domain/usecases/managers/create-payment-method.manager';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { IndexPaymentMethodManager } from './domain/usecases/managers/index-payment-method.manager';
|
||||
import { DeletePaymentMethodManager } from './domain/usecases/managers/delete-payment-method.manager';
|
||||
import { UpdatePaymentMethodManager } from './domain/usecases/managers/update-payment-method.manager';
|
||||
import { ActivePaymentMethodManager } from './domain/usecases/managers/active-payment-method.manager';
|
||||
import { ConfirmPaymentMethodManager } from './domain/usecases/managers/confirm-payment-method.manager';
|
||||
import { InactivePaymentMethodManager } from './domain/usecases/managers/inactive-payment-method.manager';
|
||||
import { DetailPaymentMethodManager } from './domain/usecases/managers/detail-payment-method.manager';
|
||||
import { BatchDeletePaymentMethodManager } from './domain/usecases/managers/batch-delete-payment-method.manager';
|
||||
import { BatchActivePaymentMethodManager } from './domain/usecases/managers/batch-active-payment-method.manager';
|
||||
import { BatchConfirmPaymentMethodManager } from './domain/usecases/managers/batch-confirm-payment-method.manager';
|
||||
import { BatchInactivePaymentMethodManager } from './domain/usecases/managers/batch-inactive-payment-method.manager';
|
||||
import { PaymentMethodModel } from './data/models/payment-method.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forFeature([PaymentMethodModel], CONNECTION_NAME.DEFAULT),
|
||||
CqrsModule,
|
||||
],
|
||||
controllers: [PaymentMethodDataController, PaymentMethodReadController],
|
||||
providers: [
|
||||
IndexPaymentMethodManager,
|
||||
DetailPaymentMethodManager,
|
||||
CreatePaymentMethodManager,
|
||||
DeletePaymentMethodManager,
|
||||
UpdatePaymentMethodManager,
|
||||
ActivePaymentMethodManager,
|
||||
ConfirmPaymentMethodManager,
|
||||
InactivePaymentMethodManager,
|
||||
BatchDeletePaymentMethodManager,
|
||||
BatchActivePaymentMethodManager,
|
||||
BatchConfirmPaymentMethodManager,
|
||||
BatchInactivePaymentMethodManager,
|
||||
|
||||
PaymentMethodDataService,
|
||||
PaymentMethodReadService,
|
||||
|
||||
PaymentMethodDataOrchestrator,
|
||||
PaymentMethodReadOrchestrator,
|
||||
],
|
||||
})
|
||||
export class PaymentMethodModule {}
|
Loading…
Reference in New Issue