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

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

  @Column({ name: 'name', type: 'varchar', length: 255, comment: '分行网点名称' })
  name!: string;

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

  @Column({ name: 'level', type: 'int', unsigned: true, default: 4, comment: '层级' })
  level!: number;

  @Column({ name: 'state', type: 'smallint', unsigned: true, default: 1, 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;
}