import { DB_SCHEMA } from 'src/utils';
import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { WebMediaCategoryEntity } from './WebMediaCategory.entity';
import { GalleriesEntity } from './Galleries.entity';

@Entity('web_media', { schema: DB_SCHEMA })
export class WebMediaEntity {
  @PrimaryGeneratedColumn({ type: 'smallint', name: 'id' })
  id: number;

  @Column('tinyint', {
    name: 'type',
    nullable: true,
    comment: '1 - Image, 2 - Video',
    width: 1,
  })
  type: boolean | null;

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

  @Column('varchar', { name: 'image', length: 255 })
  image: string;

  @Column('varchar', { name: 'video_screenshot', nullable: true, length: 255 })
  video_screenshot: string | null;

  @Column('varchar', { name: 'title', length: 25 })
  title: string;

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

  @Column('varchar', { name: 'pagetype', length: 25 })
  pagetype: string;

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

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

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

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

  @Column('tinyint', {
    name: 'active',
    nullable: true,
    width: 1,
    default: () => "'1'",
  })
  active: boolean | null;

  @Column('tinyint', { name: 'publish_on_gallery', width: 1 })
  publish_on_gallery: boolean;

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

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

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

  @ManyToOne(() => WebMediaCategoryEntity)
  @JoinColumn({ name: 'web_catId' })
  web_category: WebMediaCategoryEntity;

  @ManyToOne(() => GalleriesEntity)
  @JoinColumn({ name: 'galleryId' })
  gallery: GalleriesEntity;
}
