#ifndef BASEDAO_H
#define BASEDAO_H

#include <QObject>

#include "dao/CommonData.h"
#include "dao/util/CdbConnectionPool.h"
#include "dao/util/IdWorker.h"
#include "utils/utilsInclude.h"

struct Page {
    int pageSize = 15;
    int currentPage = 0;
    int totalPage = 0;
    int totalCount = 0;
};

class BaseDao {

public:
    Jiawa::Core::IdWorker& idWorker = Jiawa::Core::Singleton<Jiawa::Core::IdWorker>::instance();

    QString appendSchemaName(QString sql, QStringList tableNames)
    {
        if (SettingConfig::getInstance().LOCAL_SCHEMA.isEmpty()) {
            return sql;
        } else {
            QString result = sql;
            for (QString table : tableNames) {
                result.replace(table, QString("%1.%2").arg(SettingConfig::getInstance().LOCAL_SCHEMA).arg(table));
            }

            return result;
        }
    }
};

#endif // BASEDAO_H
