import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, OneToMany, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, ManyToMany, JoinTable, ManyToOne, Unique } from 'typeorm';
import { v4 as uuidv4 } from 'uuid';
import { Exclude, Expose } from 'class-transformer';
import { Users } from './users.entity';
import { CountryListInstance } from 'twilio/lib/rest/pricing/v2/voice/country';
import { SocialMedias } from './social-medias.entity';
import { YoutubeChannels } from './youtube-channel.entity';
import { FacebookPages } from './facebook-pages.entity';
import { InstagramProfiles } from './instagram-profile.entity';
import { TikTokProfiles } from './tiktok-profile.entity';



@Entity({ name: 'tiktok_videos' })
export class TikTokVideos {

  @PrimaryGeneratedColumn('uuid')
  id: string;

  @ManyToOne(() => Users, user => user.id, { nullable: true })
  @JoinColumn({ name : "users" })
  users: Users;
  
  @ManyToOne(() => SocialMedias, (socialMedia) => socialMedia.id)
  @JoinColumn({ name: "socialMedia"})
  socialMedia: SocialMedias;

  @ManyToOne(() => TikTokProfiles, (tikTokProfiles) => tikTokProfiles.id)
  @JoinColumn({ name: "tikTokProfiles" })
  tikTokProfiles: TikTokProfiles;

  @Column({ type: 'text', default: "" })
  video_id: string;

  @Column({ default: "" })
  create_time: string;
  
  @Column({ type:'text', default: "" })
  title: string;

  @Column({ type: 'text', default: "" })
  cover_image_url: string;

  @Column({ type: 'text', default: "" })
  embed_html: string;

  @Column({ type: 'text', default: "" })
  share_url: string;

  @Column({ type: 'text', default: "" })
  embed_link: string;

  @Column({ type: 'text', default: "" })
  is_comment_enabled: string;

  @Column({ type: 'text', default: "" })
  media_product_type: string;

  @Column({ type: 'text', default: "" })
  media_type: string;

  @Column({ type: 'text', default: "" })
  shortcode: string;

  @Column({ type: 'text', default: "" })
  instagram_timestamp: string;

  @Column({ type: 'bigint', default: 0 })
  height: string;

  @Column({ type: 'bigint', default: 0 })
  width: string;

  @Column({ type: 'bigint', default: 0 })
  like_count: string;

  @Column({ type: 'bigint', default: 0 })
  share_count: string;

  @Column({ type: 'bigint', default: 0 })
  comment_count: string;

  @Column({ type: 'bigint', default: 0 })
  duration: string;

  @Column({ type: 'bigint', default: 0 })
  view_count: string;

  @Exclude()
  @CreateDateColumn({
    type: 'timestamp',
    precision: 0,
    default: () => 'CURRENT_TIMESTAMP',
  })
  created_at: Date;

  @Exclude()
  @UpdateDateColumn({
    type: 'timestamp',
    precision: 0,
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
  })
  updated_at: Date;

  @Exclude()
  @DeleteDateColumn({ type: 'timestamp', nullable: true, precision: 0 })
  deleted_at: Date;

  setDefaults() {
    this.id = this.id || uuidv4();
  }
}