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

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

  @Column({ name: 'name', type: 'varchar', length: 255, comment: '地区名称' })
  name!: string;

  @Column({ name: 'level', type: 'int', unsigned: true, default: 0, comment: '层级 省市区县1,2,3,4' })
  level!: number;

  @Column({ name: 'parent_id', type: 'bigint', unsigned: true, default: 0, comment: '上级id' })
  parentId!: number;

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

  @Column({ name: 'sort', type: 'int', unsigned: true, default: 0, comment: '排序数值越大越靠前' })
  sort!: 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;
}