import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm'
import { Role } from '../../model/role.enum'
import { Exclude } from 'class-transformer'

@Entity()
export class Users {
    @PrimaryGeneratedColumn()
    id: number

    @Column()
    name: string

    @Column({ length: 100, unique: true })
    username: string

    @Column({ nullable: true })
    avatar?: string

    @Column({ length: 100, unique: true, nullable: true })
    email?: string

    @Column({ nullable: true, select: false })
    @Exclude({ toPlainOnly: true })
    password?: string

    @Column({ length: 30, nullable: true, unique: true })
    phone?: string

    @Column({ type: 'set', enum: Role, default: Role.User })
    roles: Role[]

    @Column({ nullable: true })
    invitor?: number

    @CreateDateColumn()
    createdAt: Date

    @Column({ nullable: true })
    iat: number

    @Column({ nullable: true })
    apiUserId: number
    
    @Column({ nullable: true })
    orgId: number
}
