ff-admin-server/src/entity/user/user.ts

45 lines
1.1 KiB
TypeScript
Raw Normal View History

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";
@Entity()
export class user {
2025-01-28 11:09:42 +01:00
@PrimaryColumn({ generated: "uuid", type: "varchar" })
id: string;
2025-01-28 11:09:42 +01:00
@Column({ type: "varchar", unique: true, length: 255 })
mail: string;
2025-01-28 11:09:42 +01:00
@Column({ type: "varchar", unique: true, length: 255 })
username: string;
2024-08-25 13:36:19 +02:00
@Column({ type: "varchar", length: 255 })
firstname: string;
@Column({ type: "varchar", length: 255 })
lastname: string;
@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;
@ManyToMany(() => role, (role) => role.users, {
nullable: false,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
2025-01-29 16:49:34 +01:00
cascade: ["insert"],
})
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[];
}