#ifndef INTERACTIVEHTTP_H
#define INTERACTIVEHTTP_H

#include <QObject>

#include <QTimer>
#include <QFile>
#include <QEventLoop>

#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QHttpMultiPart>
#include <QHttpPart>

#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>

#define HTTP_REQUEST_TIMEOUT_TIME 1000 * 20

class InteractiveHttp : public QObject
{
    Q_OBJECT
public:
    explicit InteractiveHttp(QObject *parent = nullptr);

    // 全局函数
    static bool httpRequestGet(const QString &url, const QByteArray &inData, QByteArray &outData);
    static bool httpRequestPostJson(const QString &url, const QByteArray &inData, QByteArray &outData);
    static bool httpRequestPostFormdata(const QString &url, QList<QHttpPart> &inData, QByteArray &outData);

    static QString strToken;
private:
    static void TempWriteData(const QString &path, const QByteArray &data);

public:

    // 获取异常类型字典值
    // url: /system/dict/data/type/material_exception
    static QByteArray http_get_exception_type();

    // 获取严重等级字典值
    // url: /system/dict/data/type/severity_level
    static QByteArray http_get_severity_level();

    // 获取用户信息
    // url: /getInfo
    static QByteArray http_get_getInfo();


    // 获取主界面显示信息
    // url: /iscs/hardware/material-api/getCabinetHomePage
    static QByteArray http_get_getCabinetHomePage();


    // 查询物资使用说明
    // url: /prod-api/iscs/hardware/material-api/getInstructionsList
    static QByteArray http_get_getInstructionsList();

    // 获取物资信息
    // url: /prod-api/iscs/materials/getIsMaterialsPage
    static QByteArray http_get_getIsMaterialsPage();

    // 获取物资柜物资错放异常
    // url: /iscs/exception/getIsMaterialsLoanExceptionPage
    static QByteArray http_get_getIsMaterialsLoanExceptionPage();

    // 查询用户特征
    // url: /system/user/characteristic/getSysUserCharacteristicPage
    static QByteArray http_get_getSysUserCharacteristicPage();


    // 查询物资检查计划
    // url: /iscs/hardware/material-api/getLastCheckPlanByCabinetCode
    static QByteArray http_get_getLastCheckPlanByCabinetCode();

    // 查询异常物资信息
    // url: /iscs/hardware/material-api/selectExMaterialTypeById
    static QByteArray http_get_selectExMaterialTypeById();

    // 根据物资柜code获取物资柜ID
    // url: /iscs/cabinet/selectIsMaterialsCabinetByCode
    static QByteArray http_get_selectIsMaterialsCabinetByCode();



    // 开始检查
    // url: /iscs/hardware/material-api/startCheckPlan
    static QByteArray http_post_startCheckPlan();

    // 保存检查状态
    // url: /iscs/hardware/material-api/insertCheckRecord
    static QByteArray http_post_insertCheckRecord(const QByteArray &json);

    // 查询物资信息
    // url: /iscs/hardware/material-api/selectMaterialsByRfidList
    static QByteArray http_post_selectMaterialsByRfidList(const QStringList &rfids);

    // 提交最终检查结果
    // url: /iscs/hardware/material-api/insertSubmitPlan
    static QByteArray http_post_insertSubmitPlan();


    // 上报异常
    // url: /iscs/exception/insertIsException
    static QByteArray http_post_insertIsException(const QString &json);

    // 删除用户特征
    // url: /system/user/characteristic/deleteSysUserCharacteristicByRecordIds
    static QByteArray http_post_deleteSysUserCharacteristicByRecordIds(const QString &recordIds);

    // 新增面部信息
    // url: /system/user/characteristic/insertUserFace
    static QByteArray http_post_insertUserFace();

    // 新增指纹信息
    // url: /system/user/characteristic/insertUserFingerprintDat
    static QByteArray http_post_insertUserFingerprintDat(const QString &group);

    // 根据人脸登录
    // url: /loginByFace
    static QByteArray http_post_loginByFace();

    // 根据指纹登录
    // url: /loginByFingerprintDat
    static QByteArray http_post_loginByFingerprintDat();

};

#endif // INTERACTIVEHTTP_H
