fix(SPG-572) Validasi "Belum memiliki periode season" jika menambahkan harga/item rate pada season yang belum memiliki periode season
parent
1e0766dc50
commit
ced08bebd3
|
@ -1,9 +1,8 @@
|
|||
import { Injectable } from "@nestjs/common";
|
||||
import { HttpStatus, Injectable, UnprocessableEntityException } from "@nestjs/common";
|
||||
import { BaseCustomManager } from "src/core/modules/domain/usecase/managers/base-custom.manager";
|
||||
import { SeasonPeriodEntity } from "../../entities/season-period.entity";
|
||||
import { EventTopics } from "src/core/strings/constants/interface.constants";
|
||||
import { SeasonPeriodModel } from "../../../data/models/season-period.model";
|
||||
import { SeasonPeriodPriceUpdatedHandler } from "../handlers/season-period-price-updated.handler";
|
||||
import { SeasonPeriodPriceUpdatedEvent } from "../../entities/event/season-period-price-updated.event";
|
||||
import { OPERATION } from "src/core/strings/constants/base.constants";
|
||||
|
||||
|
@ -11,6 +10,18 @@ import { OPERATION } from "src/core/strings/constants/base.constants";
|
|||
export class UpdateSeasonPeriodPriceManager extends BaseCustomManager<SeasonPeriodEntity> {
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
const existSeason = await this.dataService.getOneByOptions({
|
||||
where: {
|
||||
season_type_id: this.data.season_period.id
|
||||
}
|
||||
})
|
||||
if (!existSeason) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! There is no season type ${ this.data.season_period.name }`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -19,8 +30,6 @@ export class UpdateSeasonPeriodPriceManager extends BaseCustomManager<SeasonPeri
|
|||
}
|
||||
|
||||
async process(): Promise<void> {
|
||||
// this.publishEvents();
|
||||
|
||||
this.eventBus.publish(
|
||||
new SeasonPeriodPriceUpdatedEvent({
|
||||
id: '',
|
||||
|
@ -48,12 +57,7 @@ export class UpdateSeasonPeriodPriceManager extends BaseCustomManager<SeasonPeri
|
|||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
// {
|
||||
// topic: SeasonPeriodPriceUpdatedEvent,
|
||||
// data: this.data,
|
||||
// }
|
||||
];
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue