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

@Entity('b2b_affiliate_account_products', { schema: DB_SCHEMA })
export class B2bAffiliateAccountProductsEntity {
  @PrimaryGeneratedColumn({ type: 'int', name: 'id' })
  id: number;

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

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

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

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

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

  @ManyToOne(
    () => B2bAffiliateAccountsEntity,
    (b2bAccount) => b2bAccount.products,
  )
  @JoinColumn({ name: 'affiliate_account_id' })
  b2b_account: B2bAffiliateAccountsEntity;
}
