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

@Entity('stores')
@Index('idx_stores_issuer', ['issuerId'])
@Index('idx_stores_parent', ['parentId'])
export class Store {
  @PrimaryGeneratedColumn('uuid') id: string;
  @Column({ name: 'issuer_id', type: 'uuid' }) issuerId: string;
  @Column({ type: 'varchar', length: 200 }) name: string;
  @Column({ type: 'varchar', length: 500, nullable: true }) address: string | null;
  @Column({ type: 'numeric', precision: 10, scale: 7, nullable: true }) latitude: string | null;
  @Column({ type: 'numeric', precision: 10, scale: 7, nullable: true }) longitude: string | null;
  @Column({ type: 'varchar', length: 20, nullable: true }) phone: string | null;
  @Column({ name: 'business_hours', type: 'varchar', length: 200, nullable: true }) businessHours: string | null;
  @Column({ type: 'varchar', length: 50, default: 'store' }) level: string; // 'hq' | 'region' | 'store'
  @Column({ name: 'parent_id', type: 'uuid', nullable: true }) parentId: string | null;
  @Column({ type: 'varchar', length: 20, default: 'active' }) status: string;
  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date;
  @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' }) updatedAt: Date;
}
