import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { User } from './user.entity';

@Entity('guests')
export class Guest {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

  @Column({ name: 'user_id', type: 'bigint', unsigned: true, comment: '用户ID' })
  userId: number;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'user_id' })
  user: User;

  @Column({ length: 50, comment: '姓名' })
  name: string;

  @Column({ name: 'phone', length: 20, comment: '手机号' })
  phone: string;

  @Column({ name: 'id_card', length: 18, nullable: true, comment: '身份证号' })
  idCard: string;

  @Column({ type: 'enum', enum: ['male', 'female'], nullable: true, comment: '性别' })
  gender: 'male' | 'female';

  @Column({ name: 'is_default', type: 'boolean', default: false, comment: '是否默认' })
  isDefault: boolean;

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

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