#ifndef HPROJECTDAO_H
#define HPROJECTDAO_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QList>
#include <QSqlRecord>
#include <QRegularExpression>
#include "HProject.h"

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

class HProjectDao
{

public:
    HProjectDao(QSqlDatabase db);


    // 添加一个新的HProject记录
    bool addHProject(const HProject &project);

    // 更新现有的HProject记录
    bool updateHProject(const HProject &project);

    // 删除一个HProject记录
    bool deleteHProject(const HProject &project);

    // 根据ID获取HProject记录
    HProject getHProjectById(qint64 id);

    bool updateBlastStatusByUuid(const QString &uuid, const QString &blastStatus);

    PaginatedHProjectResult getAllHProjects(int page, int pageSize);

    PaginatedHProjectResult getAllHProjectsByOpera(int page, int pageSize);


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

#endif // HPROJECTDAO_H
