"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParkingLot = void 0; const typeorm_1 = require("typeorm"); const swagger_1 = require("@nestjs/swagger"); const parking_history_entity_1 = require("./parking-history.entity"); const parking_update_entity_1 = require("./parking-update.entity"); let ParkingLot = class ParkingLot { get occupancyRate() { if (this.totalSlots === 0) return 0; return ((this.totalSlots - this.availableSlots) / this.totalSlots) * 100; } get availabilityStatus() { const rate = this.occupancyRate; if (rate >= 95) return 'full'; if (rate >= 80) return 'limited'; return 'available'; } get isOpen() { if (!this.openTime || !this.closeTime) return true; const now = new Date(); const currentTime = now.getHours() * 60 + now.getMinutes(); const [openHour, openMin] = this.openTime.split(':').map(Number); const [closeHour, closeMin] = this.closeTime.split(':').map(Number); const openMinutes = openHour * 60 + openMin; const closeMinutes = closeHour * 60 + closeMin; return currentTime >= openMinutes && currentTime <= closeMinutes; } }; exports.ParkingLot = ParkingLot; __decorate([ (0, swagger_1.ApiProperty)({ description: 'Unique identifier for the parking lot' }), (0, typeorm_1.PrimaryGeneratedColumn)(), __metadata("design:type", Number) ], ParkingLot.prototype, "id", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Name of the parking lot' }), (0, typeorm_1.Column)({ type: 'varchar', length: 255 }), __metadata("design:type", String) ], ParkingLot.prototype, "name", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Address of the parking lot' }), (0, typeorm_1.Column)({ type: 'text' }), __metadata("design:type", String) ], ParkingLot.prototype, "address", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Latitude coordinate' }), (0, typeorm_1.Column)({ type: 'double precision' }), __metadata("design:type", Number) ], ParkingLot.prototype, "lat", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Longitude coordinate' }), (0, typeorm_1.Column)({ type: 'double precision' }), __metadata("design:type", Number) ], ParkingLot.prototype, "lng", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'PostGIS geography point' }), (0, typeorm_1.Column)({ type: 'geography', spatialFeatureType: 'Point', srid: 4326, nullable: true, }), __metadata("design:type", String) ], ParkingLot.prototype, "location", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Hourly parking rate' }), (0, typeorm_1.Column)({ type: 'decimal', precision: 10, scale: 2, nullable: true }), __metadata("design:type", Number) ], ParkingLot.prototype, "hourlyRate", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Opening time' }), (0, typeorm_1.Column)({ type: 'time', nullable: true }), __metadata("design:type", String) ], ParkingLot.prototype, "openTime", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Closing time' }), (0, typeorm_1.Column)({ type: 'time', nullable: true }), __metadata("design:type", String) ], ParkingLot.prototype, "closeTime", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Number of available parking spaces' }), (0, typeorm_1.Column)({ type: 'int', default: 0 }), __metadata("design:type", Number) ], ParkingLot.prototype, "availableSlots", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Total number of parking spaces' }), (0, typeorm_1.Column)({ type: 'int' }), __metadata("design:type", Number) ], ParkingLot.prototype, "totalSlots", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Parking lot amenities' }), (0, typeorm_1.Column)({ type: 'jsonb', default: '{}' }), __metadata("design:type", Object) ], ParkingLot.prototype, "amenities", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Contact information' }), (0, typeorm_1.Column)({ type: 'jsonb', default: '{}' }), __metadata("design:type", Object) ], ParkingLot.prototype, "contactInfo", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Whether the parking lot is active' }), (0, typeorm_1.Column)({ type: 'boolean', default: true }), __metadata("design:type", Boolean) ], ParkingLot.prototype, "isActive", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Creation timestamp' }), (0, typeorm_1.CreateDateColumn)(), __metadata("design:type", Date) ], ParkingLot.prototype, "createdAt", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Last update timestamp' }), (0, typeorm_1.UpdateDateColumn)(), __metadata("design:type", Date) ], ParkingLot.prototype, "updatedAt", void 0); __decorate([ (0, typeorm_1.OneToMany)(() => parking_history_entity_1.ParkingHistory, (history) => history.parkingLot), __metadata("design:type", Array) ], ParkingLot.prototype, "history", void 0); __decorate([ (0, typeorm_1.OneToMany)(() => parking_update_entity_1.ParkingUpdate, (update) => update.parkingLot), __metadata("design:type", Array) ], ParkingLot.prototype, "updates", void 0); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Occupancy rate as percentage' }), __metadata("design:type", Number), __metadata("design:paramtypes", []) ], ParkingLot.prototype, "occupancyRate", null); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Availability status' }), __metadata("design:type", String), __metadata("design:paramtypes", []) ], ParkingLot.prototype, "availabilityStatus", null); __decorate([ (0, swagger_1.ApiProperty)({ description: 'Whether the parking lot is currently open' }), __metadata("design:type", Boolean), __metadata("design:paramtypes", []) ], ParkingLot.prototype, "isOpen", null); exports.ParkingLot = ParkingLot = __decorate([ (0, typeorm_1.Entity)('parking_lots') ], ParkingLot); //# sourceMappingURL=parking-lot.entity.js.map