add supplier entity
This commit is contained in:
@ -7,11 +7,12 @@ import {
|
||||
DeleteDateColumn,
|
||||
Index,
|
||||
ManyToOne,
|
||||
JoinColumn
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { Status } from '../types/status';
|
||||
import { User } from './users';
|
||||
import { Supplier } from './supplier';
|
||||
|
||||
@Entity('goods')
|
||||
export class Goods {
|
||||
@ -19,34 +20,34 @@ export class Goods {
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 128,
|
||||
nullable: false,
|
||||
length: 128,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 255,
|
||||
nullable: true,
|
||||
length: 255,
|
||||
})
|
||||
description: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'decimal',
|
||||
precision: 10,
|
||||
scale: 2,
|
||||
nullable: false,
|
||||
type: 'decimal',
|
||||
precision: 10,
|
||||
scale: 2,
|
||||
})
|
||||
price: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'int',
|
||||
nullable: true,
|
||||
type: 'int',
|
||||
})
|
||||
quantity: number;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
})
|
||||
category_id: string;
|
||||
|
||||
@ -56,14 +57,25 @@ export class Goods {
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
})
|
||||
created_by: string;
|
||||
|
||||
@ManyToOne(() => Supplier, { nullable: false })
|
||||
@JoinColumn({ name: 'supplier_id' })
|
||||
supplier: Supplier;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
supplier_id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
})
|
||||
status: Status;
|
||||
|
||||
|
||||
68
src/entity/supplier.ts
Normal file
68
src/entity/supplier.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity('suppliers')
|
||||
export class Supplier {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 128,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 255,
|
||||
})
|
||||
description: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 128,
|
||||
})
|
||||
contact_person: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 128,
|
||||
})
|
||||
email: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 15,
|
||||
})
|
||||
phone: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 255,
|
||||
})
|
||||
address: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
})
|
||||
status: string;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@DeleteDateColumn()
|
||||
deleted_at: Date;
|
||||
}
|
||||
@ -36,6 +36,7 @@ import { Summarize } from "./entity/summarizes";
|
||||
import { SummarizeLog } from "./entity/summarize_log";
|
||||
import { SummarizeLogStatus, SummarizeType } from "./types/summarize";
|
||||
import { Goods } from "./entity/goods";
|
||||
import { Supplier } from "./entity/supplier";
|
||||
|
||||
export {
|
||||
User, //
|
||||
@ -78,5 +79,6 @@ export {
|
||||
SummarizeLog,
|
||||
SummarizeLogStatus,
|
||||
SummarizeType,
|
||||
Goods
|
||||
Goods,
|
||||
Supplier
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user