mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
完成系统管理web端功能,实现系统管理服务端接口,实现登录功能
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//#include "PvInstance.h"
|
||||
//#include "spdlogger.h"
|
||||
|
||||
MysqlOptions DaoEntity::options_;
|
||||
MysqlOption DaoEntity::option_;
|
||||
|
||||
DaoEntity::DaoEntity(string tb_name)
|
||||
{
|
||||
@@ -12,7 +12,7 @@ DaoEntity::DaoEntity(string tb_name)
|
||||
//opts.password = "123456";
|
||||
//opts.port = 3306;
|
||||
//opts.dbname = "pvb";
|
||||
db_ = make_shared<MysqlClient>(DaoEntity::options_);
|
||||
db_ = make_shared<MysqlClient>(DaoEntity::option_);
|
||||
if (!db_->isConnected())
|
||||
{
|
||||
//Global::data().status_msg = "数据库连接异常!";
|
||||
@@ -26,9 +26,17 @@ DaoEntity::~DaoEntity()
|
||||
db_ = nullptr;
|
||||
}
|
||||
|
||||
MysqlOptions& DaoEntity::mysqlOptions()
|
||||
MysqlOption& DaoEntity::mysqlOption()
|
||||
{
|
||||
return DaoEntity::options_;
|
||||
return DaoEntity::option_;
|
||||
}
|
||||
void DaoEntity::setOption(std::string host, int port, std::string user, std::string pwd, std::string dbname)
|
||||
{
|
||||
option_.host = host;
|
||||
option_.port = port;
|
||||
option_.user = user;
|
||||
option_.password = pwd;
|
||||
option_.dbname = dbname;
|
||||
}
|
||||
|
||||
std::shared_ptr<DaoEntity> DaoEntity::create(string tb_name)
|
||||
@@ -39,13 +47,13 @@ std::shared_ptr<DaoEntity> DaoEntity::create(string tb_name)
|
||||
|
||||
bool DaoEntity::execOnce(string sql)
|
||||
{
|
||||
auto db = make_shared<MysqlClient>(DaoEntity::options_);
|
||||
auto db = make_shared<MysqlClient>(DaoEntity::option_);
|
||||
return db->exec(sql);
|
||||
}
|
||||
|
||||
bool DaoEntity::execOnce(string sql, vector<DataFields>& result)
|
||||
{
|
||||
auto db = make_shared<MysqlClient>(DaoEntity::options_);
|
||||
auto db = make_shared<MysqlClient>(DaoEntity::option_);
|
||||
return db->exec(sql, result);
|
||||
}
|
||||
|
||||
@@ -141,7 +149,7 @@ bool DaoEntity::duplicateUpdate(DataFields& fields, vector<string>& keys)
|
||||
{
|
||||
s_data += ",";
|
||||
}
|
||||
s_data += (k + "='" + fields.get_str(k) + "'");
|
||||
s_data += (k + "='" + fields.getStr(k) + "'");
|
||||
}
|
||||
string sql = "INSERT INTO " + tableName_ + "(" + s_key + ") VALUES (" + s_val + ") ON duplicate KEY UPDATE " + s_data;
|
||||
return this->db_->exec(sql);
|
||||
@@ -178,7 +186,7 @@ bool DaoEntity::queryFields(string keys, const string& sql_c, PageInfo& pageinfo
|
||||
pageinfo.total = 0;
|
||||
return true;
|
||||
}
|
||||
pageinfo.total = res_total[0].get_int("total");
|
||||
pageinfo.total = res_total[0].getInt("total");
|
||||
if (pageinfo.total <= 0)
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user