import { Entity, Column } from "typeorm";
import { AbstractEntity } from "./AbstractEntity.js";
import { UserRole } from "../api/enums/UserRole.js";

/**
 * Entity describing a user
 */
@Entity({ name: "user" })
export class UserEntity extends AbstractEntity {
    @Column({ nullable: false, name: "user_name", unique: true })
    userName!: string;

    @Column({ nullable: false })
    email!: string;

    @Column({ nullable: false })
    password!: string;

    @Column({ nullable: true, name: "first_name" })
    firstName?: string;

    @Column({ nullable: true, name: "last_name" })
    lastName?: string;

    @Column({
        type: "enum",
        enum: UserRole,
        default: UserRole.USER,
    })
    role!: UserRole;
}