feat(SPG-353) REST API CUD Season Period
parent
5b5c3efccc
commit
54c5738676
|
@ -37,6 +37,11 @@ import { SalesPriceFormulaModel } from './modules/transaction/sales-price-formul
|
|||
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';
|
||||
import { SeasonPeriodModule } from './modules/season-related/season-period/season-period.module';
|
||||
import { SeasonPeriodModel } from './modules/season-related/season-period/data/models/season-period.model';
|
||||
import { ItemRateModule } from './modules/item-related/item-rate/item-rate.module';
|
||||
import { ItemRateModel } from './modules/item-related/item-rate/data/models/item-rate.model';
|
||||
import { GoogleCalendarModule } from './modules/configuration/google-calendar/google-calendar.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -57,9 +62,11 @@ import { PaymentMethodModel } from './modules/transaction/payment-method/data/mo
|
|||
ErrorLogModel,
|
||||
ItemModel,
|
||||
ItemCategoryModel,
|
||||
ItemRateModel,
|
||||
LogModel,
|
||||
PaymentMethodModel,
|
||||
SalesPriceFormulaModel,
|
||||
SeasonPeriodModel,
|
||||
SeasonTypeModel,
|
||||
TaxModel,
|
||||
UserModel,
|
||||
|
@ -68,12 +75,13 @@ import { PaymentMethodModel } from './modules/transaction/payment-method/data/mo
|
|||
],
|
||||
synchronize: false,
|
||||
}),
|
||||
AuthModule,
|
||||
ConstantModule,
|
||||
CqrsModule,
|
||||
SessionModule,
|
||||
AuthModule,
|
||||
CouchModule,
|
||||
GoogleCalendarModule,
|
||||
LogModule,
|
||||
SessionModule,
|
||||
|
||||
// user
|
||||
TenantModule,
|
||||
|
@ -83,6 +91,7 @@ import { PaymentMethodModel } from './modules/transaction/payment-method/data/mo
|
|||
// Item
|
||||
ItemCategoryModule,
|
||||
ItemModule,
|
||||
ItemRateModule,
|
||||
|
||||
// transaction
|
||||
PaymentMethodModule,
|
||||
|
@ -94,6 +103,7 @@ import { PaymentMethodModel } from './modules/transaction/payment-method/data/mo
|
|||
|
||||
// session
|
||||
SeasonTypeModule,
|
||||
SeasonPeriodModule,
|
||||
],
|
||||
controllers: [],
|
||||
providers: [
|
||||
|
|
|
@ -21,6 +21,15 @@ export abstract class BaseDataService<Entity> {
|
|||
return await queryRunner.manager.save(newEntity);
|
||||
}
|
||||
|
||||
async createBatch(
|
||||
queryRunner: QueryRunner,
|
||||
entityTarget: EntityTarget<Entity>,
|
||||
entity: Entity[],
|
||||
): Promise<Entity[]> {
|
||||
const newEntity = queryRunner.manager.create(entityTarget, entity);
|
||||
return await queryRunner.manager.save(newEntity);
|
||||
}
|
||||
|
||||
async update(
|
||||
queryRunner: QueryRunner,
|
||||
entityTarget: EntityTarget<Entity>,
|
||||
|
|
|
@ -73,6 +73,19 @@ export abstract class BaseCreateManager<Entity> extends BaseManager {
|
|||
}),
|
||||
);
|
||||
|
||||
// if (!this.eventTopics.length) return;
|
||||
if (!this.eventTopics.length) return;
|
||||
for (const topic of this.eventTopics) {
|
||||
this.eventBus.publishAll([
|
||||
new topic.topic({
|
||||
id: this.result['id'],
|
||||
old: null,
|
||||
data: topic.data,
|
||||
user: this.user,
|
||||
description: '',
|
||||
module: this.tableName,
|
||||
op: OPERATION.CREATE,
|
||||
}),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
export enum MODULE_NAME {
|
||||
ITEM = 'items',
|
||||
ITEM_CATEGORY = 'item-categories',
|
||||
ITEM_RATE = 'item-rates',
|
||||
PAYMENT_METHOD = 'payment-methods',
|
||||
SEASON_TYPE = 'season-types',
|
||||
SEASON_PERIOD = 'season-periods',
|
||||
TAX = 'taxes',
|
||||
TENANT = 'tenants',
|
||||
USER = 'users',
|
||||
|
|
|
@ -2,10 +2,12 @@ export enum TABLE_NAME {
|
|||
ERROR_LOG = 'log_errors',
|
||||
ITEM = 'items',
|
||||
ITEM_CATEGORY = 'item_categories',
|
||||
ITEM_RATE = 'item_rates',
|
||||
LOG = 'logs',
|
||||
PAYMENT_METHOD = 'payment_methods',
|
||||
PRICE_FORMULA = 'price_formulas',
|
||||
SEASON_TYPE = 'season_types',
|
||||
SEASON_PERIOD = 'season_periods',
|
||||
TAX = 'taxes',
|
||||
TENANT = 'tenants',
|
||||
USER = 'users',
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class UpdateColumnTax1718675739425 implements MigrationInterface {
|
||||
name = 'UpdateColumnTax1718675739425'
|
||||
name = 'UpdateColumnTax1718675739425';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "taxes" DROP COLUMN "value"`);
|
||||
await queryRunner.query(`ALTER TABLE "taxes" ADD "value" double precision NOT NULL DEFAULT '0'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "taxes" DROP COLUMN "value"`);
|
||||
await queryRunner.query(`ALTER TABLE "taxes" ADD "value" integer NOT NULL DEFAULT '0'`);
|
||||
}
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "taxes" DROP COLUMN "value"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "taxes" ADD "value" double precision NOT NULL DEFAULT '0'`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "taxes" DROP COLUMN "value"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "taxes" ADD "value" integer NOT NULL DEFAULT '0'`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class SeasonPeriod1718699373958 implements MigrationInterface {
|
||||
name = 'SeasonPeriod1718699373958';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."season_periods_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "season_periods" ("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"."season_periods_status_enum" NOT NULL DEFAULT 'draft', "start_date" date, "end_date" date, "days" text, "holiday_name" character varying, "season_type_id" uuid, CONSTRAINT "PK_8e25cedd8ffb18516de871fb4e0" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "season_periods" ADD CONSTRAINT "FK_4e9e71a640b450d23177c2add46" FOREIGN KEY ("season_type_id") REFERENCES "season_types"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "season_periods" DROP CONSTRAINT "FK_4e9e71a640b450d23177c2add46"`,
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "season_periods"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."season_periods_status_enum"`);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
export enum EnumDays {
|
||||
MONDAY = 'senin',
|
||||
TUESDAY = 'selasa',
|
||||
WEDNESDAY = 'rabu',
|
||||
THURSDAY = 'kamis',
|
||||
FRIDAY = 'jumat',
|
||||
SATURDAY = 'sabtu',
|
||||
SUNDAY = 'minggu',
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { SeasonPeriodEntity } from '../../domain/entities/season-period.entity';
|
||||
import { Column, Entity, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
import { EnumDays } from '../../constants';
|
||||
import { SeasonTypeModel } from 'src/modules/season-related/season-type/data/models/season-type.model';
|
||||
import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/item-rate.model';
|
||||
|
||||
@Entity(TABLE_NAME.SEASON_PERIOD)
|
||||
export class SeasonPeriodModel
|
||||
extends BaseStatusModel<SeasonPeriodEntity>
|
||||
implements SeasonPeriodEntity
|
||||
{
|
||||
@Column('date', { name: 'start_date', nullable: true })
|
||||
start_date: Date;
|
||||
|
||||
@Column('date', { name: 'end_date', nullable: true })
|
||||
end_date: Date;
|
||||
|
||||
@Column('simple-array', { name: 'days', nullable: true })
|
||||
days: EnumDays[];
|
||||
|
||||
@Column('varchar', { name: 'holiday_name', nullable: true })
|
||||
holiday_name: string;
|
||||
|
||||
@Column('varchar', { name: 'season_type_id', nullable: true })
|
||||
season_type_id: string;
|
||||
@ManyToOne(() => SeasonTypeModel, (model) => model.season_periods, {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'season_type_id' })
|
||||
season_type: SeasonTypeModel;
|
||||
|
||||
// relasi ke item rates
|
||||
@OneToMany(() => ItemRateModel, (model) => model.season_period, {
|
||||
cascade: true,
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
item_rates: ItemRateModel[];
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||
import { SeasonPeriodEntity } from '../../domain/entities/season-period.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { SeasonPeriodModel } from '../models/season-period.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class SeasonPeriodDataService extends BaseDataService<SeasonPeriodEntity> {
|
||||
constructor(
|
||||
@InjectRepository(SeasonPeriodModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<SeasonPeriodModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class SeasonPeriodChangeStatusEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class SeasonPeriodCreatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class SeasonPeriodDeletedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
export class SeasonPeriodUpdatedEvent {
|
||||
constructor(public readonly data: IEvent) {}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||
import { EnumDays } from '../../constants';
|
||||
|
||||
export interface SeasonPeriodEntity extends BaseStatusEntity {
|
||||
start_date: Date;
|
||||
end_date: Date;
|
||||
days: EnumDays[];
|
||||
holiday_name: string;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
||||
import { SeasonPeriodCreatedEvent } from '../../entities/event/season-period-created.event';
|
||||
import { SeasonPeriodDataService } from '../../../data/services/season-period-data.service';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
|
||||
@EventsHandler(SeasonPeriodCreatedEvent)
|
||||
export class SeasonPeriodHolidayHandler
|
||||
implements IEventHandler<SeasonPeriodCreatedEvent>
|
||||
{
|
||||
constructor(private dataService: SeasonPeriodDataService) {}
|
||||
|
||||
async handle(event: SeasonPeriodCreatedEvent) {
|
||||
const queryRunner = this.dataService
|
||||
.getRepository()
|
||||
.manager.connection.createQueryRunner();
|
||||
const holidayDates = [];
|
||||
|
||||
if (event.data.data.holidays?.length) {
|
||||
// foreach holiday
|
||||
for (const holiday of event.data.data.holidays) {
|
||||
const holidayDate = new SeasonPeriodModel();
|
||||
|
||||
holidayDate.holiday_name = holiday.holiday_name;
|
||||
holidayDate.start_date = holiday.start_date;
|
||||
holidayDate.end_date = holiday.end_date;
|
||||
holidayDate.created_at = event.data.data.created_at;
|
||||
holidayDate.creator_id = event.data.data.creator_id;
|
||||
holidayDate.creator_name = event.data.data.creator_name;
|
||||
holidayDate.updated_at = event.data.data.updated_at;
|
||||
holidayDate.season_type = event.data.data.season_type;
|
||||
holidayDate.item_rates = event.data.data.item_rates;
|
||||
|
||||
holidayDates.push(holidayDate);
|
||||
}
|
||||
|
||||
// create batch
|
||||
await this.dataService.createBatch(
|
||||
queryRunner,
|
||||
SeasonPeriodModel,
|
||||
holidayDates,
|
||||
);
|
||||
|
||||
// delete data
|
||||
await this.dataService.deleteById(
|
||||
queryRunner,
|
||||
SeasonPeriodModel,
|
||||
event.data.id,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodChangeStatusEvent } from '../../entities/event/season-period-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ActiveSeasonPeriodManager extends BaseUpdateStatusManager<SeasonPeriodEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.id}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodChangeStatusEvent } from '../../entities/event/season-period-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchActiveSeasonPeriodManager extends BaseBatchUpdateStatusManager<SeasonPeriodEntity> {
|
||||
validateData(data: SeasonPeriodEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodChangeStatusEvent } from '../../entities/event/season-period-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchConfirmSeasonPeriodManager extends BaseBatchUpdateStatusManager<SeasonPeriodEntity> {
|
||||
validateData(data: SeasonPeriodEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
||||
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodDeletedEvent } from '../../entities/event/season-period-deleted.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchDeleteSeasonPeriodManager extends BaseBatchDeleteManager<SeasonPeriodEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async validateData(data: SeasonPeriodEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodDeletedEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodChangeStatusEvent } from '../../entities/event/season-period-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchInactiveSeasonPeriodManager extends BaseBatchUpdateStatusManager<SeasonPeriodEntity> {
|
||||
validateData(data: SeasonPeriodEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodChangeStatusEvent } from '../../entities/event/season-period-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ConfirmSeasonPeriodManager extends BaseUpdateStatusManager<SeasonPeriodEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.id}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
||||
import { SeasonPeriodCreatedEvent } from '../../entities/event/season-period-created.event';
|
||||
|
||||
@Injectable()
|
||||
export class CreateSeasonPeriodManager extends BaseCreateManager<SeasonPeriodEntity> {
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodCreatedEvent,
|
||||
data: {
|
||||
...this.data,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return SeasonPeriodModel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodDeletedEvent } from '../../entities/event/season-period-deleted.event';
|
||||
|
||||
@Injectable()
|
||||
export class DeleteSeasonPeriodManager extends BaseDeleteManager<SeasonPeriodEntity> {
|
||||
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 SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodDeletedEvent,
|
||||
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 { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodChangeStatusEvent } from '../../entities/event/season-period-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class InactiveSeasonPeriodManager extends BaseUpdateStatusManager<SeasonPeriodEntity> {
|
||||
getResult(): string {
|
||||
return `Success inactive data ${this.result.id}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodChangeStatusEvent,
|
||||
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 { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||
import { SeasonPeriodModel } from '../../../data/models/season-period.model';
|
||||
import { SeasonPeriodUpdatedEvent } from '../../entities/event/season-period-updated.event';
|
||||
import {
|
||||
EventTopics,
|
||||
columnUniques,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
|
||||
@Injectable()
|
||||
export class UpdateSeasonPeriodManager extends BaseUpdateManager<SeasonPeriodEntity> {
|
||||
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 SeasonPeriodModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: SeasonPeriodUpdatedEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateSeasonPeriodManager } from './managers/create-season-period.manager';
|
||||
import { SeasonPeriodDataService } from '../../data/services/season-period-data.service';
|
||||
import { SeasonPeriodEntity } from '../entities/season-period.entity';
|
||||
import { DeleteSeasonPeriodManager } from './managers/delete-season-period.manager';
|
||||
import { UpdateSeasonPeriodManager } from './managers/update-season-period.manager';
|
||||
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
||||
import { ActiveSeasonPeriodManager } from './managers/active-season-period.manager';
|
||||
import { InactiveSeasonPeriodManager } from './managers/inactive-season-period.manager';
|
||||
import { ConfirmSeasonPeriodManager } from './managers/confirm-season-period.manager';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BatchConfirmSeasonPeriodManager } from './managers/batch-confirm-season-period.manager';
|
||||
import { BatchInactiveSeasonPeriodManager } from './managers/batch-inactive-season-period.manager';
|
||||
import { BatchActiveSeasonPeriodManager } from './managers/batch-active-season-period.manager';
|
||||
import { BatchDeleteSeasonPeriodManager } from './managers/batch-delete-season-period.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class SeasonPeriodDataOrchestrator extends BaseDataTransactionOrchestrator<SeasonPeriodEntity> {
|
||||
constructor(
|
||||
private createManager: CreateSeasonPeriodManager,
|
||||
private updateManager: UpdateSeasonPeriodManager,
|
||||
private deleteManager: DeleteSeasonPeriodManager,
|
||||
private activeManager: ActiveSeasonPeriodManager,
|
||||
private confirmManager: ConfirmSeasonPeriodManager,
|
||||
private inactiveManager: InactiveSeasonPeriodManager,
|
||||
private batchDeleteManager: BatchDeleteSeasonPeriodManager,
|
||||
private batchActiveManager: BatchActiveSeasonPeriodManager,
|
||||
private batchConfirmManager: BatchConfirmSeasonPeriodManager,
|
||||
private batchInactiveManager: BatchInactiveSeasonPeriodManager,
|
||||
private serviceData: SeasonPeriodDataService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async create(data): Promise<SeasonPeriodEntity> {
|
||||
this.createManager.setData(data);
|
||||
this.createManager.setService(this.serviceData, TABLE_NAME.SEASON_PERIOD);
|
||||
await this.createManager.execute();
|
||||
return this.createManager.getResult();
|
||||
}
|
||||
|
||||
async update(dataId, data): Promise<SeasonPeriodEntity> {
|
||||
this.updateManager.setData(dataId, data);
|
||||
this.updateManager.setService(this.serviceData, TABLE_NAME.SEASON_PERIOD);
|
||||
await this.updateManager.execute();
|
||||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.SEASON_PERIOD);
|
||||
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.SEASON_PERIOD,
|
||||
);
|
||||
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.SEASON_PERIOD);
|
||||
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.SEASON_PERIOD,
|
||||
);
|
||||
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.SEASON_PERIOD);
|
||||
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.SEASON_PERIOD,
|
||||
);
|
||||
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.SEASON_PERIOD);
|
||||
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.SEASON_PERIOD,
|
||||
);
|
||||
await this.batchInactiveManager.execute();
|
||||
return this.batchInactiveManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class SeasonPeriodHolidayDto {
|
||||
@ApiProperty({
|
||||
type: Date,
|
||||
required: true,
|
||||
example: '01/01/2024',
|
||||
})
|
||||
start_date: Date;
|
||||
|
||||
@ApiProperty({
|
||||
type: Date,
|
||||
required: true,
|
||||
example: '30/12/2024',
|
||||
})
|
||||
end_date: Date;
|
||||
|
||||
@ApiProperty({
|
||||
type: Date,
|
||||
required: true,
|
||||
example: 'Hari Raya',
|
||||
})
|
||||
holiday_name: string;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||
import { SeasonPeriodEntity } from '../../domain/entities/season-period.entity';
|
||||
import { EnumDays } from '../../constants';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsObject, ValidateIf, ValidateNested } from 'class-validator';
|
||||
import { Exclude } from 'class-transformer';
|
||||
import { SeasonTypeModel } from 'src/modules/season-related/season-type/data/models/season-type.model';
|
||||
import { SeasonPeriodHolidayDto } from './season-period-holiday.dto';
|
||||
import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/item-rate.model';
|
||||
import { ItemDto } from 'src/modules/item-related/item/infrastructure/dto/item.dto';
|
||||
|
||||
export class SeasonPeriodDto
|
||||
extends BaseStatusDto
|
||||
implements SeasonPeriodEntity
|
||||
{
|
||||
@ApiProperty({
|
||||
type: Object,
|
||||
required: true,
|
||||
example: {
|
||||
id: 'uuid',
|
||||
name: 'High Season',
|
||||
},
|
||||
})
|
||||
@IsObject()
|
||||
season_type: SeasonTypeModel;
|
||||
|
||||
@ApiProperty({
|
||||
type: Date,
|
||||
required: true,
|
||||
example: '2024/01/01',
|
||||
})
|
||||
start_date: Date;
|
||||
|
||||
@ApiProperty({
|
||||
type: Date,
|
||||
required: true,
|
||||
example: '2024/12/30',
|
||||
})
|
||||
end_date: Date;
|
||||
|
||||
@ApiProperty({
|
||||
type: [String],
|
||||
required: false,
|
||||
example: [EnumDays.FRIDAY, EnumDays.MONDAY],
|
||||
})
|
||||
@ValidateIf((body) => body.days)
|
||||
days: EnumDays[];
|
||||
|
||||
@ApiProperty({
|
||||
type: [SeasonPeriodHolidayDto],
|
||||
required: false,
|
||||
example: [
|
||||
{
|
||||
start_date: '2024/01/01',
|
||||
end_date: '2024/12/30',
|
||||
holiday_name: 'Hari Raya',
|
||||
},
|
||||
],
|
||||
})
|
||||
@ValidateNested({ each: true })
|
||||
@ValidateIf((body) => body.holidays)
|
||||
holidays: SeasonPeriodHolidayDto[];
|
||||
|
||||
@Exclude()
|
||||
holiday_name: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: [Object],
|
||||
example: [
|
||||
{
|
||||
item: {
|
||||
id: 'uuid',
|
||||
name: 'Entrance Ticket',
|
||||
},
|
||||
price: 10000,
|
||||
},
|
||||
],
|
||||
})
|
||||
item_rates: ItemRateModel[];
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||
import { SeasonPeriodEntity } from '../../domain/entities/season-period.entity';
|
||||
import { EnumDays } from '../../constants';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsObject, ValidateIf, ValidateNested } from 'class-validator';
|
||||
import { Exclude } from 'class-transformer';
|
||||
import { SeasonTypeModel } from 'src/modules/season-related/season-type/data/models/season-type.model';
|
||||
import { SeasonPeriodHolidayDto } from './season-period-holiday.dto';
|
||||
import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/item-rate.model';
|
||||
|
||||
export class UpdateSeasonPeriodItemDto
|
||||
extends BaseStatusDto
|
||||
implements SeasonPeriodEntity
|
||||
{
|
||||
@Exclude()
|
||||
season_type: SeasonTypeModel;
|
||||
|
||||
@Exclude()
|
||||
start_date: Date;
|
||||
|
||||
@Exclude()
|
||||
end_date: Date;
|
||||
|
||||
@Exclude()
|
||||
days: EnumDays[];
|
||||
|
||||
@Exclude()
|
||||
holidays: SeasonPeriodHolidayDto[];
|
||||
|
||||
@Exclude()
|
||||
holiday_name: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: [Object],
|
||||
example: [
|
||||
{
|
||||
item: {
|
||||
id: 'uuid',
|
||||
name: 'Entrance Ticket',
|
||||
},
|
||||
price: 10000,
|
||||
},
|
||||
],
|
||||
})
|
||||
item_rates: ItemRateModel[];
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
||||
import { SeasonPeriodEntity } from '../../domain/entities/season-period.entity';
|
||||
import { EnumDays } from '../../constants';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsObject, ValidateIf } from 'class-validator';
|
||||
import { SeasonTypeModel } from 'src/modules/season-related/season-type/data/models/season-type.model';
|
||||
import { Exclude } from 'class-transformer';
|
||||
import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/item-rate.model';
|
||||
import { SeasonPeriodHolidayDto } from './season-period-holiday.dto';
|
||||
|
||||
export class UpdateSeasonPeriodDto
|
||||
extends BaseStatusDto
|
||||
implements SeasonPeriodEntity
|
||||
{
|
||||
@ApiProperty({
|
||||
type: Object,
|
||||
required: true,
|
||||
example: {
|
||||
id: 'uuid',
|
||||
name: 'High Season',
|
||||
},
|
||||
})
|
||||
@IsObject()
|
||||
season_type: SeasonTypeModel;
|
||||
|
||||
@ApiProperty({
|
||||
type: Date,
|
||||
required: true,
|
||||
example: '01/01/2024',
|
||||
})
|
||||
start_date: Date;
|
||||
|
||||
@ApiProperty({
|
||||
type: Date,
|
||||
required: true,
|
||||
example: '30/12/2024',
|
||||
})
|
||||
end_date: Date;
|
||||
|
||||
@ApiProperty({
|
||||
type: [String],
|
||||
required: false,
|
||||
example: [EnumDays.FRIDAY, EnumDays.MONDAY],
|
||||
})
|
||||
@ValidateIf((body) => body.days)
|
||||
days: EnumDays[];
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
example: 'Hari Raya',
|
||||
})
|
||||
holiday_name: string;
|
||||
|
||||
@Exclude()
|
||||
holidays: SeasonPeriodHolidayDto[];
|
||||
|
||||
@Exclude()
|
||||
item_rates: any[];
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
Get,
|
||||
} from '@nestjs/common';
|
||||
import { SeasonPeriodDataOrchestrator } from '../domain/usecases/season-period-data.orchestrator';
|
||||
import { SeasonPeriodDto } from './dto/season-period.dto';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { SeasonPeriodEntity } from '../domain/entities/season-period.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';
|
||||
import { UpdateSeasonPeriodDto } from './dto/update-season-period.dto';
|
||||
import { UpdateSeasonPeriodItemDto } from './dto/update-season-period-item.dto';
|
||||
|
||||
@ApiTags(`${MODULE_NAME.SEASON_PERIOD.split('-').join(' ')} - data`)
|
||||
@Controller(MODULE_NAME.SEASON_PERIOD)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class SeasonPeriodDataController {
|
||||
constructor(private orchestrator: SeasonPeriodDataOrchestrator) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() data: SeasonPeriodDto): Promise<SeasonPeriodEntity> {
|
||||
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: UpdateSeasonPeriodDto,
|
||||
): Promise<SeasonPeriodEntity> {
|
||||
return await this.orchestrator.update(dataId, data);
|
||||
}
|
||||
|
||||
@Put(':id/items')
|
||||
async updateItems(
|
||||
@Param('id') dataId: string,
|
||||
@Body() data: UpdateSeasonPeriodItemDto,
|
||||
): Promise<SeasonPeriodEntity> {
|
||||
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,57 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { SeasonPeriodDataService } from './data/services/season-period-data.service';
|
||||
import { SeasonPeriodReadService } from './data/services/season-period-read.service';
|
||||
import { SeasonPeriodReadController } from './infrastructure/season-period-read.controller';
|
||||
import { SeasonPeriodReadOrchestrator } from './domain/usecases/season-period-read.orchestrator';
|
||||
import { SeasonPeriodDataController } from './infrastructure/season-period-data.controller';
|
||||
import { SeasonPeriodDataOrchestrator } from './domain/usecases/season-period-data.orchestrator';
|
||||
import { CreateSeasonPeriodManager } from './domain/usecases/managers/create-season-period.manager';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { IndexSeasonPeriodManager } from './domain/usecases/managers/index-season-period.manager';
|
||||
import { DeleteSeasonPeriodManager } from './domain/usecases/managers/delete-season-period.manager';
|
||||
import { UpdateSeasonPeriodManager } from './domain/usecases/managers/update-season-period.manager';
|
||||
import { ActiveSeasonPeriodManager } from './domain/usecases/managers/active-season-period.manager';
|
||||
import { ConfirmSeasonPeriodManager } from './domain/usecases/managers/confirm-season-period.manager';
|
||||
import { InactiveSeasonPeriodManager } from './domain/usecases/managers/inactive-season-period.manager';
|
||||
import { DetailSeasonPeriodManager } from './domain/usecases/managers/detail-season-period.manager';
|
||||
import { BatchDeleteSeasonPeriodManager } from './domain/usecases/managers/batch-delete-season-period.manager';
|
||||
import { BatchActiveSeasonPeriodManager } from './domain/usecases/managers/batch-active-season-period.manager';
|
||||
import { BatchConfirmSeasonPeriodManager } from './domain/usecases/managers/batch-confirm-season-period.manager';
|
||||
import { BatchInactiveSeasonPeriodManager } from './domain/usecases/managers/batch-inactive-season-period.manager';
|
||||
import { SeasonPeriodModel } from './data/models/season-period.model';
|
||||
import { SeasonPeriodHolidayHandler } from './domain/usecases/handlers/season-period-created.handler';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forFeature([SeasonPeriodModel], CONNECTION_NAME.DEFAULT),
|
||||
CqrsModule,
|
||||
],
|
||||
controllers: [SeasonPeriodDataController, SeasonPeriodReadController],
|
||||
providers: [
|
||||
SeasonPeriodHolidayHandler,
|
||||
|
||||
IndexSeasonPeriodManager,
|
||||
DetailSeasonPeriodManager,
|
||||
CreateSeasonPeriodManager,
|
||||
DeleteSeasonPeriodManager,
|
||||
UpdateSeasonPeriodManager,
|
||||
ActiveSeasonPeriodManager,
|
||||
ConfirmSeasonPeriodManager,
|
||||
InactiveSeasonPeriodManager,
|
||||
BatchDeleteSeasonPeriodManager,
|
||||
BatchActiveSeasonPeriodManager,
|
||||
BatchConfirmSeasonPeriodManager,
|
||||
BatchInactiveSeasonPeriodManager,
|
||||
|
||||
SeasonPeriodDataService,
|
||||
SeasonPeriodReadService,
|
||||
|
||||
SeasonPeriodDataOrchestrator,
|
||||
SeasonPeriodReadOrchestrator,
|
||||
],
|
||||
})
|
||||
export class SeasonPeriodModule {}
|
|
@ -1,7 +1,8 @@
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { SeasonTypeEntity } from '../../domain/entities/season-type.entity';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
import { SeasonPeriodModel } from 'src/modules/season-related/season-period/data/models/season-period.model';
|
||||
|
||||
@Entity(TABLE_NAME.SEASON_TYPE)
|
||||
export class SeasonTypeModel
|
||||
|
@ -10,4 +11,10 @@ export class SeasonTypeModel
|
|||
{
|
||||
@Column('varchar', { name: 'name' })
|
||||
name: string;
|
||||
|
||||
@OneToMany(() => SeasonPeriodModel, (model) => model.season_type, {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
season_periods: SeasonPeriodModel[];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue