import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  PrimaryColumn,
  OneToOne,
  OneToMany,
} from 'typeorm';
import { ProductListed } from './product-listed.entity';

@Entity('products')
export class Product {
  @PrimaryColumn('varchar')
  ebayListingId: string;

  @Column('varchar', { nullable: true, default: null })
  id: string;

  @Column()
  code: string;

  @Column({ nullable: true, default: null })
  name: string;

  @Column('simple-array', { nullable: true, default: null })
  listImage: string[];

  @Column('simple-array', { nullable: true, default: null })
  package_contain: string[];

  @Column({ type: 'longtext', nullable: true, default: null })
  description: string;

  @Column({ type: 'longtext', nullable: true, default: null })
  shortDescription: string;

  @Column({ nullable: true, default: null })
  title: string;

  @Column({ nullable: true, default: null })
  category: string; // để đơn giản, lưu string thôi

  @Column({ type: 'varchar', nullable: true, default: null })
  price: string;

  @Column({ nullable: true, default: null })
  conditionEbay: string;

  @Column({ nullable: true, default: null })
  condition: string;

  @Column({ nullable: true, default: null })
  manufactor: string;

  @Column({ nullable: true, default: null })
  location: string;

  @Column({ nullable: true, default: null })
  listingId: string;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

  @OneToMany(() => ProductListed, (listed) => listed.product)
  listedProducts: ProductListed[];
}
