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

@Entity('supplier')
export class Supplier {
  @PrimaryGeneratedColumn({ unsigned: true })
  id!: number;

  @Column({ name: 'name', type: 'varchar', length: 255, nullable: true, comment: '供货商名称' })
  name!: string | null;

  @Column({ name: 'username', type: 'varchar', length: 50, unique: true, comment: '用户名' })
  username!: string;

  @Column({ name: 'password', type: 'varchar', length: 255, comment: '密码' })
  password!: string;

  @Column({ name: 'phone', type: 'char', length: 11, nullable: true, comment: '手机号码' })
  phone!: string | null;

  @Column({ name: 'realname', type: 'varchar', length: 20, nullable: true, comment: '姓名' })
  realname!: string | null;

  @Column({ name: 'login_num', type: 'int', unsigned: true, default: 0, comment: '登录次数' })
  loginNum!: number;

  @Column({ name: 'login_time', type: 'timestamp', nullable: true, comment: '登录时间' })
  loginTime!: Date | null;

  @Column({ name: 'login_ip', type: 'varchar', length: 15, nullable: true, comment: '登录IP' })
  loginIp!: string | null;

  @Column({ name: 'last_login_time', type: 'timestamp', nullable: true, comment: '上次登录时间' })
  lastLoginTime!: Date | null;

  @Column({ name: 'last_login_ip', type: 'varchar', length: 15, nullable: true, comment: '上次登录IP' })
  lastLoginIp!: string | null;

  @Column({ name: 'state', type: 'smallint', unsigned: true, default: 2, comment: '状态 1启用 2禁用' })
  state!: number;

  @CreateDateColumn({ name: 'created_at', type: 'timestamp', comment: '创建时间' })
  createdAt!: Date;

  @UpdateDateColumn({ name: 'updated_at', type: 'timestamp', comment: '更新时间' })
  updatedAt!: Date;

  @Column({ name: 'created_by', type: 'int', unsigned: true, nullable: true, comment: '创建用户ID' })
  createdBy!: number | null;

  @Column({ name: 'updated_by', type: 'int', unsigned: true, nullable: true, comment: '更新用户ID' })
  updatedBy!: number | null;
}