#ifndef PACKINFOMANGER_H
#define PACKINFOMANGER_H

#include <QObject>
#include <QDir>
#include <QList>
#include <QDate>
#include "struct_/packinfo.h"
#include "struct_/modelinfo.h"
// 管理本地码单（箱单） 的类
// 管理本地批号的类

struct PackSaveInfo
{
    QSharedPointer<PackInfo> packInfo;
    QString absPath;

    inline bool isSync() const{
        return !absPath.contains("_sync");
    }
};

struct BoxModelSaveInfo
{
    QSharedPointer<BoxModel> boxModel;
};


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

    QList<PackSaveInfo> getPackInfo(const QDate & tm,bool noSync = false);
    QList<PackSaveInfo> getPackInfoSync(const QDate & tm);
    QDate lastSyncDate();

    QList<QSharedPointer<ProjectInfo>>  getLocalProjectInfo();
signals:

public slots:
    QString savePackInfo(const QSharedPointer<PackInfo> & info);

    QString setPackInfoSync(const QString & code, qint64 time = -1,bool autoSync = false);

    bool syncLocalProjectInfo(QList<QSharedPointer<ProjectInfo>> & projects);

    QList<QSharedPointer<BoxModel>> getBoxModel();

    QList<QSharedPointer<PackModel>> getPackModel();
private:
    QDir getDir(const QDate & tm,bool create = false);
private:
    QDir _dataDir;
};

#endif // PACKINFOMANGER_H
