#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>
#include <QtQml/qqml.h>

#define HTTP_REQUEST_TIMEOUT_TIME 1000 * 20

class InteractiveHttp : public QObject
{
    Q_OBJECT

    QML_NAMED_ELEMENT(InteractiveHttp)
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();
};

#endif // INTERACTIVEHTTP_H
