2024-09-01 14:55:05 +02:00
|
|
|
import { Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryColumn } from "typeorm";
|
2024-08-27 17:54:59 +02:00
|
|
|
import { role } from "./role";
|
2024-09-01 14:55:05 +02:00
|
|
|
import { userPermission } from "./user_permission";
|
2024-08-22 11:40:31 +02:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class user {
|
2025-01-28 11:09:42 +01:00
|
|
|
@PrimaryColumn({ generated: "uuid", type: "varchar" })
|
|
|
|
id: string;
|
2024-08-22 11:40:31 +02:00
|
|
|
|
2025-01-28 11:09:42 +01:00
|
|
|
@Column({ type: "varchar", unique: true, length: 255 })
|
2024-08-22 11:40:31 +02:00
|
|
|
mail: string;
|
|
|
|
|
2025-01-28 11:09:42 +01:00
|
|
|
@Column({ type: "varchar", unique: true, length: 255 })
|
2024-08-22 11:40:31 +02:00
|
|
|
username: string;
|
|
|
|
|
2024-08-25 13:36:19 +02:00
|
|
|
@Column({ type: "varchar", length: 255 })
|
|
|
|
firstname: string;
|
|
|
|
|
|
|
|
@Column({ type: "varchar", length: 255 })
|
|
|
|
lastname: string;
|
|
|
|
|
2024-08-22 11:40:31 +02:00
|
|
|
@Column({ type: "varchar", length: 255 })
|
|
|
|
secret: string;
|
2024-08-27 17:54:59 +02:00
|
|
|
|
2025-01-31 11:06:02 +01:00
|
|
|
@Column({ type: "boolean", default: false })
|
|
|
|
static: boolean;
|
|
|
|
|
2024-10-07 18:09:27 +02:00
|
|
|
@Column({ type: "boolean", default: false })
|
|
|
|
isOwner: boolean;
|
|
|
|
|
2024-09-14 11:33:13 +02:00
|
|
|
@ManyToMany(() => role, (role) => role.users, {
|
|
|
|
nullable: false,
|
|
|
|
onDelete: "CASCADE",
|
|
|
|
onUpdate: "RESTRICT",
|
2025-01-29 16:49:34 +01:00
|
|
|
cascade: ["insert"],
|
2024-09-14 11:33:13 +02:00
|
|
|
})
|
2024-08-27 17:54:59 +02:00
|
|
|
@JoinTable({
|
|
|
|
name: "user_roles",
|
|
|
|
})
|
|
|
|
roles: role[];
|
2024-09-01 14:55:05 +02:00
|
|
|
|
2025-01-29 16:49:34 +01:00
|
|
|
@OneToMany(() => userPermission, (userPermission) => userPermission.user, { cascade: ["insert"] })
|
2024-09-01 14:55:05 +02:00
|
|
|
permissions: userPermission[];
|
2024-08-22 11:40:31 +02:00
|
|
|
}
|