mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-28 03:09:24 +08:00
实现MQTT功能, 修改HTTP接口
This commit is contained in:
@@ -88,7 +88,7 @@ static Errcode QueryCount(DaoEntity& dao, std::string sqlFrom, int& count)
|
||||
{
|
||||
std::vector<Fields> result;
|
||||
int ret = dao.exec("SELECT COUNT(*) count " + sqlFrom, result);
|
||||
if (ret != 0)
|
||||
if (ret == 0)
|
||||
{
|
||||
count = (result.size() > 0) ? result[0].get<int>("count") : 0;
|
||||
}
|
||||
@@ -110,8 +110,9 @@ static Errcode QueryPagination(std::string sqlFields, std::string sqlCondition,
|
||||
return err;
|
||||
}
|
||||
|
||||
if (page.index < 1) page.index = 1;
|
||||
page.total = count;
|
||||
std::string sql = "SELECT " + sqlFields + " " + sqlCondition + DAO::sqlPageLimit(page.index, page.size);
|
||||
std::string sql = "SELECT " + sqlFields + " " + sqlCondition + DAO::sqlPageLimit(page.index -1, page.size);
|
||||
int ret = dao.exec(sql, result);
|
||||
return Errcode(ret);
|
||||
}
|
||||
@@ -555,4 +556,11 @@ Errcode DAO::queryPolicyTypeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>&
|
||||
{
|
||||
std::string sql = "SELECT * FROM " + DMDefPolicyType::TABLENAME + ";";
|
||||
return DAO::exec(dao, sql, result);
|
||||
}
|
||||
|
||||
Errcode DAO::insertRuntimeData(std::shared_ptr<DaoEntity> dao, Fields& fields)
|
||||
{
|
||||
if (!dao) { dao = DaoEntity::create("history1"); }
|
||||
int ret = dao->duplicateUpdate(fields, {"value"});
|
||||
return Errcode(ret);
|
||||
}
|
||||
Reference in New Issue
Block a user