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

@Entity('user_settings', { schema: DB_SCHEMA })
export class UserSettingsEntity {
  @PrimaryGeneratedColumn({ type: 'smallint', name: 'id', unsigned: true })
  id: number;

  @Column('smallint', { name: 'user_id' })
  user_id: number;

  @Column('tinyint', { name: 'theme', nullable: true, comment: 'THEME_LIST' })
  theme: number | null;

  @Column('tinyint', {
    name: 'menu_type',
    nullable: true,
    comment: '1=Vertical, 2=Horizontal',
  })
  menu_type: number | null;

  @Column('longtext', { name: 'menu_setting', nullable: true })
  menu_setting: string | null;

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

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