You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
呓喵酱
2c7df05dfe
|
5 years ago | |
---|---|---|
.. | ||
README.md | 5 years ago |
README.md
API
后端综述
- 提供四个类,分别是
Park
(停车场控制器),Plot
(停车位),Car
(车辆),FeeTable
(费用计算器) - 使用C++14标准,使用多线程,字符集utf-8
- API设计主要提供方法(函数), 不提供属性
Park
构造
Park()
: 构造一个Park对象
本类提供实例化的对象应全局唯一,如果重复声明会出现异常
请在程序启动时实例化,然后再进行登录等操作(此时会在后台整理数据)
初始化相关函数
bool isExist()
: 判断数据库中是否存在Parkvoid ini(std::vector<std::map<string, int>>& v)
: 若不存在,使用这个函数初始化新Park(第一次登录)
请传入一个map的vector。map的键名为停车位种类,键值为个数。vector顺序代表层数,从0层开始。
void updateFeeTable(std::map<string, std::vector<int>>& m)
: 更新费用计算方法。map的键名是种类type, 键值是这个type的计费方式,用vector表示。注意vector从0开始,顺序对应小时,最大为24小时。对应的值是这一小时的计费。首次运行时,本函数必须在ini()之后调用。
获取Park信息函数
const int getMaxLevel()
: 获取Park层数
获取车位函数
const std::vector<string> getPlotsID()
: 获取全部车位IDconst std::vector<string> getPlotsID(const bool isOccupied)
: 获取全部占有/未占有车位IDconst std::vector<string> getPlotsID(const int& level)
: 获取某一层的全部车位IDconst std::vector<string> getPlotsID(const int& level, const bool isOccupied)
: 获取某一层的已占有/未占有车位IDconst std::vector<string> getPlotsID(const string& type)
: 获取某一类型全部车位IDconst std::vector<string> getPlotsID(const string& type, const bool isOccupied)
: 获取某一类型占有/未占有车位IDconst std::vector<string> getPlotsID(const int& level, const string& type)
: 获取某一层,某一种类全部车位IDconst std::vector<string> getPlotsID(const int& level, const string& type, const bool isOccupied)
: 获取某一层,某一种类占有/未占有车位IDPlot getPlot(const string& id)
: 根据ID获取车位对象Plot getPlotByCar(const string& licenseNum)
: 根据车牌号获取车位对象Plot getPlotByCar(const Car& car)
: 根据car对象获取车位对象
注:通过牌号等返回的Plot可能不存在,使用前请使用
bool Plot.isExist()
判断
获取车函数
const std::vector<string> getCarsID()
: 获取全部停车场中的车牌号const std::vector<string> getCarsID(const int& level)
: 获取某一层的全部车牌号const std::vector<string> getCarsID(const string& type)
: 获取某一类型全部车牌号const std::vector<string> getCarsID(const int& level, const string& type)
: 获取某一层,某一种类全部车牌号Car getCar(const string& licenseNum)
: 根据车牌号获取车对象Car getCarByPlot(const string& id)
: 根据plot的id获取车对象Car getCarByPlot(const Plot& plot)
: 根据plot对象获取车对象
功能函数
bool checkIn(const string& licenseNum, const string& type, string& errMsg)
: 本函数适用于车进入停车场时登记。成功返回true,失败(车位已满)返回false。失败信息将追加到errMsg中。所有errMsg参数均可不填。bool checkIn(const string& licenseNum, const string& type, const int& level, string& errMsg)
: 指定层数登记。成功返回true,失败返回false。错误信息追加到errMsg。bool checkInByPlotID(const string& licenseNum, const string& type, const string& plotID, string& errMsg)
: 指定plotID登记,失败信息追加errMsg。int checkOut(const string& licenseNum)
: 车出停车场时结算,输出整数金额。异常则返回-1。
更改设置函数
void updatePlot(const Plot& plot, const int& level)
: 更改plot的levelvoid updatePlot(const Plot& plot, const string& type)
: 更改plot的种类
读取日志
当车checkOut时,记录会被自动记入日志
提取日志前请务必确认有日志存在
日志返回数据使用ovo::data类型,类似map<string, string>。详见这里
std::vector<ovo::data> getLog()
: 获取全部记录std::vector<ovo::data> getLogByDate(const string& date)
: 根据日期获取记录,格式2019-05-24
std::vector<ovo::data> getLogByCarID(const string& licenseNum)
: 根据车牌号获取记录std::vector<ovo::data> getLogByType(const string& type)
: 根据车类型获取记录std::vector<ovo::data> getLogByLevel(const int& level)
: 根据层数获取记录std::vector<ovo::data> getLogByfee(const int& fee)
: 根据计费获取记录std::vector<ovo::data> getLogByType(const string& type, const string& date)
: 根据车类型和日期获取记录std::vector<ovo::data> getLogByLevel(const int& level, const string& date)
: 根据层数和日期获取记录
Car
函数
const bool isExist()
:是否存在const string getID()
: 获取车牌号const string getType()
: 获取种类const string getPlot()
: 获取车位编号const string getID()
: 获取车牌号const string getLastInTime()
: 获取出场时间戳const string getLastOutTime()
: 获取出场时间戳const string showAll()
: JSON格式打印car的所有数据到字符串
Plot
函数
const bool isExist()
:是否存在const bool isOccupied()
:是否被占有const string getID()
: 获取车位编号const string getType()
: 获取车位种类const int getLevel()
: 获取车位所在层数const string getCar()
: 获取车牌号const string showAll()
: JSON格式打印plot的所有数据到字符串
时间安排
- 周五下午5点提供完整代码。