import { DB_SCHEMA } from 'src/utils';
import {
  Column,
  Entity,
  Index,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { UserEntity } from './User.entity';

@Index('reason', ['reason'], { unique: true })
@Entity('vcm_commission_response_reason', {
  schema: DB_SCHEMA,
})
export class VcmCommissionResponseReasonEntity {
  @PrimaryGeneratedColumn({ type: 'tinyint', name: 'id', unsigned: true })
  id: number;

  @Column('varchar', { name: 'reason', unique: true, length: 150 })
  reason: string;

  @Column('tinyint', { name: 'active', nullable: true, comment: '1=Active' })
  active: number | null;

  @Column('smallint', { name: 'by_user', nullable: true })
  by_user: number | null;

  @Column('timestamp', { name: 'created', default: () => 'CURRENT_TIMESTAMP' })
  created: Date;

  @Column('smallint', { name: 'modified_by_user', nullable: true })
  modified_by_user: number | null;

  @Column('timestamp', { name: 'modified', default: () => 'CURRENT_TIMESTAMP' })
  modified: Date;

  @ManyToOne(() => UserEntity, (user) => user.menus_created, { nullable: true })
  @JoinColumn({ name: 'by_user' })
  user: UserEntity;

  @ManyToOne(() => UserEntity, (user) => user.menus_modified, {
    nullable: true,
  })
  @JoinColumn({ name: 'modified_by_user' })
  modified_by: UserEntity;
}
