From fb4d6a321b32123c4b2deaca47184ba05653d6b7 Mon Sep 17 00:00:00 2001 From: fadlydev Date: Wed, 25 Dec 2024 21:53:24 +0700 Subject: [PATCH] add goods entity --- src/entity/goods.ts | 81 +++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 4 ++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/entity/goods.ts diff --git a/src/entity/goods.ts b/src/entity/goods.ts new file mode 100644 index 0000000..43e6b91 --- /dev/null +++ b/src/entity/goods.ts @@ -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; +} diff --git a/src/index.ts b/src/index.ts index fa44d96..daa5784 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 };