import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index, ManyToOne, JoinColumn } from 'typeorm';
import { Room } from './room.entity';

@Entity('room_calendar')
export class RoomCalendar {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

  @ManyToOne(() => Room)
  @JoinColumn({ name: 'room_id' })
  room: Room;

  @Column({ name: 'room_id', type: 'bigint', unsigned: true, comment: '房型ID' })
  roomId: number;

  @Index()
  @Column({ type: 'date', comment: '日期' })
  date: string;

  @Column({ type: 'decimal', precision: 10, scale: 2, unsigned: true, default: 0, comment: '当日房价' })
  price: number;

  @Column({ type: 'int', unsigned: true, default: 0, comment: '可售数量' })
  stock: number;

  @Column({ type: 'int', unsigned: true, default: 0, comment: '已售数量' })
  sold: number;

  @Column({ type: 'enum', enum: ['available', 'unavailable'], default: 'available', comment: '房态' })
  status: 'available' | 'unavailable';

  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at', comment: '更新时间' })
  updatedAt: Date;
}
