import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

export enum UserType {
  ANONYMOUS = 'ANONYMOUS',
  REGISTERED = 'REGISTERED',
}

@Entity('users')
export class UserEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({
    type: 'enum',
    enum: UserType,
    default: UserType.ANONYMOUS,
  })
  type: UserType;

  @Column({ nullable: true })
  fingerprint: string;

  @Column({ nullable: true })
  phone: string;

  @Column({ nullable: true })
  nickname: string;

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

  @CreateDateColumn({ name: 'created_at' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  updatedAt: Date;

  @Column({ name: 'last_active_at', default: () => 'NOW()' })
  lastActiveAt: Date;
}
