add: add modules entity
This commit is contained in:
33
src/product/entities/product.entity.ts
Normal file
33
src/product/entities/product.entity.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
VersionColumn,
|
||||
CreateDateColumn,
|
||||
OneToMany,
|
||||
} from 'typeorm';
|
||||
import { ProductSubCategories } from './productSubCategory.entity';
|
||||
import { BaseModel } from '../../config/basemodel.entity';
|
||||
|
||||
@Entity()
|
||||
export class Product extends BaseModel{
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@Column()
|
||||
code: string;
|
||||
|
||||
@Column()
|
||||
status: string;
|
||||
|
||||
@OneToMany(
|
||||
() => ProductSubCategories,
|
||||
(subCategories) => subCategories.category,
|
||||
)
|
||||
subCategories: ProductSubCategories;
|
||||
}
|
||||
27
src/product/entities/productCategory.entity.ts
Normal file
27
src/product/entities/productCategory.entity.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
VersionColumn,
|
||||
CreateDateColumn,
|
||||
OneToMany,
|
||||
} from 'typeorm';
|
||||
import { ProductSubCategories } from './productSubCategory.entity';
|
||||
import { BaseModel } from '../../config/basemodel.entity';
|
||||
|
||||
@Entity()
|
||||
export class ProductCategories extends BaseModel {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@OneToMany(
|
||||
() => ProductSubCategories,
|
||||
(subCategories) => subCategories.category,
|
||||
)
|
||||
subCategories: ProductSubCategories;
|
||||
}
|
||||
36
src/product/entities/productHistoryPrice.entity.ts
Normal file
36
src/product/entities/productHistoryPrice.entity.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
VersionColumn,
|
||||
CreateDateColumn,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
} from 'typeorm';
|
||||
import { Product } from './product.entity';
|
||||
import { BaseModel } from '../../config/basemodel.entity';
|
||||
|
||||
enum Type {
|
||||
NORMAL,
|
||||
PROMO,
|
||||
}
|
||||
|
||||
@Entity()
|
||||
export class ProductHistoryPrice extends BaseModel {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => Product, (product) => product.id)
|
||||
productId: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
startDate: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
endDate: string;
|
||||
|
||||
@Column('text')
|
||||
type: Type;
|
||||
}
|
||||
24
src/product/entities/productSubCategory.entity.ts
Normal file
24
src/product/entities/productSubCategory.entity.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
VersionColumn,
|
||||
CreateDateColumn,
|
||||
ManyToOne,
|
||||
} from 'typeorm';
|
||||
import { ProductCategories } from './productCategory.entity';
|
||||
import { BaseModel } from '../../config/basemodel.entity';
|
||||
|
||||
@Entity()
|
||||
export class ProductSubCategories extends BaseModel{
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@ManyToOne(() => ProductCategories, (categories) => categories.subCategories)
|
||||
category: ProductCategories;
|
||||
}
|
||||
Reference in New Issue
Block a user