class EntryPoint(db.Model): __tablename__ = "entryPoint" id = db.Column(db.Integer, primary_key=True) floorNumber = db.Column(db.Integer, primary_key=True) vehicleCount = db.Column(db.Integer, nullable=False) displayID = db.Column(db.Integer, db.ForeignKey("displayBoard.id"), nullable=False) parkingLotID = db.Column(db.Integer, db.ForeignKey("parkingLot.id"), primary_key=True)
class Vehicle(db.Model): __tablename__ = "vehicle" vehicleID = db.Column(db.String, primary_key=True) vehicleNumber = db.Column(db.String, primary_key=True) ticketNumber = db.Column(db.String, db.ForeignKey("ticket.ticketNumber"), primary_key=True, nullable=False) customerID = db.Column(db.Integer, db.ForeignKey("customer.customerID"), nullable=False) vehicleType = db.Column(db.String, nullable=False)
class LastConnection(db.Model): __tablename__ = "lastConnection" id = db.Column(db.Integer, autoincrement=True, primary_key=True) floorNumber = db.Column(db.Integer, primary_key=True) parkingLotID = db.Column(db.Integer, db.ForeignKey("parkingLot.id"), primary_key=True) spotID = db.Column(db.Integer, db.ForeignKey("chargingPanel.spotID"), primary_key=True) connect = db.Column(db.DateTime, nullable=False) disconnect = db.Column(db.DateTime, nullable=True) ticketNumber = db.Column(db.String, db.ForeignKey("ticket.ticketNumber"), nullable=False)
class ChargingPanel(db.Model): __tablename__ = "chargingPanel" spotID = db.Column(db.Integer, primary_key=True) floorNumber = db.Column(db.Integer, primary_key=True) parkingLotID = db.Column(db.Integer, db.ForeignKey("parkingLot.id"), primary_key=True) lastConnectionID = db.Column(db.Integer, db.ForeignKey("lastConnection.id"), primary_key=True) ticketNumber = db.Column(db.String, db.ForeignKey("ticket.ticketNumber"), nullable=True) vehicleNumber = db.Column(db.String, db.ForeignKey("vehicle.vehicleNumber"), nullable=True)
class DisplayBoard(db.Model): __tablename__ = "displayBoard" id = db.Column(db.Integer, primary_key=True) parkingLotID = db.Column(db.Integer, db.ForeignKey("parkingLot.id"), primary_key=True) floorNumber = db.Column(db.Integer, primary_key=True) message = db.Column(db.String, nullable=True) userID = db.Column(db.Integer, db.ForeignKey("parkingAttendant.parkingAttendantId"), nullable=True) timeStamp = db.Column(db.DateTime, nullable=True) entryPointID = db.Column(db.Integer, db.ForeignKey("entryPoint.id"), nullable=True) exitPointID = db.Column(db.Integer, db.ForeignKey("exitPoint.id"), nullable=True)
class ParkingSpot(db.Model): __tablename__ = "parkingSpot" spotID = db.Column(db.Integer, primary_key=True) parkingLotID = db.Column(db.Integer, db.ForeignKey("parkingLot.id"), primary_key=True) floorNumber = db.Column(db.Integer, primary_key=True) spotType = db.Column(db.String, primary_key=True) status = db.Column(db.Boolean, nullable=False) rowNumber = db.Column(db.Integer, nullable=False) columnNumber = db.Column(db.Integer, nullable=False)
class Capacity(db.Model): __tablename__ = "capacity" floorNumber = db.Column(db.Integer, primary_key=True) totalFloors = db.Column(db.Integer, nullable=False) parkingLotID = db.Column(db.Integer, db.ForeignKey("parkingLot.id"), primary_key=True, nullable=False) carSpots = db.Column(db.Integer, nullable=False) bikeSpots = db.Column(db.Integer, nullable=False) truckSpots = db.Column(db.Integer, nullable=False) electricCarSpots = db.Column(db.Integer, nullable=False)
class Ticket(db.Model): __tablename__ = "ticket" ticketNumber = db.Column(db.String, primary_key=True) customerID = db.Column(db.Integer, db.ForeignKey("customer.customerID"), nullable=False) vehicleNumber = db.Column(db.String, db.ForeignKey("vehicle.vehicleNumber"), nullable=False) parkingAttendantID = db.Column( db.Integer, db.ForeignKey("parkingAttendant.parkingAttendantId"), nullable=True) inTime = db.Column(db.DateTime, nullable=False) outTime = db.Column(db.DateTime, nullable=True) isPaid = db.Column(db.Boolean, nullable=False) spotID = db.Column(db.Integer, db.ForeignKey("parkingSpot.spotID"), nullable=False) checkTime = db.Column(db.DateTime, nullable=True) def _repr__(self): return "inTime: %s" % self.inTime
class Customer(db.Model, UserMixim): __tablename__ = "customer" customerID = db.Column(db.String, primary_key=True) vehicleID = db.Column(db.String, db.ForeignKey("vehicle.vehicleID"), nullable=False) ticketNumber = db.Column(db.String, db.ForeignKey("ticket.ticketNumber"), nullable=True) firstName = db.Column(db.String, nullable=False) middleName = db.Column(db.String, nullable=True) lastName = db.Column(db.String, nullable=False) contactNumber = db.Column(db.Integer, nullable=False) password = db.Column(db.String, nullable=True) def __repr__(self): idLine = "Customer ID: %s" % (self.customerID) nameLine = "First Name: %s, Middle Name: %s, Last Name: %s" % ( self.firstName, self.middleName, self.lastName) contactNumber = "Contact Number: %s" % (self.contactNumber) vehicleInfo = "Vehicle Number: %s, Vehicle Type: %s, ticketNumber: %s" % ( self.vehicleNumber, self.vehicleType, self.ticketNumber) return '\n'.join([idLine, nameLine, contactNumber, vehicleInfo])