import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, VersionColumn } from 'typeorm';

export enum IssuerStatus { PENDING = 'pending', ACTIVE = 'active', SUSPENDED = 'suspended', REJECTED = 'rejected' }

@Entity('issuers')
export class Issuer {
  @PrimaryGeneratedColumn('uuid') id: string;
  @Column({ name: 'user_id', type: 'uuid' }) userId: string;
  @Column({ name: 'company_name', type: 'varchar', length: 200 }) companyName: string;
  @Column({ name: 'business_license', type: 'varchar', length: 100, nullable: true }) businessLicense: string | null;
  @Column({ name: 'contact_name', type: 'varchar', length: 100 }) contactName: string;
  @Column({ name: 'contact_phone', type: 'varchar', length: 20 }) contactPhone: string;
  @Column({ name: 'contact_email', type: 'varchar', length: 100, nullable: true }) contactEmail: string | null;
  @Column({ type: 'text', nullable: true }) description: string | null;
  @Column({ name: 'logo_url', type: 'varchar', length: 500, nullable: true }) logoUrl: string | null;
  @Column({ type: 'varchar', length: 20, default: 'pending' }) status: IssuerStatus;
  @Column({ name: 'fee_rate', type: 'numeric', precision: 5, scale: 4, default: '0.015' }) feeRate: string;
  @Column({ name: 'credit_score', type: 'numeric', precision: 5, scale: 2, default: '50.00' }) creditScore: string;
  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date;
  @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' }) updatedAt: Date;
  @VersionColumn({ default: 1 }) version: number;
}
