feat: add vip pass and video url to item
parent
c0a0b2316d
commit
8f43907091
|
@ -0,0 +1,21 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class ItemVideoAndVipPass1729072422409 implements MigrationInterface {
|
||||
name = 'ItemVideoAndVipPass1729072422409';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "items" ADD "video_url" character varying`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "vip_categories" ADD "has_vip_pass" boolean NOT NULL DEFAULT false`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "vip_categories" DROP COLUMN "has_vip_pass"`,
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "video_url"`);
|
||||
}
|
||||
}
|
|
@ -28,6 +28,9 @@ export class ItemModel
|
|||
@Column('varchar', { name: 'image_url', nullable: true })
|
||||
image_url: string;
|
||||
|
||||
@Column('varchar', { nullable: true })
|
||||
video_url: string;
|
||||
|
||||
@Column('enum', {
|
||||
name: 'item_type',
|
||||
enum: ItemType,
|
||||
|
|
|
@ -6,6 +6,7 @@ export interface ItemEntity extends BaseStatusEntity {
|
|||
name: string;
|
||||
item_type: ItemType;
|
||||
image_url: string;
|
||||
video_url?: string;
|
||||
|
||||
hpp: number;
|
||||
sales_margin: number;
|
||||
|
|
|
@ -31,6 +31,15 @@ export class ItemDto extends BaseStatusDto implements ItemEntity {
|
|||
@ValidateIf((body) => body.image)
|
||||
image_url: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
example: '...',
|
||||
})
|
||||
@IsString()
|
||||
@ValidateIf((body) => body.video_url)
|
||||
video_url: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: 'string',
|
||||
required: true,
|
||||
|
|
|
@ -12,6 +12,9 @@ export class VipCategoryModel
|
|||
@Column('varchar', { name: 'name' })
|
||||
name: string;
|
||||
|
||||
@Column('boolean', { default: false })
|
||||
has_vip_pass: boolean;
|
||||
|
||||
@OneToMany(() => VipCodeModel, (model) => model.vip_category, {
|
||||
cascade: true,
|
||||
onDelete: 'CASCADE',
|
||||
|
|
|
@ -2,4 +2,5 @@ import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.e
|
|||
|
||||
export interface VipCategoryEntity extends BaseStatusEntity {
|
||||
name: string;
|
||||
has_vip_pass?: boolean;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.d
|
|||
import { VipCategoryEntity } from '../../domain/entities/vip-category.entity';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString } from 'class-validator';
|
||||
import { boolean } from 'mathjs';
|
||||
|
||||
export class VipCategoryDto extends BaseStatusDto implements VipCategoryEntity {
|
||||
@ApiProperty({
|
||||
|
@ -12,4 +13,12 @@ export class VipCategoryDto extends BaseStatusDto implements VipCategoryEntity {
|
|||
})
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@ApiProperty({
|
||||
name: 'has_vip_pass',
|
||||
type: boolean,
|
||||
required: false,
|
||||
example: false,
|
||||
})
|
||||
has_vip_pass: boolean;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue