|
|
@ -199,6 +199,7 @@ void MainControlService::processFrontEndMessage_userOperate(weak_ptr<WebSocket> |
|
|
|
return; |
|
|
|
} |
|
|
|
m_deviceStateService->setLoginState(uid, m_dbService->getUser(uid)->permission_level, m_dbService->getUser(uid)->visible); |
|
|
|
m_dbService->addUserBehaviorRecord(uid, kbehavior_login, ""); |
|
|
|
logger->info("user {} login success", uid); |
|
|
|
} |
|
|
|
|
|
|
@ -211,6 +212,7 @@ void MainControlService::processFrontEndMessage_userOperate(weak_ptr<WebSocket> |
|
|
|
if (cmdstr == "unlogin") { |
|
|
|
m_deviceStateService->unlogin(); |
|
|
|
logger->info("user unlogin success"); |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_logout, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -232,7 +234,10 @@ void MainControlService::processFrontEndMessage_userOperate(weak_ptr<WebSocket> |
|
|
|
receipt["ackcodeInfo"] = err::error_code_get_desc(err::kce, err::kpasswd_error, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
m_dbService->changePasswd(uid, newpasswd); |
|
|
|
auto user = m_dbService->changePasswd(uid, newpasswd); |
|
|
|
// kbehavior_update_user_passwd
|
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_update_user_passwd, fmt::format("({})", uid)); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -241,19 +246,45 @@ void MainControlService::processFrontEndMessage_userOperate(weak_ptr<WebSocket> |
|
|
|
string passwd = cmd["passwd"]; |
|
|
|
int permission_level = jsonGet<int>(cmd["permission_level"]); |
|
|
|
m_dbService->addUser(uid, passwd, permission_level); |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_add_user, fmt::format("({})", uid)); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (cmdstr == "delUser") { |
|
|
|
int id = jsonGet<int>(cmd["id"]); |
|
|
|
m_dbService->delUser(id); |
|
|
|
int id = jsonGet<int>(cmd["id"]); |
|
|
|
auto user = m_dbService->delUser(id); |
|
|
|
if (!user) { |
|
|
|
receipt["ackcode"] = err::error_code_get_get_ecode(err::kce, err::kuser_not_exist); |
|
|
|
receipt["ackcodeInfo"] = err::error_code_get_desc(err::kce, err::kuser_not_exist, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_del_user, fmt::format("({})", user->uid)); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (cmdstr == "updateUserPermissionLevel") { |
|
|
|
int id = jsonGet<int>(cmd["id"]); |
|
|
|
int permission_level = jsonGet<int>(cmd["permission_level"]); |
|
|
|
m_dbService->updateUserPermissionLevel(id, permission_level); |
|
|
|
int id = jsonGet<int>(cmd["id"]); |
|
|
|
int permission_level = jsonGet<int>(cmd["permission_level"]); |
|
|
|
auto user = m_dbService->updateUserPermissionLevel(id, permission_level); |
|
|
|
if (!user) { |
|
|
|
receipt["ackcode"] = err::error_code_get_get_ecode(err::kce, err::kuser_not_exist); |
|
|
|
receipt["ackcodeInfo"] = err::error_code_get_desc(err::kce, err::kuser_not_exist, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_update_user_permission_level, |
|
|
|
fmt::format("({},{})", user->uid, permission_level)); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (cmdstr == "updateUserUid") { |
|
|
|
int id = jsonGet<int>(cmd["id"]); |
|
|
|
string uid = cmd["uid"]; |
|
|
|
string olduid; |
|
|
|
auto user = m_dbService->updateUserUid(id, uid, olduid); |
|
|
|
if (!user) { |
|
|
|
receipt["ackcode"] = err::error_code_get_get_ecode(err::kce, err::kuser_not_exist); |
|
|
|
receipt["ackcodeInfo"] = err::error_code_get_desc(err::kce, err::kuser_not_exist, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_update_user_uid, fmt::format("({}->{})", olduid, uid)); |
|
|
|
} |
|
|
|
if (cmdstr == "getAllUser") { |
|
|
|
auto users = m_dbService->getAllUserJson(); |
|
|
|
receipt["dbval"] = users; |
|
|
@ -334,6 +365,8 @@ void MainControlService::processFrontEndMessage_Disinfection(weak_ptr<WebSocket> |
|
|
|
m_dbService->getSettingVal("continued_satur"), //
|
|
|
|
m_dbService->getSettingVal("stoped_humi"), //
|
|
|
|
m_dbService->getSettingVal("continued_humi")); |
|
|
|
// kbehavior_do_disinfection
|
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_do_disinfection, fmt::format("({})", jsonGet<int>(cmd["loglevel"]))); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (cmdstr == "changeDisinfectionParameter") { |
|
|
@ -349,6 +382,7 @@ void MainControlService::processFrontEndMessage_Disinfection(weak_ptr<WebSocket> |
|
|
|
|
|
|
|
if (cmdstr == "stopDisinfection") { |
|
|
|
m_disinfectionCtrlService->stopDisinfection(); |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_stop_disinfection, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -436,11 +470,13 @@ void MainControlService::processFrontEndMessage_setting(weak_ptr<WebSocket> webS |
|
|
|
string settingName = cmd["settingName"]; |
|
|
|
int settingVal = jsonGet<int>(cmd["settingVal"]); |
|
|
|
bool suc = m_dbService->setSettingVal(settingName, settingVal); |
|
|
|
|
|
|
|
if (!suc) { |
|
|
|
receipt["ackcode"] = err::error_code_get_get_ecode(err::kce, err::kdb_operate_error); |
|
|
|
receipt["ackcodeInfo"] = err::error_code_get_desc(err::kce, err::kdb_operate_error, "setSettingVal fail"); |
|
|
|
return; |
|
|
|
} |
|
|
|
return; |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_set_setting_val, fmt::format("({},{})", settingName, settingVal)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -466,6 +502,9 @@ void MainControlService::processFrontEndMessage_processFormulaCmd(weak_ptr<WebSo |
|
|
|
atoi(formul->continued_satur.c_str()), //
|
|
|
|
atoi(formul->stoped_humi.c_str()), //
|
|
|
|
atoi(formul->continued_humi.c_str())); //
|
|
|
|
|
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_do_formula, fmt::format("({})", formul->formula_id)); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
if (cmdstr == "getAllFormula") { |
|
|
@ -474,6 +513,7 @@ void MainControlService::processFrontEndMessage_processFormulaCmd(weak_ptr<WebSo |
|
|
|
} |
|
|
|
|
|
|
|
if (cmdstr == "addFormula") { |
|
|
|
string formula_id = cmd["formula_id"]; |
|
|
|
m_dbService->addFormula(cmd["formula_id"], //
|
|
|
|
jsonGet<int>(cmd["stoped_gs"]), //
|
|
|
|
jsonGet<int>(cmd["continued_gs"]), //
|
|
|
@ -482,11 +522,16 @@ void MainControlService::processFrontEndMessage_processFormulaCmd(weak_ptr<WebSo |
|
|
|
jsonGet<int>(cmd["stoped_humi"]), //
|
|
|
|
jsonGet<int>(cmd["continued_humi"]), //
|
|
|
|
jsonGet<int>(cmd["injection_pump_speed"])); |
|
|
|
// kbehavior_add_formula
|
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_add_formula, fmt::format("({})", formula_id)); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (cmdstr == "delFormula") { |
|
|
|
m_dbService->delFormula(jsonGet<int>(cmd["id"])); |
|
|
|
auto formula = m_dbService->delFormula(jsonGet<int>(cmd["id"])); |
|
|
|
if (formula) { |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_del_formula, fmt::format("({})", formula->formula_id)); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -497,7 +542,11 @@ void MainControlService::processFrontEndMessage_processFormulaCmd(weak_ptr<WebSo |
|
|
|
} else { |
|
|
|
val_str = std::to_string(cmd["val"].get<int>()); |
|
|
|
} |
|
|
|
m_dbService->updateFormula(jsonGet<int>(cmd["id"]), cmd["column"], val_str); |
|
|
|
auto formula = m_dbService->updateFormula(jsonGet<int>(cmd["id"]), cmd["column"], val_str); |
|
|
|
if (formula) { |
|
|
|
m_dbService->addUserBehaviorRecord(m_deviceStateService->getLoginUid(), kbehavior_update_formula, |
|
|
|
fmt::format("({},{},{})", formula->formula_id, cmd["column"], val_str)); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -521,16 +570,20 @@ void MainControlService::processFrontEndMessage_processBehaviorRecordCmd(weak_pt |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_add_user, "(zhaohe)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_del_user, "(zhaohe)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_update_user_permission_level, "(zhaohe,3)"); |
|
|
|
// kbehavior_update_user_uid
|
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_update_user_passwd, "()"); |
|
|
|
|
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_set_setting_val, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_add_formula, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_del_formula, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_update_formula, "(....)"); |
|
|
|
|
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_do_disinfection, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_stop_disinfection, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_do_formula, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_update_setting_val_on_disinfection, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_export_data, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_export_disinfection_data, "(....)"); |
|
|
|
m_dbService->addUserBehaviorRecord("admin", kbehavior_export_user_action_data, "(....)"); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|