| | |
| | | Json::Value responseJsonValue; |
| | | responseJsonValue["message"] = "添加失败!"; |
| | | responseJsonValue["success"] = "false"; |
| | | |
| | | std::map<std::string, std::string> whereKeyValues; |
| | | whereKeyValues["cam_dev_id"] = keyValuesToAdd["cam_dev_id"]; |
| | | if (this->findCamDevList(whereKeyValues)["data"].size() > 0) { |
| | | responseJsonValue["message"] = "cam_dev_id exist!"; |
| | | return responseJsonValue; |
| | | } |
| | | |
| | | QMutexLocker mutexLocker(m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, *m_db); |
| | | |
| | |
| | | rec.setGenerated("id", false); |
| | | |
| | | pModel.insertRecord(-1, rec);//TODO |
| | | |
| | | m_db->transaction();//开始事务操作 |
| | | |
| | | auto id1 = pModel.query().lastInsertId(); |
| | | if (pModel.submitAll()) { |
| | | m_db->commit();//提交 |
| | | responseJsonValue["id"] = pModel.query().lastInsertId().toString().toStdString(); |
| | | responseJsonValue["success"] = "true"; |
| | | responseJsonValue["message"] = "添加成功!"; |
| | | } else { |