import { Entity, Column, PrimaryGeneratedColumn, Index } from 'typeorm';

@Entity('employer_platform')
export class Platform {
  @PrimaryGeneratedColumn({
    name: 'platform_id',
    type: 'int',
    unsigned: true,
    comment: '平台ID'
  })
  id!: number;

  @Column({
    name: 'platform_name',
    type: 'varchar',
    length: 100,
    nullable: false,
    comment: '平台名称'
  })
  @Index('idx_platform_name', { unique: true })
  platformName!: string;

  @Column({
    name: 'contact_person',
    type: 'varchar',
    length: 50,
    nullable: false,
    default: '',
    comment: '联系人'
  })
  contactPerson!: string;

  @Column({
    name: 'contact_phone',
    type: 'varchar',
    length: 20,
    nullable: false,
    default: '',
    comment: '联系电话'
  })
  contactPhone!: string;

  @Column({
    name: 'contact_email',
    type: 'varchar',
    length: 100,
    nullable: true,
    comment: '联系邮箱'
  })
  contactEmail?: string;

  @Column({
    name: 'status',
    type: 'int',
    default: 1,
    comment: '状态：1-正常，0-禁用'
  })
  status!: number;

  @Column({
    name: 'create_time',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    comment: '创建时间'
  })
  createTime!: Date;

  @Column({
    name: 'update_time',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
    comment: '更新时间'
  })
  updateTime!: Date;
}