feat: add usage_type field to items and item_queues with corresponding database migration
parent
a5da557dd9
commit
a77e6b0381
|
@ -0,0 +1,29 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddUsageTypeToItem1750319148269 implements MigrationInterface {
|
||||
name = 'AddUsageTypeToItem1750319148269';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."item_queues_usage_type_enum" AS ENUM('one_time', 'multiple')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_queues" ADD "usage_type" "public"."item_queues_usage_type_enum" NOT NULL DEFAULT 'one_time'`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."items_usage_type_enum" AS ENUM('one_time', 'multiple')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ADD "usage_type" "public"."items_usage_type_enum" NOT NULL DEFAULT 'one_time'`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "usage_type"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."items_usage_type_enum"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "item_queues" DROP COLUMN "usage_type"`,
|
||||
);
|
||||
await queryRunner.query(`DROP TYPE "public"."item_queues_usage_type_enum"`);
|
||||
}
|
||||
}
|
|
@ -5,3 +5,8 @@ export enum ItemType {
|
|||
FREE_GIFT = 'free gift',
|
||||
OTHER = 'other',
|
||||
}
|
||||
|
||||
export enum UsageType {
|
||||
ONE_TIME = 'one_time',
|
||||
MULTIPLE = 'multiple',
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|||
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
|
||||
import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||
import { ItemType } from '../../constants';
|
||||
import { ItemType, UsageType } from '../../constants';
|
||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
||||
|
||||
@Entity(TABLE_NAME.ITEM_QUEUE)
|
||||
|
@ -29,6 +29,13 @@ export class ItemQueueModel
|
|||
})
|
||||
item_type: ItemType;
|
||||
|
||||
@Column('enum', {
|
||||
name: 'usage_type',
|
||||
enum: UsageType,
|
||||
default: UsageType.ONE_TIME,
|
||||
})
|
||||
usage_type: UsageType;
|
||||
|
||||
@OneToMany(() => ItemModel, (model) => model.item_queue, {
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||
import { ItemType } from '../../constants';
|
||||
import { ItemType, UsageType } from '../../constants';
|
||||
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
|
||||
|
||||
export interface ItemQueueEntity extends BaseStatusEntity {
|
||||
|
@ -11,4 +11,5 @@ export interface ItemQueueEntity extends BaseStatusEntity {
|
|||
items: ItemEntity[];
|
||||
use_notification?: boolean;
|
||||
requiring_notification?: boolean;
|
||||
usage_type?: UsageType;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ export class DetailItemQueueManager extends BaseDetailManager<ItemQueueEntity> {
|
|||
`${this.tableName}.call_preparation`,
|
||||
`${this.tableName}.use_notification`,
|
||||
`${this.tableName}.requiring_notification`,
|
||||
`${this.tableName}.usage_type`,
|
||||
|
||||
`items.id`,
|
||||
`items.created_at`,
|
||||
|
|
|
@ -43,7 +43,7 @@ export class IndexItemQueueManager extends BaseIndexManager<ItemQueueEntity> {
|
|||
`${this.tableName}.call_preparation`,
|
||||
`${this.tableName}.use_notification`,
|
||||
`${this.tableName}.requiring_notification`,
|
||||
|
||||
`${this.tableName}.usage_type`,
|
||||
`items.id`,
|
||||
`items.created_at`,
|
||||
`items.status`,
|
||||
|
|
|
@ -18,6 +18,7 @@ import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/it
|
|||
import { GateModel } from 'src/modules/web-information/gate/data/models/gate.model';
|
||||
import { ItemQueueModel } from 'src/modules/item-related/item-queue/data/models/item-queue.model';
|
||||
import { TimeGroupModel } from 'src/modules/item-related/time-group/data/models/time-group.model';
|
||||
import { UsageType } from 'src/modules/item-related/item-queue/constants';
|
||||
|
||||
@Entity(TABLE_NAME.ITEM)
|
||||
export class ItemModel
|
||||
|
@ -43,6 +44,13 @@ export class ItemModel
|
|||
})
|
||||
item_type: ItemType;
|
||||
|
||||
@Column('enum', {
|
||||
name: 'usage_type',
|
||||
enum: UsageType,
|
||||
default: UsageType.ONE_TIME,
|
||||
})
|
||||
usage_type: UsageType;
|
||||
|
||||
@Column('bigint', { name: 'hpp', nullable: true })
|
||||
hpp: number;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.e
|
|||
import { ItemType } from 'src/modules/item-related/item-category/constants';
|
||||
import { LimitType } from '../../constants';
|
||||
import { ItemRateEntity } from 'src/modules/item-related/item-rate/domain/entities/item-rate.entity';
|
||||
|
||||
import { UsageType } from 'src/modules/item-related/item-queue/constants';
|
||||
export interface ItemEntity extends BaseStatusEntity {
|
||||
name: string;
|
||||
item_type: ItemType;
|
||||
|
@ -20,6 +20,7 @@ export interface ItemEntity extends BaseStatusEntity {
|
|||
show_to_booking: boolean;
|
||||
breakdown_bundling?: boolean;
|
||||
booking_description?: string;
|
||||
usage_type?: UsageType;
|
||||
|
||||
item_rates?: ItemRateEntity[] | any[];
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
|
|||
`${this.tableName}.total_price`,
|
||||
`${this.tableName}.base_price`,
|
||||
`${this.tableName}.use_queue`,
|
||||
`${this.tableName}.usage_type`,
|
||||
`${this.tableName}.show_to_booking`,
|
||||
`${this.tableName}.breakdown_bundling`,
|
||||
`${this.tableName}.play_estimation`,
|
||||
|
|
|
@ -55,6 +55,7 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
|
|||
`${this.tableName}.play_estimation`,
|
||||
`${this.tableName}.show_to_booking`,
|
||||
`${this.tableName}.booking_description`,
|
||||
`${this.tableName}.usage_type`,
|
||||
|
||||
`item_category.id`,
|
||||
`item_category.name`,
|
||||
|
|
Loading…
Reference in New Issue