package service;

import JDBC.ParkingRecordJDBC;
import pojo.ParkingRecord;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Map;

public class ParkingRecordService {
    ParkingRecordJDBC db = new ParkingRecordJDBC();
    public ParkingRecord getLatestRecord(String car_license) throws Exception {
        return db.selectLatestRecord(car_license);
    }

    public void updateEndTime(int record_id, Timestamp end_time) throws Exception {
        db.setEndTime(record_id, end_time);
    }

    public void addNewRecord(ParkingRecord newRecord) throws Exception {
        db.insertNewRecord(newRecord);
    }


    public List<ParkingRecord> getAllRecords() throws Exception {
        return db.selectAllRecords();
    }

    public List<ParkingRecord> getRecordsByCase(String car_license, String location, Timestamp startTime, Timestamp endTime) throws Exception {
        return db.selectRecordsByCase(car_license, location, startTime, endTime);
    }

    public Map<String, Double> getTopCost() throws Exception {
        return db.selectTopCost();
    }

    public Map<Date, Double> getMonthIncome() throws Exception {
        return db.selectMonthIncome();
    }

    public List<ParkingRecord> GetAllRecordbySpot_Id(int spot_id) throws Exception {
        return db.GetAllRecordbySpot_Id(spot_id);
    }

    public int getBusyNum() throws Exception {
        return db.selectBusyNum();
    }
    public int getUserSum() throws Exception {
        return db.selectUserSum();
    }

    public Map<Integer, Double> getHourMins() throws Exception {
        return db.selectHourMins();
    }

    public Map<String, Double> getLocationMins() throws Exception {
        return db.selectLocationMins();
    }
}



