add categories
This commit is contained in:
65
src/entity/categories.ts
Normal file
65
src/entity/categories.ts
Normal file
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -24,6 +24,7 @@ import { Munisipo } from "./entity/munisipo";
|
|||||||
import { Suco } from "./entity/suco";
|
import { Suco } from "./entity/suco";
|
||||||
import { LogPull } from "./entity/log_pull";
|
import { LogPull } from "./entity/log_pull";
|
||||||
import { LogPullType, StatusLogPull } from "./types/pull";
|
import { LogPullType, StatusLogPull } from "./types/pull";
|
||||||
|
import { Category } from "./entity/categories";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
User,
|
User,
|
||||||
@ -53,5 +54,6 @@ export {
|
|||||||
Suco,
|
Suco,
|
||||||
LogPull,
|
LogPull,
|
||||||
LogPullType,
|
LogPullType,
|
||||||
StatusLogPull
|
StatusLogPull,
|
||||||
|
Category
|
||||||
};
|
};
|
||||||
5
src/types/category_source.ts
Normal file
5
src/types/category_source.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export enum CategorySource {
|
||||||
|
TrialBalanceBranch = 'trialBalanceBranch',
|
||||||
|
CifAccount = 'cifAccount',
|
||||||
|
Lnkolek = 'lnkolek',
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user