import {
  Table,
  Column,
  Model,
  DataType,
  Index,
  PrimaryKey,
  AutoIncrement,
  ForeignKey,
  BelongsTo,
} from 'sequelize-typescript';
import { PriceCompanyFeedAccessAttr } from '../interfaces/price-company-feed-access-attr.interface';
import { PricingLogic } from '../enum/feed.enum';
import FeedModel from './price-feed.entity';

@Table({
  tableName: 'price_CompanyFeedAccess',
  timestamps: true,
  createdAt: 'CreatedAt',
  updatedAt: 'UpdatedAt',
})
export default class PriceCompanyFeedAccess extends Model<PriceCompanyFeedAccessAttr> {
  @PrimaryKey
  @Column({
    type: DataType.STRING(30),
  })
  CompanyAccessId: string;

  @Column({
    type: DataType.STRING(30),
    allowNull: false,
  })
  CompanyCode: string;

  @ForeignKey(() => FeedModel)
  @Column({
    type: DataType.STRING(50),
    allowNull: false,
  })
  FeedName: string;

  @BelongsTo(() => FeedModel)
  Feed: FeedModel;

  @Column({
    type: DataType.STRING(20),
    allowNull: false,
    defaultValue: 'Active',
  })
  Status: string;

  @Column({
    type: DataType.ENUM(PricingLogic.SELL_BUY_SELL, PricingLogic.BUY_BUY_SELL),
    allowNull: false,
    defaultValue: PricingLogic.SELL_BUY_SELL,
  })
  PricingLogic: PricingLogic;

  @Column({
    type: DataType.INTEGER,
    allowNull: false,
  })
  CreatedById: number;

  @Column({
    type: DataType.DATE,
    allowNull: false,
  })
  CreatedAt: Date;

  @Column({
    type: DataType.INTEGER,
    allowNull: false,
  })
  UpdatedById: number;

  @Column({
    type: DataType.DATE,
    allowNull: false,
  })
  UpdatedAt: Date;
}
