#ifndef HPROJECTDAO_H
#define HPROJECTDAO_H

#include <QList>
#include <QMessageBox>
#include <QObject>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlRecord>

#include "HProject.h"

struct PaginatedHProjectResult {
    QList<QSharedPointer<HProject>> projects;
    int totalCount;
};

class HProjectDao {
   public:
    HProjectDao(QSqlDatabase db);
    bool addHProject(const HProject &project);
    bool updateHProject(const HProject &project);
    bool deleteHProject(const HProject &project);
    bool updateBlastStatusByUuid(const QString &uuid, const QString &blastStatus);
    HProject getHProjectById(qint64 id);
    PaginatedHProjectResult getAllHProjects(int page, int pageSize);
    PaginatedHProjectResult getAllHProjectsByOpera(int page, int pageSize);
    QList<QSharedPointer<HProject>> getAllHProjectsReg();
    QList<QSharedPointer<HProject>> getRegistedProjectByAddressUuid(QList<QString> addressUuids);

   private:
    QSqlDatabase database;
    // 将QSqlRecord转换为HProject对象
    QSharedPointer<HProject> recordToProject(const QSqlRecord &record);
};

#endif  // HPROJECTDAO_H
