diff --git a/src/entity/categories.ts b/src/entity/categories.ts new file mode 100644 index 0000000..beba1b4 --- /dev/null +++ b/src/entity/categories.ts @@ -0,0 +1,65 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; + +import { CategorySource } from '../types/category_source'; +import { Status } from '../types/status'; + +@Entity('categories') +export class Category { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: true, + length: 256 + }) + name: string; + + @Column({ + nullable: true, + length: 4096 + }) + description: string; + + @Column({ + type: 'enum', + enum: CategorySource, + nullable: false + }) + source: CategorySource; + + @Column({ + type: 'enum', + enum: Status, + nullable: false + }) + status: Status; + + @Column({ nullable: true }) + parentId: number; + + @ManyToOne(() => Category, (category) => category.children) + parent: Category; + + @OneToMany(() => Category, (category) => category.parent) + children: Category[]; + + @Column({ + nullable: true, + type: 'uuid', + array: true + }) + products: string[]; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 49c0bc7..32a4ce7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,7 @@ import { Munisipo } from "./entity/munisipo"; import { Suco } from "./entity/suco"; import { LogPull } from "./entity/log_pull"; import { LogPullType, StatusLogPull } from "./types/pull"; +import { Category } from "./entity/categories"; export { User, @@ -53,5 +54,6 @@ export { Suco, LogPull, LogPullType, - StatusLogPull + StatusLogPull, + Category }; \ No newline at end of file diff --git a/src/types/category_source.ts b/src/types/category_source.ts new file mode 100644 index 0000000..ea97d8a --- /dev/null +++ b/src/types/category_source.ts @@ -0,0 +1,5 @@ +export enum CategorySource { + TrialBalanceBranch = 'trialBalanceBranch', + CifAccount = 'cifAccount', + Lnkolek = 'lnkolek', +}; \ No newline at end of file