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

@Entity('room_decor_placements')
@Index('idx_room_decor_placements_user_id', ['user_id'])
@Index('idx_room_decor_placements_user_decor_unique', ['user_id', 'decor_id'], { unique: true })
export class RoomDecorPlacements {
  @PrimaryGeneratedColumn({ type: 'bigint', comment: '主键ID' })
  id: bigint;

  @Column({ type: 'bigint', nullable: false, comment: '关联users.id' })
  user_id: bigint;

  @Column({ type: 'varchar', length: 100, nullable: false, comment: '房间摆件ID' })
  decor_id: string;

  @Column({ type: 'boolean', nullable: false, default: false, comment: '是否已摆放' })
  placed: boolean;

  @Column({ type: 'float', nullable: true, comment: '房间内X坐标' })
  position_x: number | null;

  @Column({ type: 'float', nullable: true, comment: '房间内Y坐标' })
  position_y: number | null;

  @Column({ type: 'float', nullable: false, default: 1, comment: '摆件缩放' })
  scale: number;

  @Column({ type: 'float', nullable: false, default: 0, comment: '摆件旋转角度' })
  rotation_degrees: number;

  @Column({ type: 'int', nullable: false, default: 0, comment: '摆放层级' })
  z_index: number;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', comment: '创建时间' })
  created_at: Date;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP', comment: '更新时间' })
  updated_at: Date;
}
