add entity AuthRole , AuthRoleAttr , AuthSys
This commit is contained in:
parent
aa67674fa7
commit
4beef77eb3
3 changed files with 213 additions and 0 deletions
35
src/entities/AuthRole.ts
Normal file
35
src/entities/AuthRole.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { Entity, Column, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { AuthRoleAttr } from "./AuthRoleAttr";
|
||||
|
||||
@Entity("AuthRole")
|
||||
export class AuthRole extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อบทบาท",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
roleName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "รายละเอียด",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
roleDescription: string;
|
||||
|
||||
@OneToMany(() => AuthRoleAttr, (authRoleAttr) => authRoleAttr.authRoleAttrForRole)
|
||||
authRoles: AuthRoleAttr[];
|
||||
}
|
||||
|
||||
export class CreateAuthRole {
|
||||
@Column()
|
||||
roleName: string;
|
||||
|
||||
@Column()
|
||||
roleDescription: string;
|
||||
}
|
||||
|
||||
export type UpdateAuthRole = Partial<CreateAuthRole>;
|
||||
102
src/entities/AuthRoleAttr.ts
Normal file
102
src/entities/AuthRoleAttr.ts
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { AuthSys } from "./AuthSys";
|
||||
import { AuthRole } from "./AuthRole";
|
||||
|
||||
@Entity("AuthRoleAttr")
|
||||
export class AuthRoleAttr extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
attrOwnership: string;
|
||||
|
||||
@Column({
|
||||
comment: "",
|
||||
default: false,
|
||||
})
|
||||
attrIsCreate: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "",
|
||||
default: false,
|
||||
})
|
||||
attrIsList: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "",
|
||||
default: false,
|
||||
})
|
||||
attrIsGet: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "",
|
||||
default: false,
|
||||
})
|
||||
attrIsUpdate: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "",
|
||||
default: false,
|
||||
})
|
||||
attrIsDelete: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
attrPrivilege: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง AuthRole",
|
||||
default: null,
|
||||
})
|
||||
authRoleId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 255,
|
||||
comment: "คีย์นอก(FK)ของตาราง AuthSys",
|
||||
default: null,
|
||||
})
|
||||
authSysId: string;
|
||||
|
||||
@ManyToOne(() => AuthSys, (authSys) => authSys.authSys)
|
||||
@JoinColumn({ name: "authSysId" })
|
||||
authRoleAttrForSys: AuthSys;
|
||||
|
||||
@ManyToOne(() => AuthRole, (authRole) => authRole.authRoles)
|
||||
@JoinColumn({ name: "authRoleId" })
|
||||
authRoleAttrForRole: AuthRole;
|
||||
}
|
||||
|
||||
export class CreateAuthRoleAttr {
|
||||
@Column()
|
||||
attrOwnership: string;
|
||||
|
||||
@Column()
|
||||
attrIsCreate: boolean;
|
||||
|
||||
@Column()
|
||||
attrIsList: boolean;
|
||||
|
||||
@Column()
|
||||
attrIsGet: boolean;
|
||||
|
||||
@Column()
|
||||
attrIsUpdate: boolean;
|
||||
|
||||
@Column()
|
||||
attrIsDelete: boolean;
|
||||
|
||||
@Column()
|
||||
attrPrivilege: string;
|
||||
}
|
||||
|
||||
export type UpdateAuthRoleAttr = Partial<CreateAuthRoleAttr>;
|
||||
76
src/entities/AuthSys.ts
Normal file
76
src/entities/AuthSys.ts
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
import {
|
||||
Entity,
|
||||
Column,
|
||||
OneToMany,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
PrimaryColumn,
|
||||
} from "typeorm";
|
||||
import { AuthRoleAttr } from "./AuthRoleAttr";
|
||||
|
||||
@Entity("AuthSys")
|
||||
export class AuthSys {
|
||||
@PrimaryColumn({
|
||||
comment: "ไอดีหลักของตาราง",
|
||||
length: 255,
|
||||
})
|
||||
id: string;
|
||||
|
||||
@CreateDateColumn({ comment: "สร้างข้อมูลเมื่อ" })
|
||||
createdAt!: Date;
|
||||
|
||||
@Column({
|
||||
comment: "User Id ที่สร้างข้อมูล",
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
createdUserId!: String;
|
||||
|
||||
@UpdateDateColumn({ comment: "แก้ไขข้อมูลล่าสุดเมื่อ" })
|
||||
lastUpdatedAt!: Date;
|
||||
|
||||
@Column({
|
||||
comment: "User Id ที่แก้ไขข้อมูล",
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
lastUpdateUserId!: String;
|
||||
|
||||
@Column({ comment: "ชื่อ User ที่สร้างข้อมูล", length: 200, default: "string" })
|
||||
createdFullName!: String;
|
||||
|
||||
@Column({ comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด", length: 200, default: "string" })
|
||||
lastUpdateFullName!: String;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อระบบ",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
sysName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "รายละเอียด",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
sysDescription: string;
|
||||
|
||||
@OneToMany(() => AuthRoleAttr, (authRoleAttr) => authRoleAttr.authRoleAttrForSys)
|
||||
authSys: AuthRoleAttr[];
|
||||
}
|
||||
|
||||
export class CreateAuthSys {
|
||||
@PrimaryColumn()
|
||||
id: string;
|
||||
|
||||
@Column()
|
||||
sysName: string;
|
||||
|
||||
@Column()
|
||||
sysDescription: string;
|
||||
}
|
||||
|
||||
export type UpdateAuthSys = Partial<CreateAuthSys>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue