refactor: change the role to roles and many to many
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Exclude } from "class-transformer";
|
||||
import { Column, Entity, ManyToMany, ManyToOne, OneToMany, OneToOne } from "typeorm";
|
||||
import { Column, Entity, JoinTable, ManyToMany, OneToMany, OneToOne } from "typeorm";
|
||||
|
||||
import { LegalUser } from "./legal-user.entity";
|
||||
import { RealUser } from "./real-user.entity";
|
||||
@@ -47,8 +47,17 @@ export class User extends BaseEntity {
|
||||
nationalCode: string;
|
||||
|
||||
//-----------------------------------------
|
||||
@ManyToOne(() => Role, { eager: true, onDelete: "RESTRICT", nullable: false })
|
||||
role: Role;
|
||||
// @ManyToOne(() => Role, { eager: true, onDelete: "RESTRICT", nullable: false })
|
||||
// role: Role;
|
||||
|
||||
@ManyToMany(() => Role)
|
||||
@JoinTable({ name: "user_role_relation" })
|
||||
roles: Role[];
|
||||
|
||||
@ManyToMany(() => UserGroup, (group) => group.users)
|
||||
groups: UserGroup[];
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
@OneToMany(() => Ticket, (ticket) => ticket.user)
|
||||
tickets: Ticket[];
|
||||
@@ -56,9 +65,6 @@ export class User extends BaseEntity {
|
||||
@OneToMany(() => TicketMessage, (ticketMessage) => ticketMessage.author)
|
||||
ticketMessage: TicketMessage[];
|
||||
|
||||
@ManyToMany(() => UserGroup, (group) => group.users)
|
||||
groups: UserGroup[];
|
||||
|
||||
@OneToMany(() => Criticism, (criticism) => criticism.user)
|
||||
criticisms: Criticism[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user