import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm'; import { ApiProperty } from '@nestjs/swagger'; import { BaseEntity } from './base.entity'; import { Establishment } from './establishment.entity'; import { User } from './user.entity'; @Entity({ name: 'reservations', schema: 'commerce' }) export class Reservation extends BaseEntity { @ApiProperty({ description: 'Establishment ID' }) @Column({ name: 'establishment_id', nullable: true }) establishmentId: string; @ApiProperty({ description: 'User ID' }) @Column({ name: 'user_id', nullable: true }) userId: string; @ApiProperty({ description: 'Reservation type', example: 'room' }) @Column({ length: 20 }) type: string; @ApiProperty({ description: 'Reference ID (room, table, etc.)' }) @Column({ name: 'reference_id', nullable: true }) referenceId: string; @ApiProperty({ description: 'Check-in date' }) @Column({ name: 'check_in_date', type: 'date', nullable: true }) checkInDate: Date; @ApiProperty({ description: 'Check-out date' }) @Column({ name: 'check_out_date', type: 'date', nullable: true }) checkOutDate: Date; @ApiProperty({ description: 'Check-in time' }) @Column({ name: 'check_in_time', type: 'time', nullable: true }) checkInTime: string; @ApiProperty({ description: 'Number of guests', example: 2 }) @Column({ name: 'guests_count', nullable: true }) guestsCount: number; @ApiProperty({ description: 'Special requests' }) @Column({ name: 'special_requests', type: 'text', nullable: true }) specialRequests: string; @ApiProperty({ description: 'Total amount', example: 240.00 }) @Column({ name: 'total_amount', type: 'decimal', precision: 10, scale: 2, nullable: true }) totalAmount: number; @ApiProperty({ description: 'Reservation status', example: 'confirmed' }) @Column({ length: 20, default: 'pending' }) status: string; // Relations @ManyToOne(() => Establishment) @JoinColumn({ name: 'establishment_id' }) establishment: Establishment; @ManyToOne(() => User) @JoinColumn({ name: 'user_id' }) user: User; }