add categories

This commit is contained in:
fro1991
2024-12-15 01:19:05 +07:00
parent 5d2835c779
commit a731b6ad5a
3 changed files with 73 additions and 1 deletions

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

View File

@ -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
};

View File

@ -0,0 +1,5 @@
export enum CategorySource {
TrialBalanceBranch = 'trialBalanceBranch',
CifAccount = 'cifAccount',
Lnkolek = 'lnkolek',
};