diff --git a/package.json b/package.json index d7dacde..0936b46 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "entity", "version": "1.0.0", "description": "This kind of project was built to present entity table type ORM", - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", + "main": "src/index.ts", + "types": "src/index.ts", "scripts": { "dev": "nodemon", "build": "tsc" diff --git a/src/entity/administrativu.ts b/src/entity/administrativu.ts new file mode 100644 index 0000000..98ac22f --- /dev/null +++ b/src/entity/administrativu.ts @@ -0,0 +1,39 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('administrativus') +export class Administrativu { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 32 + }) + code: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @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/entity/aldeia.ts b/src/entity/aldeia.ts new file mode 100644 index 0000000..a8cd493 --- /dev/null +++ b/src/entity/aldeia.ts @@ -0,0 +1,39 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('aldeias') +export class Aldeia { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 32 + }) + code: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @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/entity/class_economi.ts b/src/entity/class_economi.ts new file mode 100644 index 0000000..13e583d --- /dev/null +++ b/src/entity/class_economi.ts @@ -0,0 +1,39 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('class_economis') +export class ClassEconomi { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 32 + }) + code: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @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/entity/district.ts b/src/entity/district.ts new file mode 100644 index 0000000..f2cd528 --- /dev/null +++ b/src/entity/district.ts @@ -0,0 +1,39 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('districts') +export class District { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 32 + }) + code: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @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/entity/income_tier.ts b/src/entity/income_tier.ts new file mode 100644 index 0000000..7ce829a --- /dev/null +++ b/src/entity/income_tier.ts @@ -0,0 +1,39 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('income_tiers') +export class IncomeTier { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 32 + }) + code: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @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/entity/menu.ts b/src/entity/menu.ts new file mode 100644 index 0000000..2cf80d7 --- /dev/null +++ b/src/entity/menu.ts @@ -0,0 +1,63 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('menus') +export class Menu { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 128 + }) + module: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: true, + length: 256 + }) + link: string; + + @Column({ + nullable: true, + type: 'uuid' + }) + id_parent: string; + + @Column({ + nullable: false, + type: 'int2' + }) + order: number; + + @Column({ + nullable: true, + length: 128 + }) + icon: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @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/entity/munisipo.ts b/src/entity/munisipo.ts new file mode 100644 index 0000000..283c7eb --- /dev/null +++ b/src/entity/munisipo.ts @@ -0,0 +1,39 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('munisipos') +export class Munisipo { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 32 + }) + code: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @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/entity/suco.ts b/src/entity/suco.ts new file mode 100644 index 0000000..3ff95d6 --- /dev/null +++ b/src/entity/suco.ts @@ -0,0 +1,39 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('sucos') +export class Suco { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 32 + }) + code: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @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/entity/users.ts b/src/entity/users.ts index 295e9b2..908f589 100644 --- a/src/entity/users.ts +++ b/src/entity/users.ts @@ -1,7 +1,8 @@ import bcrypt from 'bcryptjs'; -import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, OneToOne, JoinColumn } from 'typeorm'; import { Status } from '../types/status'; +import { UserRole } from './users_roles'; @Entity('users') export class User { @@ -48,6 +49,12 @@ export class User { }) reset_token: string; + @OneToOne(() => UserRole) + @JoinColumn({ + name: 'id_role' + }) + role: UserRole; + @Column({ nullable: false, length: 64 diff --git a/src/index.ts b/src/index.ts index 6b58c34..8c75900 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +13,7 @@ import { Status } from "./types/status"; import { EmailBody } from "./types/email"; import { Branch } from "./entity/branchs"; import { Product } from "./entity/products"; +import { Menu } from "./entity/menu"; export { User, @@ -30,5 +31,6 @@ export { Status, EmailBody, Product, - Branch + Branch, + Menu }; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 961a3ee..bfd8c92 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,9 +16,9 @@ "typeRoots": ["./src/types", "./node_modules/@types"], // "baseUrl": "src/", "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, + "noFallthroughCasesInSwitch": true // "allowJs": true, - "declaration": true + // "declaration": true // "emitDeclarationOnly": true, // "declarationMap": true },