refactor: change the role to roles and many to many

This commit is contained in:
mahyargdz
2025-02-16 16:58:51 +03:30
parent 9cdd7ef28e
commit ad673613d9
32 changed files with 264 additions and 88 deletions
+12 -6
View File
@@ -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[];