add supplier entity

This commit is contained in:
fadlydev
2024-12-28 12:00:26 +07:00
parent 20d7d96f62
commit 2cfcfccfaa
3 changed files with 100 additions and 18 deletions

View File

@ -7,11 +7,12 @@ import {
DeleteDateColumn, DeleteDateColumn,
Index, Index,
ManyToOne, ManyToOne,
JoinColumn JoinColumn,
} from 'typeorm'; } from 'typeorm';
import { Status } from '../types/status'; import { Status } from '../types/status';
import { User } from './users'; import { User } from './users';
import { Supplier } from './supplier';
@Entity('goods') @Entity('goods')
export class Goods { export class Goods {
@ -61,6 +62,17 @@ export class Goods {
}) })
created_by: string; created_by: string;
@ManyToOne(() => Supplier, { nullable: false })
@JoinColumn({ name: 'supplier_id' })
supplier: Supplier;
@Index()
@Column({
nullable: false,
type: 'uuid',
})
supplier_id: string;
@Column({ @Column({
nullable: false, nullable: false,
length: 64, length: 64,

68
src/entity/supplier.ts Normal file
View 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;
}

View File

@ -36,6 +36,7 @@ import { Summarize } from "./entity/summarizes";
import { SummarizeLog } from "./entity/summarize_log"; import { SummarizeLog } from "./entity/summarize_log";
import { SummarizeLogStatus, SummarizeType } from "./types/summarize"; import { SummarizeLogStatus, SummarizeType } from "./types/summarize";
import { Goods } from "./entity/goods"; import { Goods } from "./entity/goods";
import { Supplier } from "./entity/supplier";
export { export {
User, // User, //
@ -78,5 +79,6 @@ export {
SummarizeLog, SummarizeLog,
SummarizeLogStatus, SummarizeLogStatus,
SummarizeType, SummarizeType,
Goods Goods,
Supplier
}; };