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

@Entity('recent_visited_menus', { schema: DB_SCHEMA })
export class RecentVisitedMenusEntity {
  @PrimaryGeneratedColumn({ type: 'mediumint', name: 'id' })
  id: number;

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

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

  @Column('json', { name: 'visited_menus', nullable: true })
  visited_menus: any[] | null;

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

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

  @OneToOne(() => UserEntity, (user) => user.recent_visited_menus)
  @JoinColumn({ name: 'user_id' })
  user: UserEntity;
}
