diff --git a/appsrc/baseservice/db/db_service.cpp b/appsrc/baseservice/db/db_service.cpp index 609c5ab..c2b5da2 100644 --- a/appsrc/baseservice/db/db_service.cpp +++ b/appsrc/baseservice/db/db_service.cpp @@ -73,11 +73,13 @@ void DBService::init_usr_db() { logger->info("init user db"); auto storage = make_storage(USER_DB_STRUCT); storage.sync_schema(); - auto admin = storage.get_all(where(c(&User::uid) == "admin")); + auto allusr = storage.get_all(); + + auto admin = storage.get_all(where(c(&User::is_admin) == true)); if (admin.size() == 0) { storage.insert({-1, "管理员", "9973", true}); // 管理员 } - auto user = storage.get_all(where(c(&User::uid) == "user")); + auto user = storage.get_all(where(c(&User::is_admin) == false)); if (user.size() == 0) { storage.insert({-1, "用户0", "0000", false}); // 普通用户 } diff --git a/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp b/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp index dd4c144..d42387a 100644 --- a/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp +++ b/appsrc/baseservice/front_msg_processer/front_msg_processer.cpp @@ -90,22 +90,25 @@ void FrontMsgProcesser::processMsg(shared_ptr cxt) { } if (int(cxt->receipt["ackcode"]) != 0) { - cxt->receipt["message"] = fmt::format("[{}],{}", ecode2str(cxt->receipt["ackcode"]), cxt->ackcodeExtMessage); + cxt->receipt["message"] = fmt::format("[{}]", ecode2str(cxt->receipt["ackcode"])); + cxt->receipt["extMessage"] = fmt::format("{}", cxt->ackcodeExtMessage); } if (cxt->rely.empty() == false) { cxt->receipt["rely"] = cxt->rely; } } catch (const appexception& e) { - cxt->receipt["ackcode"] = e.ecode(); - cxt->receipt["message"] = fmt::format("[{}],{}", ecode2str(cxt->receipt["ackcode"]), e.description); + cxt->receipt["ackcode"] = e.ecode(); + cxt->receipt["message"] = fmt::format("[{}]", ecode2str(cxt->receipt["ackcode"])); + cxt->receipt["extMessage"] = fmt::format("{}", e.description); } cxt->receipt["fromClass"] = m_msgProcesserMap[key]->className; cxt->receipt["fromFn"] = m_msgProcesserMap[key]->fnName; } else { logger->error("unknown command: {}", key); - cxt->receipt["ackcode"] = err::kappe_cmd_not_support; - cxt->receipt["message"] = fmt::format("[{}],未找到指令 {}", ecode2str(cxt->receipt["ackcode"]), key); + cxt->receipt["ackcode"] = err::kappe_cmd_not_support; + cxt->receipt["message"] = fmt::format("[{}]", ecode2str(cxt->receipt["ackcode"])); + cxt->receipt["extMessage"] = fmt::format("not find cmd: {}", ecode2str(cxt->receipt["ackcode"]), key); } } diff --git a/appsrc/service/audit_mgr_service.cpp b/appsrc/service/audit_mgr_service.cpp index c96e70e..86218b6 100644 --- a/appsrc/service/audit_mgr_service.cpp +++ b/appsrc/service/audit_mgr_service.cpp @@ -24,7 +24,7 @@ void AuditMgrService::initialize() { GET_TO_SERVICE(m_udiskMgr); REG_EXTFN_VOID(exportData, void()); - REG_EXTFN_VOID(getRecords, void()); + REG_EXTFN(getRecords, void(int,int), page, pageSize); REG_EXTFN_VOID(pushTestData, void()); } int AuditMgrService::callExportData() { @@ -84,9 +84,10 @@ void AuditMgrService::exportData(shared_ptr cxt) { } } -void AuditMgrService::getRecords(shared_ptr cxt) { +void AuditMgrService::getRecords(shared_ptr cxt, int page, int page_size) { json& params = cxt->params; - cxt->rely = m_db->getUserBehaviorRecordDescJson(jsonGet(params["page"]), jsonGet(params["page_size"])); + // cxt->rely = m_db->getUserBehaviorRecordDescJson(jsonGet(params["page"]), jsonGet(params["page_size"])); + cxt->rely = m_db->getUserBehaviorRecordDescJson(page, page_size); } void AuditMgrService::pushTestData(shared_ptr cxt) { ADD_USER_BEHAVIOR("123", kbehavior_login, ""); diff --git a/appsrc/service/audit_mgr_service.hpp b/appsrc/service/audit_mgr_service.hpp index 85ff045..fdf141f 100644 --- a/appsrc/service/audit_mgr_service.hpp +++ b/appsrc/service/audit_mgr_service.hpp @@ -22,7 +22,7 @@ class AuditMgrService : public enable_shared_from_this { private: void exportData(shared_ptr cxt); - void getRecords(shared_ptr cxt); + void getRecords(shared_ptr cxt, int page, int page_size); void pushTestData(shared_ptr cxt); int callExportData(); diff --git a/appsrc/service/hardware/device_io_ctrl_service.cpp b/appsrc/service/hardware/device_io_ctrl_service.cpp index f648a2e..a98e9d4 100644 --- a/appsrc/service/hardware/device_io_ctrl_service.cpp +++ b/appsrc/service/hardware/device_io_ctrl_service.cpp @@ -472,8 +472,8 @@ int DeviceIoControlService::AddLiquidPumpPostPS_readPa() { // #define PROCESS_CMD_WITH_RET(fnName, ...) \ if (testFnName == #fnName) { \ - auto ret = fnName(__VA_ARGS__); \ - cxt->rely = ret; \ + auto ret = fnName(__VA_ARGS__); \ + cxt->rely = ret; \ return; \ } diff --git a/appsrc/service/hardware/device_io_ctrl_service.hpp b/appsrc/service/hardware/device_io_ctrl_service.hpp index 4af9650..ec528dc 100644 --- a/appsrc/service/hardware/device_io_ctrl_service.hpp +++ b/appsrc/service/hardware/device_io_ctrl_service.hpp @@ -38,6 +38,7 @@ class DeviceIoControlService : public enable_shared_from_this m_workQueue; shared_ptr m_h2o2SensorDataMgr = make_shared(); + unique_ptr heartThread; public: void initialize(); diff --git a/appsrc/service/user_mgr_service.cpp b/appsrc/service/user_mgr_service.cpp index 35f56ff..2f6ba68 100644 --- a/appsrc/service/user_mgr_service.cpp +++ b/appsrc/service/user_mgr_service.cpp @@ -27,9 +27,9 @@ void UserMgrService::login(shared_ptr cxt, string uid, string } if (!m_db->isUserExist(uid)) // - THROW_APP_EXCEPTION(err::kappe_user_not_exist, fmt::format("user {} not exist", uid)); + THROW_APP_EXCEPTION(err::kappe_user_not_exist, ""); if (!m_db->ispasswdCorrect(uid, pwd)) // - THROW_APP_EXCEPTION(err::kappe_passwd_error, fmt::format("user {} passwd error", uid)); + THROW_APP_EXCEPTION(err::kappe_passwd_error, ""); m_deviceStateService->setLoginState(uid, m_db->getUser(uid)->is_admin); logger->info("user {} login success", uid); @@ -44,7 +44,6 @@ void UserMgrService::unlogin(shared_ptr cxt) { return; } void UserMgrService::chpasswd(shared_ptr cxt, string uid, string newpasswd, string passwd) { - if (!m_deviceStateService->isLoginAdmin()) { APPCHECK(!m_db->ispasswdCorrect(uid, passwd), err::kappe_passwd_error, fmt::format("user {} passwd error", uid)); } @@ -52,9 +51,7 @@ void UserMgrService::chpasswd(shared_ptr cxt, string uid, str logger->info("changet passwd {} {}", uid, passwd); auto user = m_db->changePasswd(uid, newpasswd); } -void UserMgrService::addUser(shared_ptr cxt, string uid, string passwd) { - m_db->addUser(uid, passwd); -} +void UserMgrService::addUser(shared_ptr cxt, string uid, string passwd) { m_db->addUser(uid, passwd); } void UserMgrService::delUser(shared_ptr cxt, int id) { auto user = m_db->delUser(id); APPCHECK(!user, err::kappe_user_not_exist, fmt::format("user {} not exist", id)); @@ -66,7 +63,7 @@ void UserMgrService::updateUserUid(shared_ptr cxt, int id, st APPCHECK(!user, err::kappe_user_not_exist, fmt::format("user {} not exist", id)); } void UserMgrService::getAllUser(shared_ptr cxt) { - auto users = m_db->getAllUserJson(); + auto users = m_db->getAllUserJson(); cxt->receipt["rely"] = users; return; } diff --git a/doc/TODO.md b/doc/TODO.md new file mode 100644 index 0000000..3891db6 --- /dev/null +++ b/doc/TODO.md @@ -0,0 +1,9 @@ + +``` +1. 添加从机心跳检测程序,超时后自动关闭所有硬件 +2. 主机添加复位标志位检测程序 +3. 从机添加设备启动上报包。监听从机复位事件 +4. 添加关机指令 +5. 关闭时间自动更新 (OK) + +``` \ No newline at end of file