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

@Entity('channel_info')
export class Channel {
  @PrimaryGeneratedColumn({
    name: 'channel_id',
    type: 'int',
    unsigned: true,
    comment: '渠道ID'
  })
  id!: number;

  @Column({
    name: 'channel_name',
    type: 'varchar',
    length: 100,
    nullable: false,
    comment: '渠道名称'
  })
  @Index('idx_channel_name', { unique: true })
  channelName!: string;

  @Column({
    name: 'channel_type',
    type: 'varchar',
    length: 50,
    nullable: false,
    default: '',
    comment: '渠道类型'
  })
  channelType!: 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: 'description',
    type: 'text',
    nullable: true,
    comment: '描述'
  })
  description?: 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;
}