add goods entity
This commit is contained in:
81
src/entity/goods.ts
Normal file
81
src/entity/goods.ts
Normal file
@ -0,0 +1,81 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Index,
|
||||
ManyToOne,
|
||||
JoinColumn
|
||||
} from 'typeorm';
|
||||
|
||||
import { Status } from '../types/status';
|
||||
import { User } from './users';
|
||||
|
||||
@Entity('goods')
|
||||
export class Goods {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 128,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 255,
|
||||
})
|
||||
description: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'decimal',
|
||||
precision: 10,
|
||||
scale: 2,
|
||||
})
|
||||
price: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'int',
|
||||
})
|
||||
quantity: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
})
|
||||
category_id: string;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id, { nullable: true })
|
||||
@JoinColumn({ name: 'created_by' })
|
||||
createdBy: User;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
})
|
||||
created_by: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
})
|
||||
status: Status;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@DeleteDateColumn()
|
||||
deleted_at: Date;
|
||||
}
|
||||
@ -35,6 +35,7 @@ import { CategoryType } from "./types/category";
|
||||
import { Summarize } from "./entity/summarizes";
|
||||
import { SummarizeLog } from "./entity/summarize_log";
|
||||
import { SummarizeLogStatus, SummarizeType } from "./types/summarize";
|
||||
import { Goods } from "./entity/goods";
|
||||
|
||||
export {
|
||||
User, //
|
||||
@ -76,5 +77,6 @@ export {
|
||||
Summarize,
|
||||
SummarizeLog,
|
||||
SummarizeLogStatus,
|
||||
SummarizeType
|
||||
SummarizeType,
|
||||
Goods
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user