Merge branch 'master' of ssh://115.28.86.8:29418/~admin/昆仑_1025
1 文件已重命名
24个文件已修改
19个文件已添加
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE QtCreatorProject> |
| | | <!-- Written by QtCreator 4.5.0, 2024-10-31T16:02:45. --> |
| | | <!-- Written by QtCreator 4.5.0, 2024-11-04T20:34:52. --> |
| | | <qtcreator> |
| | | <data> |
| | | <variable>EnvironmentId</variable> |
| | |
| | | PmsClientSocket::PmsClientSocket(QWidget * parent):QWidget(parent) |
| | | { |
| | | client = new QTcpSocket(this); |
| | | |
| | | connect(client,SIGNAL(connected()),this,SLOT(connected_Slot())); |
| | | client->connectToHost(targetIp,port); |
| | | if(!client->waitForConnected(3000)){ |
| | | |
| | |
| | | } |
| | | connectSuccess = true; |
| | | qDebug()<< "QTç½ç»éä¿¡æåå·²è¿æ¥æå¡å¨ï¼"; |
| | | connect(client,SIGNAL(connected()),this,SLOT(connected_Slot())); |
| | | |
| | | } |
| | | |
| | | void PmsClientSocket::queryAllUserAboutUser() |
| | | { |
| | | if(connectSuccess){ |
| | | QueryPmsRequest req; |
| | | QueryPmsReq req; |
| | | client->write((char *)&req,req.head.len); |
| | | qDebug() << "æ¥è¯¢å
¨é¨æé请æ±åéæå"; |
| | | } |
| | |
| | | void PmsClientSocket::queryPmsByParam(PmsParam param) |
| | | { |
| | | if(connectSuccess){ |
| | | QueryPmsRequest req; |
| | | strcpy(req.name,param.getName().c_str()); |
| | | strcpy(req.permissonType,param.getPermissonType().c_str()); |
| | | strcpy(req.userNo,param.getUserNo().c_str()); |
| | | QueryPmsReq req; |
| | | strcpy(req.name,param.getName().toLocal8Bit().data()); |
| | | strcpy(req.permissonType,param.getPermissonType().toLocal8Bit().data()); |
| | | strcpy(req.userNo,param.getUserNo().toLocal8Bit().data()); |
| | | client->write((char *)&req,req.head.len); |
| | | qDebug() << "æ¡ä»¶æ¥è¯¢æé请æ±åéæå"; |
| | | } |
| | |
| | | |
| | | void PmsClientSocket::updatePmsByParam(PmsPlusParma param) |
| | | { |
| | | UpdatePmsRequest upReq; |
| | | upReq.devManage = param.getDevManage(); |
| | | upReq.loggerSearch = param.getLoggerSearch(); |
| | | upReq.mapMark = param.getMapMark(); |
| | | upReq.productPlan = param.getProductPlan(); |
| | | upReq.roleId = param.getRoleId(); |
| | | UpdatePmsReq upReq; |
| | | |
| | | upReq.id = param.getId(); |
| | | if(param.getPermissonType().isEmpty()){ |
| | | upReq.devManage = param.getDevManage(); |
| | | upReq.loggerSearch = param.getLoggerSearch(); |
| | | upReq.mapMark = param.getMapMark(); |
| | | upReq.productPlan = param.getProductPlan(); |
| | | upReq.warningManage = param.getWarninManage(); |
| | | upReq.versionManage = param.getVersionManage(); |
| | | upReq.admin = param.getAdmin(); |
| | | upReq.queryHistory = param.getQueryHistory(); |
| | | |
| | | memset(upReq.permissonType,0,32); |
| | | }else { |
| | | strcpy(upReq.permissonType,param.getPermissonType().toLocal8Bit().data()); |
| | | } |
| | | client->write((char *)&upReq,upReq.head.len); |
| | | qDebug() << "æ´æ°æé请æ±åéæå"; |
| | | } |
| | |
| | | void PmsClientSocket::readyRead_Slot() |
| | | { |
| | | QByteArray buf = client->readAll(); |
| | | QString recvData = QString::fromLocal8Bit(buf); |
| | | qDebug()<< "clientæ¶å°çæ°æ®" << recvData; |
| | | QueryPmsResponse * res; |
| | | UpdatePmsResponse * upRes; |
| | | int type = *(int *)buf.data(); |
| | | if(type == QUERY_PMS_REQ){ |
| | | res = (QueryPmsResponse *)buf.data(); |
| | | qDebug()<< "clientæ¶å°äºçæ°æ®"; |
| | | QueryPmsRes * res; |
| | | UpdatePmsRes * upRes; |
| | | Head head = *(Head *)buf.data(); |
| | | if(head.type == QUERY_PMS_RES){ |
| | | qDebug()<< "æ¥è¯¢ååº"; |
| | | res = (QueryPmsRes *)buf.data(); |
| | | if(res->success){ |
| | | vector<PmsQueryResult> vecs; |
| | | int pmsLen = res->head.len-sizeof(QueryPmsResponse); |
| | | for(int i =0;i<pmsLen;i+=sizeof(PmsRes)){ |
| | | PmsRes structRes = *(PmsRes*)(res + sizeof(QueryPmsResponse) + i*sizeof(PmsRes)); |
| | | PmsQueryResult res; |
| | | res.setName(string(structRes.name)); |
| | | res.setUserNo(string(structRes.userNo)); |
| | | res.setRoleId(structRes.roleId); |
| | | res.setStartDateTime(string(structRes.startDateTime)); |
| | | res.setEndDateTime(string(structRes.endDateTime)); |
| | | res.setLoggerSearch(structRes.loggerSearch); |
| | | res.setMapMark(structRes.mapMark); |
| | | res.setDevManage(structRes.devManage); |
| | | res.setProductPlan(structRes.productPlan); |
| | | res.setQueryHistory(structRes.queryHistory); |
| | | res.setPermissonType(string(structRes.permissonType)); |
| | | vecs.push_back(res); |
| | | int pmsLen = (res->head.len-sizeof(QueryPmsRes))/sizeof(PmsRes); |
| | | for(int i =0;i<pmsLen;i++){ |
| | | PmsRes structRes = res->pmsList[i]; |
| | | PmsQueryResult qres; |
| | | qres.setName(QString::fromLocal8Bit(structRes.name)); |
| | | qres.setUserNo(QString::fromLocal8Bit(structRes.userNo)); |
| | | qres.setId(structRes.id); |
| | | qres.setLoginTime(string(structRes.loginTime)); |
| | | qres.setRegisterTime(string(structRes.registerTime)); |
| | | qres.setLoggerSearch(structRes.loggerSearch); |
| | | qres.setMapMark(structRes.mapMark); |
| | | qres.setDevManage(structRes.devManage); |
| | | qres.setProductPlan(structRes.productPlan); |
| | | qres.setQueryHistory(structRes.queryHistory); |
| | | qres.setPermissonType(QString::fromLocal8Bit(structRes.permissonType)); |
| | | qres.setWarninManage(structRes.warningManage); |
| | | qres.setVersionManage(structRes.versionManage); |
| | | qres.setAdmin(structRes.admin); |
| | | vecs.push_back(qres); |
| | | } |
| | | if(!vecs.empty()){ |
| | | emit notifyDateChange(vecs); |
| | | } |
| | | emit notifyDateChange(vecs); |
| | | }else{ |
| | | // æ¥è¯¢å¤±è´¥æ°æ®ä¸ºç©ºæ¸
é¤è¡¨æ ¼æ°æ® |
| | | emit notifyDateChange(vector<PmsQueryResult>()); |
| | | } |
| | | } |
| | | if(type == UPDATE_PMS_REQ){ |
| | | res = (QueryPmsResponse *)buf.data(); |
| | | if(res->success){ |
| | | if(head.type == UPDATE_PMS_RES){ |
| | | upRes = (UpdatePmsRes *)buf.data(); |
| | | qDebug()<< "æ´æ°ååº"; |
| | | if(upRes->success){ |
| | | QString dlgTitle = "æ´æ°ç»æ"; |
| | | QString strInfo = "æéä¿¡æ¯æ´æ°æå"; |
| | | QMessageBox::information(this,dlgTitle,strInfo, |
| | |
| | | }; |
| | | |
| | | enum option{ |
| | | QUERY_PMS_REQ, |
| | | QUERY_PMS_REQ=6, |
| | | UPDATE_PMS_REQ, |
| | | QUERY_PMS_RES, |
| | | UPDATE_PMS_RES, |
| | |
| | | |
| | | |
| | | // æåå·¥ç¼å·ãååæè使¥è¯¢äººåæéä¿¡æ¯è¯·æ± |
| | | typedef struct QueryPmsRequest{ |
| | | typedef struct QueryPmsReq{ |
| | | Head head; |
| | | char userNo[32]; |
| | | char name[32]; |
| | | char permissonType[32]; |
| | | QueryPmsRequest(){ |
| | | QueryPmsReq(){ |
| | | head.type=QUERY_PMS_REQ; |
| | | memset(userNo,0,32); |
| | | memset(permissonType,0,32); |
| | | memset(name,0,32); |
| | | head.len = sizeof(QueryPmsRequest); |
| | | head.len = sizeof(QueryPmsReq); |
| | | } |
| | | } QueryPmsRequest; |
| | | } QueryPmsReq; |
| | | |
| | | // æè§è²idæ´æ°æéä¿¡æ¯è¯·æ± |
| | | typedef struct UpdatePmsRequest{ |
| | | typedef struct UpdatePmsReq{ |
| | | Head head; |
| | | int roleId; |
| | | // 人å表主é®id |
| | | int id; |
| | | int queryHistory; |
| | | int loggerSearch; |
| | | int mapMark; |
| | | int devManage; |
| | | int productPlan; |
| | | UpdatePmsRequest(){ |
| | | head.type=QUERY_PMS_RES; |
| | | head.len = sizeof(UpdatePmsRequest); |
| | | } |
| | | } UpdatePmsRequest; |
| | | int warningManage; |
| | | int versionManage; //çæ¬ç®¡ç |
| | | int admin; //ç³»ç»ç®¡çå |
| | | |
| | | // å个人åæéç»æä½ |
| | | typedef struct UserAboutPms{ |
| | | char permissonType[32]; |
| | | UpdatePmsReq(){ |
| | | head.type=UPDATE_PMS_REQ; |
| | | head.len = sizeof(UpdatePmsReq); |
| | | } |
| | | } UpdatePmsReq; |
| | | |
| | | // å个人ååæéèåæ¥è¯¢ç»æä½ |
| | | typedef struct PmsRes{ |
| | | int queryHistory; |
| | | int loggerSearch; |
| | | int mapMark; |
| | | int devManage; |
| | | int productPlan; |
| | | int roleId; |
| | | int versionManage; //çæ¬ç®¡ç |
| | | int warningManage; |
| | | int admin; //ç³»ç»ç®¡çå |
| | | |
| | | int id; |
| | | |
| | | char userNo[32]; |
| | | char name[32]; |
| | | char permissonType[32]; |
| | | char startDateTime[32]; |
| | | char endDateTime[32]; |
| | | |
| | | char permissonType[32]; // è§è²ç±»å |
| | | |
| | | char department[32]; |
| | | char loginTime[32]; |
| | | char registerTime[32]; |
| | | } PmsRes; |
| | | |
| | | // æ¥è¯¢äººååè§è²ä¿¡æ¯çååºç»æä½ |
| | | typedef struct UserAboutPmsResponse{ |
| | | typedef struct QueryPmsRes{ |
| | | Head head; |
| | | int success; // 1为æå ,0为失败 |
| | | //PmsRes pmsList[100]; |
| | | char pmsList[0]; |
| | | UserAboutPmsResponse(){ |
| | | PmsRes pmsList[0]; |
| | | QueryPmsRes(){ |
| | | head.type=QUERY_PMS_RES; |
| | | // memset(pmsList,0,sizeof(PmsRes)); |
| | | // head.len = sizeof(UserAboutPmsResponse); |
| | | } |
| | | } QueryPmsResponse; |
| | | } QueryPmsRes; |
| | | |
| | | // æéæ´æ°ç»æååºä½ |
| | | typedef struct UpdatePmsResponse{ |
| | | typedef struct UpdatePmsRes{ |
| | | Head head; |
| | | int success; // 1为æå ,0为失败 |
| | | UpdatePmsResponse(){ |
| | | UpdatePmsRes(){ |
| | | head.type = UPDATE_PMS_RES; |
| | | head.len = sizeof(UpdatePmsResponse); |
| | | head.len = sizeof(UpdatePmsRes); |
| | | } |
| | | |
| | | } UpdatePmsResponse ; |
| | | } UpdatePmsRes ; |
| | | |
| | | |
| | | class PmsClientSocket : public QWidget |
| | |
| | | |
| | | QTcpSocket *client; |
| | | |
| | | int port=88888; |
| | | int port=16888; |
| | | QString targetIp = "127.0.0.1"; |
| | | |
| | | bool connectSuccess= false; |
| | |
| | | map5[2]=ui->radioButton_15; |
| | | |
| | | |
| | | map<int,QRadioButton *> warningMap; |
| | | warningMap[0]=ui->radioButton_16; |
| | | warningMap[1]=ui->radioButton_17; |
| | | warningMap[2]=ui->radioButton_18; |
| | | |
| | | map<int,QRadioButton *> versionMap; |
| | | versionMap[0]=ui->radioButton_19; |
| | | versionMap[1]=ui->radioButton_20; |
| | | versionMap[2]=ui->radioButton_21; |
| | | |
| | | map<int,QRadioButton *> superManager; |
| | | // 1为è¶
级管çå |
| | | superManager[0]=ui->radioButton_23; |
| | | superManager[1]=ui->radioButton_22; |
| | | |
| | | btnList.push_back(map1); |
| | | btnList.push_back(map2); |
| | | btnList.push_back(map3); |
| | | btnList.push_back(map4); |
| | | btnList.push_back(map5); |
| | | btnList.push_back(warningMap); |
| | | btnList.push_back(versionMap); |
| | | btnList.push_back(superManager); |
| | | |
| | | } |
| | | |
| | |
| | | int PermissonDialog::findBoxCheck(map<int, QRadioButton *> map) |
| | | { |
| | | for(int i =0;i<map.size();i++){ |
| | | if(btnList[0][i]->isChecked()){ |
| | | if(map[i]->isChecked()){ |
| | | return i; |
| | | } |
| | | } |
| | |
| | | btnList[2][res.getMapMark()]->setChecked(true); |
| | | btnList[3][res.getDevManage()]->setChecked(true); |
| | | btnList[4][res.getProductPlan()]->setChecked(true); |
| | | |
| | | btnList[5][res.getWarninManage()]->setChecked(true); |
| | | |
| | | btnList[6][res.getVersionManage()]->setChecked(true); |
| | | |
| | | btnList[7][res.getAdmin()]->setChecked(true); |
| | | |
| | | curRes = res; |
| | | |
| | |
| | | param.setMapMark(findBoxCheck(btnList[2])); |
| | | param.setDevManage(findBoxCheck(btnList[3])); |
| | | param.setProductPlan(findBoxCheck(btnList[4])); |
| | | param.setWarninManage(findBoxCheck(btnList[5])); |
| | | param.setVersionManage(findBoxCheck(btnList[6])); |
| | | param.setAdmin(findBoxCheck(btnList[7])); |
| | | |
| | | param.setRoleId(curRes.getRoleId()); |
| | | param.setId(curRes.getId()); |
| | | client->updatePmsByParam(param); |
| | | |
| | | } |
| | |
| | | <rect> |
| | | <x>0</x> |
| | | <y>0</y> |
| | | <width>421</width> |
| | | <height>361</height> |
| | | <width>560</width> |
| | | <height>492</height> |
| | | </rect> |
| | | </property> |
| | | <property name="windowTitle"> |
| | |
| | | <layout class="QGridLayout" name="gridLayout_3"> |
| | | <item row="0" column="0"> |
| | | <layout class="QGridLayout" name="gridLayout_2"> |
| | | <item row="3" column="0"> |
| | | <widget class="QDialogButtonBox" name="buttonBox"> |
| | | <property name="orientation"> |
| | | <enum>Qt::Horizontal</enum> |
| | | </property> |
| | | <property name="standardButtons"> |
| | | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
| | | </property> |
| | | </widget> |
| | | </item> |
| | | <item row="0" column="0"> |
| | | <layout class="QGridLayout" name="gridLayout"> |
| | | <item row="0" column="0"> |
| | | <widget class="QGroupBox" name="groupBox"> |
| | | <property name="title"> |
| | | <string>åæ¶æ¥è¯¢</string> |
| | | </property> |
| | | <widget class="QRadioButton" name="radioButton"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>20</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>æ æé</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_2"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>150</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>坿¥ç</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_3"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>280</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>å¯ä¿®æ¹</string> |
| | | </property> |
| | | </widget> |
| | | </widget> |
| | | </item> |
| | | <item row="1" column="0"> |
| | | <widget class="QGroupBox" name="groupBox_2"> |
| | | <property name="title"> |
| | |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_6"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>280</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>å¯ä¿®æ¹</string> |
| | | </property> |
| | | </widget> |
| | | </widget> |
| | | </item> |
| | | <item row="0" column="0"> |
| | | <widget class="QGroupBox" name="groupBox"> |
| | | <property name="title"> |
| | | <string>åæ¶æ¥è¯¢</string> |
| | | </property> |
| | | <widget class="QRadioButton" name="radioButton"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>20</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>æ æé</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_2"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>150</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>坿¥ç</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_3"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>280</x> |
| | |
| | | </widget> |
| | | </widget> |
| | | </item> |
| | | <item row="5" column="0"> |
| | | <widget class="QGroupBox" name="groupBox_6"> |
| | | <property name="title"> |
| | | <string>è¦æ¥ç®¡ç</string> |
| | | </property> |
| | | <widget class="QRadioButton" name="radioButton_16"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>20</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>æ æé</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_17"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>150</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>坿¥ç</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_18"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>280</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>å¯ä¿®æ¹</string> |
| | | </property> |
| | | </widget> |
| | | </widget> |
| | | </item> |
| | | <item row="6" column="0"> |
| | | <widget class="QGroupBox" name="groupBox_7"> |
| | | <property name="title"> |
| | | <string>çæ¬ç®¡ç</string> |
| | | </property> |
| | | <widget class="QRadioButton" name="radioButton_19"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>20</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>æ æé</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_20"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>150</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>坿¥ç</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_21"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>280</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>å¯ä¿®æ¹</string> |
| | | </property> |
| | | </widget> |
| | | </widget> |
| | | </item> |
| | | <item row="7" column="0"> |
| | | <widget class="QGroupBox" name="groupBox_8"> |
| | | <property name="title"> |
| | | <string>è¶
级管çå</string> |
| | | </property> |
| | | <widget class="QRadioButton" name="radioButton_22"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>20</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>æ¯</string> |
| | | </property> |
| | | </widget> |
| | | <widget class="QRadioButton" name="radioButton_23"> |
| | | <property name="geometry"> |
| | | <rect> |
| | | <x>150</x> |
| | | <y>20</y> |
| | | <width>115</width> |
| | | <height>19</height> |
| | | </rect> |
| | | </property> |
| | | <property name="text"> |
| | | <string>å¦</string> |
| | | </property> |
| | | </widget> |
| | | </widget> |
| | | </item> |
| | | </layout> |
| | | </item> |
| | | <item row="1" column="0"> |
| | | <widget class="QDialogButtonBox" name="buttonBox"> |
| | | <property name="orientation"> |
| | | <enum>Qt::Horizontal</enum> |
| | | </property> |
| | | <property name="standardButtons"> |
| | | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
| | | </property> |
| | | </widget> |
| | | </item> |
| | | </layout> |
| | | </item> |
| | |
| | | ui(new Ui::PermissonWindow) |
| | | { |
| | | ui->setupUi(this); |
| | | clientSocket = new PmsClientSocket(this); |
| | | |
| | | dia = new PermissonDialog(this,clientSocket); |
| | | |
| | | |
| | | |
| | | connect(this,SIGNAL(sendUserNo(PmsQueryResult)),dia,SLOT(recvUserNo(PmsQueryResult))); |
| | | connect(clientSocket,SIGNAL(notifyDateChange(vector<PmsQueryResult>)),this,SLOT(renderItemData(vector<PmsQueryResult>))); |
| | | |
| | | roleMap["æ®ééç¿åå·¥"] = 1; |
| | | roleMap["ææ¯ç»´æ¤äººå"] = 2; |
| | | roleMap["ç³»ç»ç®¡çå"] = 3; |
| | | roleMap["å®å
¨ç®¡ç人å"] = 4; |
| | | |
| | | this->setWindowTitle("æé管ç"); |
| | | vector<QString> lableList; |
| | | lableList.push_back("åå·¥ç¼å·"); |
| | | lableList.push_back("å§å"); |
| | | lableList.push_back("å½å¤©å·¥ä½æ¶é´"); |
| | | lableList.push_back("å½å¤©ç»ææ¶é´"); |
| | | lableList.push_back("é¨é¨"); |
| | | lableList.push_back("ç»å½æ¶é´"); |
| | | lableList.push_back("æ³¨åæ¶é´"); |
| | | |
| | | lableList.push_back("èä½"); |
| | | clientSocket = new PmsClientSocket(this); |
| | | |
| | | |
| | | dia = new PermissonDialog(this,clientSocket); |
| | | |
| | | m_model = new QStandardItemModel(globalPms.size(),lableList.size(),this); |
| | | |
| | | ui->tableView->setModel(m_model); |
| | | |
| | | for(int i=0;i<m_model->rowCount();i++){ |
| | | PmsQueryResult curRes = globalPms[i]; |
| | | m_model->setItem(i,0,new QStandardItem(QString::fromStdString(curRes.getUserNo()))); |
| | | m_model->setItem(i,1,new QStandardItem(QString::fromLocal8Bit(curRes.getName().c_str()))); |
| | | m_model->setItem(i,2,new QStandardItem(QString::fromStdString(curRes.getStartDateTime()))); |
| | | m_model->setItem(i,3,new QStandardItem(QString::fromStdString(curRes.getEndDateTime()))); |
| | | m_model->setItem(i,4,new QStandardItem(QString::fromLocal8Bit(curRes.getPermissonType().c_str()))); |
| | | |
| | | } |
| | | |
| | | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); |
| | | ui->tableView->verticalHeader()->hide(); |
| | | |
| | | |
| | | QStringList lable; |
| | |
| | | |
| | | m_model->setHorizontalHeaderLabels(lable); |
| | | |
| | | ui->tableView->setModel(m_model); |
| | | ui->tableView->verticalHeader()->hide(); |
| | | |
| | | connect(this,SIGNAL(sendUserNo(PmsQueryResult)),dia,SLOT(recvUserNo(PmsQueryResult))); |
| | | connect(clientSocket,SIGNAL(notifyDateChange(vector<PmsQueryResult>)),this,SLOT(renderItemData(vector<PmsQueryResult>))); |
| | | connect(m_model,SIGNAL(itemChanged(QStandardItem*)),this,SLOT(listenItemChange(QStandardItem*))); |
| | | |
| | | |
| | | // å䏿¬¡æ¥è¯¢å
¨é¨æ°æ®è¯·æ± |
| | | clientSocket->queryAllUserAboutUser(); |
| | | |
| | | |
| | | |
| | | |
| | | QComBoxDelegate * qc = new QComBoxDelegate(this); |
| | | |
| | | |
| | | |
| | | ui->tableView->setItemDelegateForColumn(4,qc); |
| | | ui->tableView->setItemDelegateForColumn(5,qc); |
| | | |
| | | |
| | | m = new QMenu(this); |
| | |
| | | connect(ac1,&QAction::triggered,[=]{ |
| | | int row = ui->tableView->currentIndex().row(); |
| | | qDebug() << "æ´æ°å½åå工信æ¯" |
| | | << QString::fromStdString( globalPms[row].getUserNo()); |
| | | << globalPms[row].getUserNo(); |
| | | // åéåå·¥ç¼å·ä¿¡æ¯ |
| | | emit sendUserNo(globalPms[row]); |
| | | |
| | | dia->setModal(true); |
| | | dia->show(); |
| | | }); |
| | | |
| | | |
| | | connect(m_model,SIGNAL(itemChanged(QStandardItem*)),this,SLOT(listenItemChange(QStandardItem*))); |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | void PermissonWindow::on_pushButton_clicked() |
| | | { |
| | | qDebug() << "åéæ¥è¯¢è¯·æ±"; |
| | | |
| | | PmsParam pm; |
| | | pm.setName(ui->lineEdit->text().toStdString()); |
| | | pm.setPermissonType(ui->lineEdit_2->text().toStdString()); |
| | | pm.setUserNo(ui->lineEdit_3->text().toStdString()); |
| | | pm.setName(ui->lineEdit->text()); |
| | | pm.setPermissonType(ui->lineEdit_2->text()); |
| | | pm.setUserNo(ui->lineEdit_3->text()); |
| | | |
| | | clientSocket->queryPmsByParam(pm); |
| | | qDebug() << "æ¥è¯¢ä¸"; |
| | | |
| | | } |
| | | |
| | | void PermissonWindow::listenItemChange(QStandardItem *item) |
| | | { |
| | | QString localText = item->text(); |
| | | if(roleMap.count(localText.toStdString())){ |
| | | qDebug() << "åèµ·è使´æ°è¯·æ±"; |
| | | if(item->column()==m_model->columnCount()-1){ |
| | | QString localText = item->text(); |
| | | |
| | | PmsPlusParma pm; |
| | | pm.setPermissonType(localText.toStdString()); |
| | | pm.setRoleId(roleMap[localText.toStdString()]); |
| | | pm.setPermissonType(localText); |
| | | |
| | | int id = globalPms[item->row()].getId(); |
| | | pm.setId(id); |
| | | clientSocket->updatePmsByParam(pm); |
| | | } |
| | | } |
| | | |
| | | void PermissonWindow::renderItemData(vector<PmsQueryResult> res) |
| | | { |
| | | |
| | | globalPms = res; |
| | | m_model->setRowCount(globalPms.size()); |
| | | |
| | | for(int i=0;i<m_model->rowCount();i++){ |
| | | PmsQueryResult curRes = globalPms[i]; |
| | | m_model->setItem(i,0,new QStandardItem(QString::fromStdString(curRes.getUserNo()))); |
| | | m_model->setItem(i,1,new QStandardItem(QString::fromLocal8Bit(curRes.getName().c_str()))); |
| | | m_model->setItem(i,2,new QStandardItem(QString::fromStdString(curRes.getStartDateTime()))); |
| | | m_model->setItem(i,3,new QStandardItem(QString::fromStdString(curRes.getEndDateTime()))); |
| | | m_model->setItem(i,4,new QStandardItem(QString::fromLocal8Bit(curRes.getPermissonType().c_str()))); |
| | | m_model->setItem(i,0,new QStandardItem(curRes.getUserNo())); |
| | | m_model->setItem(i,1,new QStandardItem(curRes.getName())); |
| | | m_model->setItem(i,2,new QStandardItem(QString::fromStdString(curRes.getDepartment()))); |
| | | m_model->setItem(i,3,new QStandardItem(QString::fromStdString(curRes.getLoginTime()))); |
| | | m_model->setItem(i,4,new QStandardItem(QString::fromStdString(curRes.getRegisterTime()))); |
| | | |
| | | m_model->blockSignals(true); |
| | | m_model->setItem(i,5,new QStandardItem(curRes.getPermissonType())); |
| | | m_model->blockSignals(false); |
| | | } |
| | | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); |
| | | |
| | | qDebug() << "æ¥è¯¢å°çæ°é " << globalPms.size(); |
| | | } |
| | | |
| | |
| | | QMenu * m; |
| | | PermissonDialog *dia; |
| | | SyncDataToDB * dbInfo; |
| | | map<string,int> roleMap; |
| | | |
| | | |
| | | vector<PmsQueryResult> globalPms; |
| | | PmsClientSocket * clientSocket; |
| | | |
| | | bool isRenderData; |
| | | |
| | | |
| | | }; |
| | | |
| | |
| | | #ifndef PMSPARAM_H |
| | | #define PMSPARAM_H |
| | | #include <QString> |
| | | #include <string> |
| | | using namespace std; |
| | | |
| | | |
| | | class PmsParam { |
| | | protected: |
| | | string userNo; |
| | | string name; |
| | | string permissonType; |
| | | QString userNo; |
| | | QString name; |
| | | QString permissonType; |
| | | public: |
| | | void setUserNo(string id){ |
| | | void setUserNo(QString id){ |
| | | this->userNo = id; |
| | | } |
| | | void setName(string name){ |
| | | void setName(QString name){ |
| | | this->name = name; |
| | | } |
| | | void setPermissonType(string permissonType){ |
| | | void setPermissonType(QString permissonType){ |
| | | this->permissonType = permissonType; |
| | | } |
| | | |
| | | string getUserNo(){ |
| | | QString getUserNo(){ |
| | | return userNo; |
| | | } |
| | | string getName(){ |
| | | QString getName(){ |
| | | return name; |
| | | } |
| | | string getPermissonType(){ |
| | | QString getPermissonType(){ |
| | | return permissonType; |
| | | } |
| | | |
| | |
| | | #ifndef PMSPLUSPARAM_H |
| | | #ifndef PMSPLUSPARAM_H |
| | | #define PMSPLUSPARAM_H |
| | | #include "pmsparam.h" |
| | | |
| | | class PmsPlusParma : public PmsParam{ |
| | | int roleId; |
| | | int id; |
| | | |
| | | int queryHistory; |
| | | int loggerSearch; |
| | | int mapMark; |
| | | int devManage; |
| | | int productPlan; |
| | | |
| | | int warninManage; |
| | | int versionManage; //çæ¬ç®¡ç |
| | | int admin; //ç³»ç»ç®¡çå |
| | | public: |
| | | void setQueryHistory(int val){ |
| | | this->queryHistory = val; |
| | |
| | | this->productPlan = val; |
| | | } |
| | | |
| | | void setRoleId(int val){ |
| | | this->roleId = val; |
| | | void setId(int val){ |
| | | this->id = val; |
| | | } |
| | | |
| | | int getQueryHistory(){ |
| | |
| | | return productPlan; |
| | | } |
| | | |
| | | int getRoleId(){ |
| | | return roleId; |
| | | int getId(){ |
| | | return id; |
| | | } |
| | | |
| | | PmsPlusParma(){ |
| | | id = 0; |
| | | queryHistory = 0; |
| | | loggerSearch = 0; |
| | | mapMark = 0; |
| | | devManage = 0; |
| | | productPlan = 0; |
| | | } |
| | | |
| | | |
| | | PmsPlusParma(){ |
| | | roleId = -1; |
| | | queryHistory = -1; |
| | | loggerSearch = -1; |
| | | mapMark = -1; |
| | | devManage = -1; |
| | | productPlan = -1; |
| | | int getVersionManage() const |
| | | { |
| | | return versionManage; |
| | | } |
| | | |
| | | void setVersionManage(int value) |
| | | { |
| | | versionManage = value; |
| | | } |
| | | |
| | | int getAdmin() const |
| | | { |
| | | return admin; |
| | | } |
| | | |
| | | void setAdmin(int value) |
| | | { |
| | | admin = value; |
| | | } |
| | | |
| | | int getWarninManage() const |
| | | { |
| | | return warninManage; |
| | | } |
| | | |
| | | void setWarninManage(int value) |
| | | { |
| | | warninManage = value; |
| | | } |
| | | }; |
| | | |
| | | #endif // PMSPLUSPARAM_H |
| | | |
| | | |
| | |
| | | #ifndef PMSQUERYRESULT_H |
| | | #ifndef PMSQUERYRESULT_H |
| | | #define PMSQUERYRESULT_H |
| | | |
| | | #include "pmsparam.h" |
| | | class PmsQueryResult : public PmsParam{ |
| | | string startDateTime; |
| | | string endDateTime; |
| | | |
| | | int queryHistory; |
| | | int loggerSearch; |
| | |
| | | int devManage; |
| | | int productPlan; |
| | | |
| | | int warninManage; |
| | | int versionManage; //çæ¬ç®¡ç |
| | | int admin; //ç³»ç»ç®¡çå |
| | | |
| | | int id; |
| | | int roleId; |
| | | |
| | | string department; |
| | | string loginTime; |
| | | string registerTime; |
| | | public: |
| | | void setStartDateTime(string time){ |
| | | this->startDateTime = time; |
| | | void setLoginTime(string time){ |
| | | this->loginTime = time; |
| | | } |
| | | void setEndDateTime(string time){ |
| | | this->endDateTime = time; |
| | | void setRegisterTime(string time){ |
| | | this->registerTime = time; |
| | | } |
| | | |
| | | void setQueryHistory(int val){ |
| | |
| | | void setProductPlan(int val){ |
| | | this->productPlan = val; |
| | | } |
| | | void setRoleId(int val){ |
| | | this->roleId = val; |
| | | void setId(int val){ |
| | | this->id = val; |
| | | } |
| | | |
| | | |
| | | string getStartDateTime(){ |
| | | return startDateTime; |
| | | string getLoginTime(){ |
| | | return loginTime; |
| | | } |
| | | string getEndDateTime(){ |
| | | return endDateTime; |
| | | string getRegisterTime(){ |
| | | return registerTime; |
| | | } |
| | | int getQueryHistory(){ |
| | | return queryHistory; |
| | |
| | | int getProductPlan(){ |
| | | return productPlan; |
| | | } |
| | | int getRoleId(){ |
| | | return roleId; |
| | | int getId(){ |
| | | return id; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | int getVersionManage() const |
| | | { |
| | | return versionManage; |
| | | } |
| | | |
| | | void setVersionManage(int value) |
| | | { |
| | | versionManage = value; |
| | | } |
| | | |
| | | int getAdmin() const |
| | | { |
| | | return admin; |
| | | } |
| | | |
| | | void setAdmin(int value) |
| | | { |
| | | admin = value; |
| | | } |
| | | |
| | | int getWarninManage() const |
| | | { |
| | | return warninManage; |
| | | } |
| | | |
| | | void setWarninManage(int value) |
| | | { |
| | | warninManage = value; |
| | | } |
| | | |
| | | |
| | | |
| | | string getDepartment() const |
| | | { |
| | | return department; |
| | | } |
| | | |
| | | void setDepartment(const string &value) |
| | | { |
| | | department = value; |
| | | } |
| | | |
| | | }; |
| | | |
| | | |
| | | #endif // PMSQUERYRESULT_H |
| | | |
| | | |
| | |
| | | { |
| | | QComboBox * box = new QComboBox(parent); |
| | | QStringList text; |
| | | text << "æ®ééç¿åå·¥" << "ææ¯ç»´æ¤äººå" << "ç³»ç»ç®¡çå"<< "å®å
¨ç®¡ç人å"; |
| | | |
| | | QString curText = qvariant_cast<QString>(index.data()); |
| | | |
| | | vector<QString> vecq; |
| | | vecq.push_back("ææ¯ç»´æ¤äººå"); |
| | | vecq.push_back("ç³»ç»ç®¡çå"); |
| | | vecq.push_back("å®å
¨ç®¡ç人å"); |
| | | vecq.push_back("æ®ééç¿åå·¥"); |
| | | |
| | | text << curText; |
| | | for(QString role : vecq){ |
| | | if(curText!=role){ |
| | | text << role; |
| | | } |
| | | } |
| | | box->addItems(text); |
| | | |
| | | return box; |
| | |
| | | #ifndef QCOMBOXDELEGATE_H |
| | | #ifndef QCOMBOXDELEGATE_H |
| | | #define QCOMBOXDELEGATE_H |
| | | |
| | | #include <QItemDelegate> |
| | | #include <QComboBox> |
| | | #pragma execution_character_set("utf-8") |
| | | #include <vector> |
| | | using namespace std; |
| | | |
| | | class QComBoxDelegate : public QItemDelegate |
| | | { |
| | | |
| | | public: |
| | | QComBoxDelegate(); |
| | | QComBoxDelegate(QObject * p=0); |
| | |
| | | { |
| | | string sql = "SELECT * FROM user_info AS u, employee_permisson AS e WHERE u.role_id=e.id"; |
| | | |
| | | if(!param.getUserNo().empty()){ |
| | | sql += " and u.user_no='" + param.getUserNo() + "'"; |
| | | } |
| | | // if(!param.getUserNo().empty()){ |
| | | // sql += " and u.user_no='" + param.getUserNo() + "'"; |
| | | // } |
| | | |
| | | if(!param.getName().empty()){ |
| | | sql += " and u.name='" + param.getName()+ "'"; |
| | | } |
| | | // if(!param.getName().empty()){ |
| | | // sql += " and u.name='" + param.getName()+ "'"; |
| | | // } |
| | | |
| | | if(!param.getPermissonType().empty()){ |
| | | sql += " and e.permission_type='" + param.getPermissonType()+ "'"; |
| | | } |
| | | // if(!param.getPermissonType().empty()){ |
| | | // sql += " and e.permission_type='" + param.getPermissonType()+ "'"; |
| | | // } |
| | | |
| | | qDebug() << "sqlè¯å¥" << QString::fromStdString(sql); |
| | | |
| | |
| | | string sql = "update employee_permisson"; |
| | | |
| | | // åªæ´æ¹èä½ |
| | | if(!param.getPermissonType().empty()){ |
| | | sql.append(" set permission_type='" + param.getPermissonType())+ "'"; |
| | | }else{ |
| | | sql.append(" set query_history=") + to_string(param.getQueryHistory()); |
| | | sql.append(",logger_search=") + to_string(param.getLoggerSearch()); |
| | | sql.append(",map_mark=") + to_string(param.getMapMark()); |
| | | sql.append(",dev_manage=") + to_string(param.getDevManage()); |
| | | sql.append(",product_plan=") + to_string(param.getProductPlan()); |
| | | } |
| | | sql.append(" where e.id=" + param.getRoleId()); |
| | | // if(!param.getPermissonType().empty()){ |
| | | // sql.append(" set permission_type='" + param.getPermissonType())+ "'"; |
| | | // }else{ |
| | | // sql.append(" set query_history=") + to_string(param.getQueryHistory()); |
| | | // sql.append(",logger_search=") + to_string(param.getLoggerSearch()); |
| | | // sql.append(",map_mark=") + to_string(param.getMapMark()); |
| | | // sql.append(",dev_manage=") + to_string(param.getDevManage()); |
| | | // sql.append(",product_plan=") + to_string(param.getProductPlan()); |
| | | // } |
| | | //sql.append(" where e.id=" + param.getRoleId()); |
| | | |
| | | mysql_real_query(&mysql, sql.c_str(), sql.size()); |
| | | mysql_store_result(&mysql); |
| | |
| | | |
| | | void SyncDataToDB::setPmsResult(PmsQueryResult &res, char **row) |
| | | { |
| | | res.setName(string(row[1])); |
| | | res.setUserNo(string(row[5])); |
| | | res.setStartDateTime(string(row[2])); |
| | | res.setEndDateTime(string(row[3])); |
| | | res.setRoleId(stoi(string(row[4]))); |
| | | // res.setName(string(row[1])); |
| | | // res.setUserNo(string(row[5])); |
| | | // res.setStartDateTime(string(row[2])); |
| | | // res.setEndDateTime(string(row[3])); |
| | | // res.setRoleId(stoi(string(row[4]))); |
| | | |
| | | res.setPermissonType(string(row[8])); |
| | | // res.setPermissonType(string(row[8])); |
| | | res.setQueryHistory(stoi(string(row[9]))); |
| | | res.setLoggerSearch(stoi(string(row[10]))); |
| | | res.setMapMark(stoi(string(row[11]))); |
| | |
| | | res.setProductPlan(stoi(string(row[13]))); |
| | | |
| | | |
| | | qDebug() << QString::fromStdString(res.getUserNo()); |
| | | //qDebug() << QString::fromStdString(res.getUserNo()); |
| | | } |
New file |
| | |
| | | #include "stdafx.h" |
| | | #include "PermissonManage.h" |
| | | #include <iostream> |
| | | #include "MysqlConn.h" |
| | | #include <string.h> |
| | | #include <vector> |
| | | using namespace std; |
| | | |
| | | |
| | | PermissonManage::PermissonManage() |
| | | { |
| | | } |
| | | |
| | | |
| | | PermissonManage::~PermissonManage() |
| | | { |
| | | } |
| | | |
| | | bool PermissonManage::queryPmsByParam(SOCKET client, QueryPmsReq * req) |
| | | { |
| | | // ç»è£
SQLè¯å¥ |
| | | string sql = "SELECT * FROM user_info AS u, role_info AS e WHERE u.role_id=e.id"; |
| | | |
| | | if (*(req->userNo)) { |
| | | sql += " and u.user_no='" + string(req->userNo) + "'"; |
| | | } |
| | | |
| | | if (*(req->name)) { |
| | | sql += " and u.name='" + string(req->name) + "'"; |
| | | } |
| | | |
| | | if (*(req->permissonType)) { |
| | | sql += " and e.permission_type='" + string(req->permissonType) + "'"; |
| | | } |
| | | |
| | | cout << "sql:" << sql << endl; |
| | | |
| | | // è°ç¨MySQL API æ§è¡SQLè¯å¥ï¼æ ¹æ®è¿åå¼ç»è£
ååºç»æä½ |
| | | MysqlConn conn; |
| | | conn.connect("127.0.0.1", "root", "root", "mydb"); |
| | | |
| | | |
| | | bool ret = conn.query (sql); |
| | | |
| | | vector<PmsRes> pmsTempList; |
| | | while (conn.getResult()){ |
| | | PmsRes pmsRes; |
| | | pmsRes.admin = stoi(conn.getField(22)); |
| | | strcpy_s(pmsRes.department, conn.getField(1).c_str()); |
| | | |
| | | pmsRes.devManage = stoi(conn.getField(18)); |
| | | pmsRes.id = stoi(conn.getField(0)); |
| | | pmsRes.loggerSearch = stoi(conn.getField(16)); |
| | | strcpy_s(pmsRes.loginTime, conn.getField(11).c_str()); |
| | | pmsRes.mapMark = stoi(conn.getField(17)); |
| | | |
| | | strcpy_s(pmsRes.name, conn.getField(2).c_str()); |
| | | strcpy_s(pmsRes.permissonType, conn.getField(14).c_str()); |
| | | pmsRes.productPlan = stoi(conn.getField(19)); |
| | | pmsRes.queryHistory = stoi(conn.getField(15)); |
| | | strcpy_s(pmsRes.registerTime, conn.getField(12).c_str()); |
| | | strcpy_s(pmsRes.userNo, conn.getField(4).c_str()); |
| | | pmsRes.versionManage = stoi(conn.getField(21)); |
| | | pmsRes.warningManage = stoi(conn.getField(20)); |
| | | pmsTempList.push_back(pmsRes); |
| | | |
| | | |
| | | cout << "è·åç»æé2" << conn.getField(0) << conn.getField(1) << conn.getField(2); |
| | | } |
| | | |
| | | QueryPmsRes *res; |
| | | int len = sizeof(QueryPmsRes) + pmsTempList.size() * sizeof(PmsRes); |
| | | res = (QueryPmsRes *)malloc(len); |
| | | |
| | | |
| | | PmsRes * pmArr = new PmsRes[pmsTempList.size()]; |
| | | for (int i = 0; i < pmsTempList.size();i++) { |
| | | pmArr[i] = pmsTempList[i]; |
| | | } |
| | | |
| | | memcpy(res->pmsList,pmArr, pmsTempList.size() * sizeof(PmsRes)); |
| | | |
| | | |
| | | res->head.type = QUERY_PMS_RES; |
| | | res->head.len = len; |
| | | |
| | | if (ret > 0) { |
| | | res->success = 1; // æå |
| | | } |
| | | else { |
| | | res->success = 0; // 失败 |
| | | } |
| | | cout << "id="<< res->pmsList[0].id << endl; |
| | | // åéç»æä½ç»å®¢æ·ç«¯ |
| | | cout << __FUNCTION__ << send(client, (char*)res, res->head.len, 0) << endl; |
| | | |
| | | delete[] pmArr; |
| | | delete res; |
| | | return true; |
| | | } |
| | | |
| | | bool PermissonManage::updatePms(SOCKET client, UpdatePmsReq * req) |
| | | { |
| | | // è°ç¨MySQL API æ§è¡SQLè¯å¥ï¼æ ¹æ®è¿åå¼ç»è£
ååºç»æä½ |
| | | MysqlConn conn; |
| | | conn.connect("127.0.0.1", "root", "root", "mydb"); |
| | | |
| | | char sql[512] = { 0 }; |
| | | |
| | | UpdatePmsRes res; |
| | | if (*(req->permissonType)) { |
| | | |
| | | // å
ç¨è§è²ç±»åæ¥ä¸éè§è²è¡¨id |
| | | sprintf(sql, "select id from role_info where permission_type='%s'", req->permissonType); |
| | | bool ret = conn.query(sql); |
| | | bool retRes = conn.getResult(); |
| | | if (!ret || !retRes) { |
| | | res.success = 0; |
| | | } |
| | | else { |
| | | int roleId = stoi(conn.getField(0)); |
| | | memset(sql, 0, 512); |
| | | sprintf(sql, "update user_info set role_id=%d where id=%d", roleId, req->id); |
| | | ret = conn.update(sql); |
| | | res.success = ret; |
| | | } |
| | | } |
| | | else { |
| | | // å
ç¨idæ¥ä¸éè§è²id |
| | | sprintf(sql,"select role_id from user_info where id=%d", req->id); |
| | | |
| | | bool ret = conn.query(sql); |
| | | bool retRes = conn.getResult(); |
| | | if (!ret || !retRes) { |
| | | res.success = 0; |
| | | }else { |
| | | int roleId = stoi(conn.getField(0)); |
| | | memset(sql, 0, 512); |
| | | sprintf(sql, "update role_info set query_history=%d,logger_search=%d,map_mark=%d,dev_manage=%d" |
| | | ",product_plan=%d,warning_manage=%d,version_manage=%d,role_info.admin=%d where id=%d",req->queryHistory,req->loggerSearch, |
| | | req->mapMark,req->devManage,req->productPlan,req->warningManage,req->versionManage,req->admin,roleId); |
| | | |
| | | cout << "æ´æ°æésql:" << sql << endl; |
| | | ret = conn.update(sql); |
| | | res.success = ret; |
| | | } |
| | | } |
| | | // åéç»æä½ç»å®¢æ·ç«¯ |
| | | cout << __FUNCTION__ << send(client, (char*)&res, res.head.len, 0) << endl; |
| | | |
| | | return true; |
| | | } |
New file |
| | |
| | | #pragma once |
| | | |
| | | #include "common.h" |
| | | #include <WinSock2.h> |
| | | #include <string> |
| | | using namespace std; |
| | | |
| | | class PermissonManage |
| | | { |
| | | public: |
| | | PermissonManage(); |
| | | ~PermissonManage(); |
| | | bool queryPmsByParam(SOCKET client, QueryPmsReq * req); |
| | | bool updatePms(SOCKET client, UpdatePmsReq * req); |
| | | }; |
| | | |
New file |
| | |
| | | #include "stdafx.h" |
| | | #include "ServerSocket.h" |
| | | #include "common.h" |
| | | #include "DeviceManage.h" |
| | | #include "PermissonManage.h" |
| | | |
| | | #define HEART_CHECK_TIMES 60 // å¿è·³æ£æµçæ¬¡æ° |
| | | |
| | | struct TestData |
| | | { |
| | | int type; |
| | | int len; |
| | | char data[32]; |
| | | }; |
| | | |
| | | ServerSocket::ServerSocket(bool openHeartCheck):m_openHeartCheck(openHeartCheck) |
| | | { |
| | | if (initSocket()) { |
| | | cout << "init socket ok" << endl; |
| | | } |
| | | else { |
| | | cout << "init socket fail" << endl; |
| | | } |
| | | } |
| | | |
| | | |
| | | ServerSocket::~ServerSocket() |
| | | { |
| | | closesocket(m_server); // å
³éæå¡ç«¯å¥æ¥å |
| | | WSACleanup(); // å
³éç½ç»ç¯å¢ |
| | | } |
| | | |
| | | bool ServerSocket::initSocket() |
| | | { |
| | | WSAData wsa = { 0 }; |
| | | WSAStartup(MAKEWORD(2, 2), &wsa); // å¯å¨ç½ç»ç¯å¢ |
| | | // SOCK_STREAM:TCPåè®® |
| | | // SOCK_DGRAMï¼UDPåè®® |
| | | m_server = socket(AF_INET, SOCK_STREAM, 0); |
| | | SOCKADDR_IN addr; |
| | | addr.sin_family = AF_INET; |
| | | addr.sin_port = htons(16888); |
| | | addr.sin_addr.S_un.S_addr = 0; |
| | | int ret_bind = ::bind(m_server, (sockaddr*)&addr, sizeof(addr)); |
| | | if (ret_bind) { |
| | | cout << "bind fail:" << WSAGetLastError() << endl; |
| | | return false; |
| | | } |
| | | int ret_listen = listen(m_server, 5); |
| | | if (ret_listen) { |
| | | cout << "listen fail:" << WSAGetLastError() << endl; |
| | | return false; |
| | | } |
| | | // æ£å¸¸ï¼æååå§å |
| | | // å¯å¨acceptçº¿ç¨ |
| | | thread accept_thread(&ServerSocket::acceptThread, this); |
| | | accept_thread.detach(); // å¥ç¦»çº¿ç¨ï¼é²æ¢å¼å¸¸ç»æ |
| | | // å¯å¨å¿è·³æ£æµçº¿ç¨ |
| | | thread heart_check_thread(&ServerSocket::heartCheckThread, this); |
| | | heart_check_thread.detach(); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | void ServerSocket::acceptThread() |
| | | { |
| | | while (true) |
| | | { |
| | | SOCKADDR_IN addr; |
| | | SOCKET client; // å½åè¿æ¥ä¸ç客æ·ç«¯å¥æ¥å |
| | | int len = sizeof(addr); |
| | | |
| | | cout << "wait for conn..." << endl; |
| | | client = accept(m_server, (sockaddr*)&addr, &len); |
| | | cout << "conn client:" << client << endl; |
| | | |
| | | if (client == SOCKET_ERROR) { |
| | | cout << "socket error:" << WSAGetLastError() << endl; |
| | | break; |
| | | } |
| | | else if (client == 0) { |
| | | cout << "socket close:" << WSAGetLastError() << endl; |
| | | break; |
| | | } |
| | | // æ£å¸¸ |
| | | // å»ºç«æ°çé®å¼å¯¹ |
| | | m_clientsMap[client] = HEART_CHECK_TIMES; |
| | | // å建é¿è¿æ¥ççº¿ç¨ |
| | | thread recv_send_thread(&ServerSocket::recvAndSendThread, this, client); |
| | | recv_send_thread.detach(); |
| | | } |
| | | } |
| | | void ServerSocket::recvAndSendThread(SOCKET client) |
| | | { |
| | | while (true) { |
| | | char buffer[1024] = { 0 }; |
| | | int len_recv = recv(client, buffer, sizeof(buffer), 0); |
| | | cout << "len_recv:" << len_recv << " client:" << client << endl; |
| | | if (len_recv <= 0) { |
| | | cout << "client socket å·²å
³éæå¼å¸¸ç»æ:" << WSAGetLastError() << endl; |
| | | break; |
| | | } |
| | | // æ£å¸¸ |
| | | // éç½®å¿è·³éå¼ |
| | | m_clientsMap[client] = HEART_CHECK_TIMES; |
| | | // è§£å
å¤ç |
| | | cout << "buffer:" << buffer << endl; |
| | | |
| | | int type = *(int*)buffer; |
| | | if (type == 100) { |
| | | TestData* td = (TestData*)buffer; |
| | | cout << "æ¶å°ç»æä½:" << td->len << " " << td->data << endl; |
| | | } |
| | | else if (type == AD_REQ) { |
| | | // æ·»å è®¾å¤ |
| | | cout << "æ¶å°æ·»å 设å¤è¯·æ±" << endl; |
| | | ADReq *req = (ADReq*)buffer; |
| | | cout << "设å¤åç§°" << req->devInfo[0].deviceName << endl; |
| | | |
| | | // è°ç¨ æ·»å è®¾å¤ ä¸å¡API |
| | | DeviceManage devMan; |
| | | devMan.addDeviceBusiness(client, req); |
| | | } |
| | | else if (type == QUERY_PMS_REQ) { |
| | | cout << "æ¥è¯¢æé请æ±" << endl; |
| | | QueryPmsReq * req = (QueryPmsReq *)buffer; |
| | | PermissonManage pmsManage; |
| | | pmsManage.queryPmsByParam(client, req); |
| | | |
| | | } |
| | | else if (type == UPDATE_PMS_REQ) { |
| | | cout << "æ´æ°æé请æ±" << endl; |
| | | UpdatePmsReq * req = (UpdatePmsReq *)buffer; |
| | | PermissonManage pmsManage; |
| | | pmsManage.updatePms(client, req); |
| | | |
| | | } |
| | | |
| | | // åå°ä¸å¨çåæ¶å°çå
容ç»å¯¹åºå®¢æ·ç«¯ |
| | | //send(client, buffer, len_recv, 0); |
| | | } |
| | | closesocket(client); |
| | | } |
| | | |
| | | void ServerSocket::heartCheckThread() |
| | | { |
| | | while (m_openHeartCheck) |
| | | { |
| | | // 轮询map |
| | | for (auto iter = m_clientsMap.begin();iter != m_clientsMap.end();) { |
| | | iter->second--; // éå¼éå |
| | | cout << "client:" << iter->first << " éå¼:" << iter->second << endl; |
| | | if (iter->second == 0) { |
| | | // è¿æ¥æ æäºï¼å
³éè¿æ¥ï¼åå é¤ |
| | | cout << "åç°æ æå®¢æ·ç«¯è¿æ¥:" << iter->first << endl; |
| | | closesocket(iter->first); |
| | | iter = m_clientsMap.erase(iter); // æ¥æ¶è¿åå¼ï¼é²æ¢è¿ä»£å¨å¤±æ |
| | | } |
| | | else { |
| | | ++iter; |
| | | } |
| | | } |
| | | // é´é5ç§ |
| | | Sleep(5 * 1000); // ç¡ç 5000毫ç§ï¼å°±æ¯5ç§ |
| | | } |
| | | } |
New file |
| | |
| | | #ifndef COMMON_H |
| | | #define COMMON_H |
| | | |
| | | #include <string.h> |
| | | |
| | | enum TypeInfo { |
| | | |
| | | //注åç»å½ |
| | | LOGIN_REQ, // ç»å½è¯·æ± |
| | | LOGIN_RES, // ç»å½ååº |
| | | REGISTER_REQ, //注åè¯·æ± |
| | | REGISTER_RES, //注åååº |
| | | RESET_REQ, //éç½®å¯ç è¯·æ± |
| | | RESET_RES, //éç½®å¯ç ååº |
| | | |
| | | |
| | | //æé管ç |
| | | QUERY_PMS_REQ, // æåå·¥ç¼å·ãååæè使¥è¯¢äººåæéä¿¡æ¯è¯·æ± |
| | | UPDATE_PMS_REQ, // æè§è²idæ´æ°æéä¿¡æ¯è¯·æ± |
| | | QUERY_PMS_RES, // æ¥è¯¢äººååè§è²ä¿¡æ¯çååºç»æä½ |
| | | UPDATE_PMS_RES, // æéæ´æ°ç»æååºä½ |
| | | |
| | | //设å¤ç®¡ç |
| | | AD_REQ,//æ·»å 设å¤è¯·æ± |
| | | AD_RES,//æ·»å 设å¤ååº |
| | | MD_REQ,//ä¿®æ¹è®¾å¤è¯·æ± |
| | | MD_RES,//ä¿®æ¹è®¾å¤ååº |
| | | QD_REQ,//æ¥è¯¢è®¾å¤è¯·æ± |
| | | QD_RES,//æ¥è¯¢è®¾å¤ååº |
| | | |
| | | //å°å¾æ 注 |
| | | MML_REQ,//å°å¾æ 注å è½½è¯·æ± |
| | | MML_RES,//å°å¾æ 注å è½½ååº |
| | | MMI_REQ,//å°å¾æ 注æå
¥è¯·æ± |
| | | MMI_RES,//å°å¾æ 注æå
¥ååº |
| | | MMD_REQ,//å°å¾æ 注å é¤è¯·æ± |
| | | MMD_RES,//å°å¾æ 注å é¤ååº |
| | | |
| | | //大屿¾ç¤º |
| | | ENVIRONMENT_REQ,//ç¯å¢æ°æ®è¯·æ± |
| | | ENVIRONMENT_RES,//ç¯å¢æ°æ®ååº |
| | | DEVICESTATUS_REQ,//设å¤ç¶æè¯·æ± |
| | | DEVICESTATUS_RES,//设å¤ç¶æååº |
| | | MOVEMENTRECORD_REQ,//æä½æ¥å¿è¯·æ± |
| | | MOVEMENTRECORD_RES,//æä½æ¥å¿ååº |
| | | ALARMRECORD_REQ,//è¦æ¥è®°å½è¯·æ± |
| | | ALARMRECORD_RES,//è¦æ¥è®°å½ååº |
| | | YIELD_REQ,//ç
¤ç¿äº§éè¯·æ± |
| | | YIELD_RES,//ç
¤ç¿äº§éååº |
| | | |
| | | //è¦æ¥ç®¡ç |
| | | WARNING_REQ, // è¦æ¥è¯·æ± |
| | | WARNING_RES, // è¦æ¥ååº |
| | | |
| | | |
| | | //ç产计å管ç |
| | | ADD_PDPLAN_REQ,//æ·»å 䏿¡ç产计åç请æ±ç»æä½ |
| | | ADD_PDPLAN_RES,//æ·»å 䏿¡ç产计åçååºç»æä½ |
| | | DEL_PDPLAN_REQ,//å é¤ä¸æ¡ç产计åç请æ±ç»æä½ |
| | | DEL_PDPLAN_RES,//å é¤ä¸æ¡ç产计åçååºç»æä½ |
| | | UPDATE_PDPLAN_REQ,//æ´æ¹ä¸æ¡ç产计åç请æ±ç»æä½ |
| | | UPDATE_PDPLAN_RES,//æ´æ¹ä¸æ¡ç产计åçååºç»æä½ |
| | | QUERY_PDPLAN_REQ,//æ¥è¯¢ä¸æ¡ç产计åç请æ±ç»æä½ |
| | | QUERY_PDPLAN_RES,//æ¥è¯¢ä¸æ¡ç产计åçååºç»æä½ |
| | | |
| | | |
| | | ADD_MONOUTPUT_REQ,//æ·»å æäº§éç请æ±ç»æä½ |
| | | ADD_MONOUTPUT_RES,//æ·»å æäº§éçååºç»æä½ |
| | | DEL_MONOUTPUT_REQ,//å é¤æäº§éç请æ±ç»æä½ |
| | | DEL_MONOUTPUT_RES,//å é¤æäº§éçååºç»æä½ |
| | | UPDATE_MONOUTPUT_REQ,//æ´æ°æäº§éç请æ±ç»æä½ |
| | | UPDATE_MONOUTPUT_RES,//æ´æ°æäº§éçååºç»æä½ |
| | | QUERY_MONOUTPUT_REQ,//æ¥è¯¢æäº§éç请æ±ç»æä½ |
| | | QUERY_MONOUTPUT_RES,//æ¥è¯¢æäº§éçååºç»æä½ |
| | | |
| | | |
| | | //èªå¨å级 |
| | | VERSION_NUM_REQ, // çæ¬å·è¯·æ± |
| | | VERSION_NUM_RES, // çæ¬å·ååº |
| | | UPLOAD_FILE_REQ, // ä¸ä¼ æä»¶çè¯·æ± |
| | | UPLOAD_FILE_RES, // ä¸ä¼ æä»¶çååº |
| | | VERSION_INFOENTRY_REQ, // çæ¬ä¿¡æ¯å½å
¥è¯·æ± |
| | | VERSION_INFOENTRY_RES, //çæ¬ä¿¡æ¯å½å
¥ååº |
| | | VERSION_UPDATE_REQ, // çæ¬æ´æ°è¯·æ± |
| | | VERSION_UPDATE_RES, // çæ¬æ´æ°ååº |
| | | FILE_DOWNLOADS_REQ, // çæ¬æ´æ°æä»¶ä¸è½½è¯·æ± |
| | | FILE_DOWNLOADS_RES, // çæ¬æ´æ°æä»¶ä¸è½½ååº |
| | | DOWNLOAD_SUCCESSFULLY_RES, // æ´æ°æä»¶ä¸è½½æåçååº |
| | | |
| | | //æ¥å¿ |
| | | LOGSEARCH_REQ,//æ¥å¿æ¥è¯¢è¯·æ± |
| | | LOGSEARCH_RES,//æ¥å¿æ¥è¯¢ååº |
| | | |
| | | }; |
| | | |
| | | struct Head { |
| | | int type; |
| | | int len; |
| | | }; |
| | | |
| | | //注åç»å½ |
| | | //ç»å½è¯·æ± |
| | | struct LoginReq |
| | | { |
| | | Head head; |
| | | char userName[32]; |
| | | char password[32]; |
| | | LoginReq() { |
| | | head.type = LOGIN_REQ; |
| | | head.len = sizeof(LoginReq); |
| | | } |
| | | }; |
| | | |
| | | struct Permission |
| | | { |
| | | int admin;//è¶
级管çå |
| | | int loggerSearch; //æ¥å¿æ¥è¯¢ |
| | | int queryHistory; //åå²è®°å½ |
| | | int mapMark;//å°å¾ |
| | | int versionManage; // çæ¬ç®¡ç |
| | | int warning; //è¦æ¥ |
| | | int devManage; //设å¤ç®¡ç |
| | | int productPlan;//ç产计å |
| | | char roleName[32]; // è§è²å |
| | | }; |
| | | |
| | | //ç»å½ååº |
| | | struct LoginRes |
| | | { |
| | | Head head; |
| | | char userName[32]; |
| | | int status; // ç»å½ç¶æ |
| | | // ç»å½æåæ¶ï¼è¯¥è´¦å·å¯¹åºçæéç»å |
| | | Permission per; |
| | | LoginRes() |
| | | { |
| | | head.type = LOGIN_RES; |
| | | head.len = sizeof(LoginRes); |
| | | } |
| | | }; |
| | | |
| | | //注åè¯·æ± |
| | | struct RegisterReq |
| | | { |
| | | Head head; |
| | | char userName[32]; |
| | | char password[32]; |
| | | char email[50]; |
| | | char capcha[10];//éªè¯ç |
| | | char telephone[32]; |
| | | RegisterReq() { |
| | | head.type = REGISTER_REQ; |
| | | head.len = sizeof(RegisterReq); |
| | | } |
| | | }; |
| | | |
| | | //注åååº |
| | | struct RegisterRes |
| | | { |
| | | Head head; |
| | | char userName[32]; |
| | | int status; // 注åç¶æ |
| | | RegisterRes() |
| | | { |
| | | head.type = REGISTER_RES; |
| | | head.len = sizeof(RegisterRes); |
| | | } |
| | | }; |
| | | |
| | | //éç½®å¯ç è¯·æ± |
| | | struct ResetReq |
| | | { |
| | | Head head; |
| | | char email[50]; |
| | | char capcha[10];//éªè¯ç |
| | | char password[32];//æ°å¯ç |
| | | char confirmPassword[32];//确认å¯ç |
| | | ResetReq() { |
| | | head.type = RESET_REQ; |
| | | head.len = sizeof(ResetReq); |
| | | } |
| | | }; |
| | | |
| | | //éç½®å¯ç ååº |
| | | struct ResetRes |
| | | { |
| | | Head head; |
| | | char user_name[32]; |
| | | int status; // éç½®å¯ç ç¶æ |
| | | ResetRes() |
| | | { |
| | | head.type = RESET_RES; |
| | | head.len = sizeof(ResetRes); |
| | | } |
| | | }; |
| | | |
| | | //æé管ç |
| | | // æåå·¥ç¼å·ãååæè使¥è¯¢äººåæéä¿¡æ¯è¯·æ± |
| | | typedef struct QueryPmsReq { |
| | | Head head; |
| | | char userNo[32]; |
| | | char name[32]; |
| | | char permissonType[32]; |
| | | QueryPmsReq() { |
| | | head.type = QUERY_PMS_REQ; |
| | | memset(userNo, 0, 32); |
| | | memset(permissonType, 0, 32); |
| | | memset(name, 0, 32); |
| | | head.len = sizeof(QueryPmsReq); |
| | | } |
| | | } QueryPmsReq; |
| | | |
| | | // æè§è²idæ´æ°æéä¿¡æ¯è¯·æ± |
| | | typedef struct UpdatePmsReq { |
| | | Head head; |
| | | // 人å表主é®id |
| | | int id; |
| | | int queryHistory; |
| | | int loggerSearch; |
| | | int mapMark; |
| | | int devManage; |
| | | int productPlan; |
| | | int warningManage; |
| | | int versionManage; //çæ¬ç®¡ç |
| | | int admin; //ç³»ç»ç®¡çå |
| | | |
| | | char permissonType[32]; |
| | | UpdatePmsReq() { |
| | | head.type = QUERY_PMS_RES; |
| | | head.len = sizeof(UpdatePmsReq); |
| | | } |
| | | } UpdatePmsReq; |
| | | |
| | | // å个人ååæéèåæ¥è¯¢ç»æä½ |
| | | typedef struct PmsRes { |
| | | int queryHistory; |
| | | int loggerSearch; |
| | | int mapMark; |
| | | int devManage; |
| | | int productPlan; |
| | | int versionManage; //çæ¬ç®¡ç |
| | | int warningManage; |
| | | int admin; //ç³»ç»ç®¡çå |
| | | |
| | | int id; |
| | | |
| | | char userNo[32]; |
| | | char name[32]; |
| | | |
| | | char permissonType[32]; // è§è²ç±»å |
| | | |
| | | char department[32]; |
| | | char loginTime[32]; |
| | | char registerTime[32]; |
| | | } PmsRes; |
| | | |
| | | // æ¥è¯¢äººååè§è²ä¿¡æ¯çååºç»æä½ |
| | | typedef struct QueryPmsRes { |
| | | Head head; |
| | | int success; // 1为æå ,0为失败 |
| | | PmsRes pmsList[0]; |
| | | QueryPmsRes() { |
| | | head.type = QUERY_PMS_REQ; |
| | | } |
| | | } QueryPmsRes; |
| | | |
| | | // æéæ´æ°ç»æååºä½ |
| | | struct UpdatePmsRes { |
| | | Head head; |
| | | int success; // 1为æå ,0为失败 |
| | | UpdatePmsRes() { |
| | | head.type = UPDATE_PMS_RES; |
| | | head.len = sizeof(UpdatePmsRes); |
| | | } |
| | | |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | //设å¤ç®¡ç |
| | | struct DevicesInfo |
| | | { |
| | | char deviceName[32];//设å¤åç§° |
| | | char deviceStatus[32];//设å¤ç¶æ |
| | | char area[32]; // å°åº |
| | | double longitude;//ç»åº¦ |
| | | double latitude;//纬度 |
| | | char purchasingTime[15];//è´ä¹°æ¶é´ |
| | | char installTime[15];//å®è£
æ¶é´ |
| | | char manufacturer[100];//åå®¶ |
| | | char devicesSerialNumber[32];//设å¤ç¼ç |
| | | char devicesType[32];//设å¤ç±»å |
| | | }; |
| | | //æ·»å è®¾å¤ |
| | | struct ADReq//æ·»å è¯·æ± |
| | | { |
| | | Head head; |
| | | DevicesInfo devInfo[0]; |
| | | |
| | | ADReq() { |
| | | head.type = AD_REQ; |
| | | head.len = sizeof(ADReq); |
| | | } |
| | | |
| | | }; |
| | | |
| | | struct ADRes//æ·»å ååº |
| | | { |
| | | Head head; |
| | | int status; |
| | | ADRes() { |
| | | head.type = AD_RES; |
| | | head.len = sizeof(ADRes); |
| | | } |
| | | |
| | | }; |
| | | //ä¿®æ¹è®¾å¤ |
| | | struct MDRes//ä¿®æ¹ååº |
| | | { |
| | | Head head; |
| | | DevicesInfo info; |
| | | MDRes() { |
| | | head.type = MD_RES; |
| | | head.len = sizeof(MDRes); |
| | | } |
| | | }; |
| | | struct MDReq//ä¿®æ¹è¯·æ± |
| | | { |
| | | Head head; |
| | | int type; |
| | | MDReq() { |
| | | head.type = MD_REQ; |
| | | head.len = sizeof(MDReq); |
| | | } |
| | | }; |
| | | //æ¥è¯¢è®¾å¤ |
| | | struct QDReq//æ¥è¯¢è¯·æ± |
| | | { |
| | | Head head; |
| | | DevicesInfo info; |
| | | QDReq() { |
| | | head.type = QD_REQ; |
| | | head.len = sizeof(QDReq); |
| | | } |
| | | }; |
| | | struct QDRes//æ¥è¯¢ååº |
| | | { |
| | | Head head; |
| | | int type; |
| | | QDRes() { |
| | | head.type = QD_RES; |
| | | head.len = sizeof(QDRes); |
| | | } |
| | | }; |
| | | |
| | | |
| | | //å°å¾æ 注 |
| | | struct MarkInfo |
| | | { |
| | | int markId;//æ æ³¨ç¹id |
| | | double latitude;//纬度 |
| | | double longitude;//ç»åº¦ |
| | | int deviceId;//设å¤ID |
| | | int deviceStatus;//设å¤ç¶æ |
| | | char deviceName[32];//设å¤åç§° |
| | | }; |
| | | //å°å¾æ 注å è½½è¯·æ± |
| | | struct MMLReq//å°å¾ |
| | | { |
| | | Head head; |
| | | MMLReq() { |
| | | head.type = MML_REQ; |
| | | head.len = sizeof(MMLReq); |
| | | } |
| | | }; |
| | | //å°å¾æ 注å è½½ååºï¼ |
| | | struct MMLRes |
| | | { |
| | | Head head; |
| | | int status;//æä½ç¶æ |
| | | MarkInfo info[0]; |
| | | MMLRes() { |
| | | head.type = MML_RES; |
| | | head.len = sizeof(MMLRes); |
| | | } |
| | | }; |
| | | //å°å¾æ 注æå
¥è¯·æ± |
| | | struct MMIReq//å°å¾ |
| | | { |
| | | Head head; |
| | | MarkInfo info[0]; |
| | | MMIReq() { |
| | | head.type = MMI_REQ; |
| | | head.len = sizeof(MMIReq); |
| | | } |
| | | }; |
| | | //å°å¾æ 注æå
¥ååºï¼ |
| | | struct MMIRes |
| | | { |
| | | Head head; |
| | | int status;//æä½ç¶æ |
| | | MarkInfo info[0]; |
| | | MMIRes() { |
| | | head.type = MMI_RES; |
| | | head.len = sizeof(MMIRes); |
| | | } |
| | | }; |
| | | |
| | | //å°å¾æ 注å é¤è¯·æ± |
| | | struct MMDReq//å°å¾ |
| | | { |
| | | Head head; |
| | | MarkInfo info[0]; |
| | | MMDReq() { |
| | | head.type = MMD_REQ; |
| | | head.len = sizeof(MMDReq); |
| | | } |
| | | }; |
| | | //å°å¾æ 注å é¤ååºï¼ |
| | | struct MMDRes |
| | | { |
| | | Head head; |
| | | int status;//æä½ç¶æ |
| | | MarkInfo info[0]; |
| | | MMDRes() { |
| | | head.type = MMD_RES; |
| | | head.len = sizeof(MMDRes); |
| | | } |
| | | }; |
| | | |
| | | //大屿¾ç¤º |
| | | //ç¯å¢æ°æ®è¯·æ± |
| | | struct EnvironmentReq |
| | | { |
| | | Head head; |
| | | EnvironmentReq() { |
| | | head.type = ENVIRONMENT_REQ; |
| | | head.len = sizeof(EnvironmentReq); |
| | | } |
| | | }; |
| | | //ç¯å¢æ°æ®ååº |
| | | struct Environment |
| | | { |
| | | double longitude;//ç»åº¦ |
| | | double latitude;//纬度 |
| | | float temp;//温度 |
| | | float humidity;//湿度 |
| | | float oxygen;//æ°§æ°æµåº¦ |
| | | float carbon;//䏿°§å碳æµåº¦ |
| | | }; |
| | | struct EnvironmentRes |
| | | { |
| | | Head head; |
| | | int status; |
| | | Environment environment[0]; |
| | | EnvironmentRes() { |
| | | head.type = ENVIRONMENT_RES; |
| | | head.len = sizeof(EnvironmentRes); |
| | | } |
| | | }; |
| | | //设å¤ç¶æè¯·æ± |
| | | struct DeviceStatusReq |
| | | { |
| | | Head head; |
| | | DeviceStatusReq() { |
| | | head.type = DEVICESTATUS_REQ; |
| | | head.len = sizeof(DeviceStatusReq); |
| | | } |
| | | }; |
| | | //设å¤ç¶æååº |
| | | struct DeviceStatus |
| | | { |
| | | double longitude;//ç»åº¦ |
| | | double latitude;//纬度 |
| | | int deviceID;//设å¤ç¼å· |
| | | char deviceName[32];//设å¤åç§° |
| | | char deviceStatus[32];//设å¤ç¶æ |
| | | }; |
| | | struct DeviceStatusRes |
| | | { |
| | | Head head; |
| | | int status; |
| | | DeviceStatus deviceStatus[0]; |
| | | DeviceStatusRes() { |
| | | head.type = DEVICESTATUS_RES; |
| | | head.len = sizeof(DeviceStatusRes); |
| | | } |
| | | }; |
| | | //æä½æ¥å¿è¯·æ± |
| | | struct MovementRecordReq |
| | | { |
| | | Head head; |
| | | MovementRecordReq() { |
| | | head.type = MOVEMENTRECORD_REQ; |
| | | head.len = sizeof(MovementRecordReq); |
| | | } |
| | | }; |
| | | //æä½æ¥å¿ååº |
| | | struct MovementRecord |
| | | { |
| | | double longitude;//ç»åº¦ |
| | | double latitude;//纬度 |
| | | char userName;//æä½ç¨æ·å |
| | | char operateTime[32];//æä½æ¶é´ |
| | | char deviceName[32];//æä½è®¾å¤ |
| | | char movement[256];//æä½æè¿° |
| | | }; |
| | | struct MovementRecordRes |
| | | { |
| | | Head head; |
| | | int status; |
| | | MovementRecord movementRecord[0]; |
| | | MovementRecordRes() { |
| | | head.type = MOVEMENTRECORD_RES; |
| | | head.len = sizeof(MovementRecordRes); |
| | | } |
| | | }; |
| | | //è¦æ¥è®°å½è¯·æ± |
| | | struct AlarmRecordReq |
| | | { |
| | | Head head; |
| | | AlarmRecordReq() { |
| | | head.type = ALARMRECORD_REQ; |
| | | head.len = sizeof(AlarmRecordReq); |
| | | } |
| | | }; |
| | | //è¦æ¥è®°å½ååº |
| | | struct AlarmRecord |
| | | { |
| | | double longitude;//ç»åº¦ |
| | | double latitude;//纬度 |
| | | char alarmTime[32];//è¦æ¥æ¶é´ |
| | | char alarmtype[32];//å¤çæ¶é´ |
| | | char alarmContent[256];//è¦æ¥å
容 |
| | | }; |
| | | struct AlarmRecordRes |
| | | { |
| | | Head head; |
| | | int status; |
| | | AlarmRecord alarmRecord[0]; |
| | | AlarmRecordRes() { |
| | | head.type = ALARMRECORD_RES; |
| | | head.len = sizeof(AlarmRecordRes); |
| | | } |
| | | }; |
| | | //ç
¤ç¿äº§éè¯·æ± |
| | | struct YieldReq |
| | | { |
| | | Head head; |
| | | YieldReq() { |
| | | head.type = YIELD_REQ; |
| | | head.len = sizeof(YieldReq); |
| | | } |
| | | }; |
| | | //ç
¤ç¿äº§éååº |
| | | struct Yield |
| | | { |
| | | int month;//æä»½ |
| | | int output;//产é |
| | | }; |
| | | struct YieldRes |
| | | { |
| | | Head head; |
| | | int status; |
| | | Yield yield[0]; |
| | | YieldRes() { |
| | | head.type = YIELD_RES; |
| | | head.len = sizeof(YieldRes); |
| | | } |
| | | }; |
| | | |
| | | //è¦æ¥ç®¡ç |
| | | // è¦æ¥è¯·æ±ç»æä½ |
| | | struct WarningReq { |
| | | Head head; |
| | | |
| | | float oxygenWarning; |
| | | float carbonWarning; |
| | | float tempWarning; |
| | | float humidityWarning; |
| | | |
| | | WarningReq() { |
| | | head.type = WARNING_REQ; |
| | | head.len = sizeof(WarningReq); |
| | | } |
| | | }; |
| | | |
| | | |
| | | struct DataThreshold { |
| | | //éå¼ |
| | | float oxygenThreshold; |
| | | float carbonThreshold; |
| | | float tempThreshold; |
| | | float humidityThreshold; |
| | | }; |
| | | |
| | | struct Data { |
| | | float oxygen; // æ°§æ°æµåº¦ |
| | | float carbon; // 䏿°§å碳æµåº¦ |
| | | float temp; // 温度 |
| | | float humidity; // 湿度 |
| | | }; |
| | | |
| | | // è¦æ¥ååºç»æä½ |
| | | struct WarningRes { |
| | | Head head; |
| | | int status; // ååºç¶æï¼æ¯å¦ 0 表示æåï¼1 表示失败çï¼ |
| | | const char* message; // ååºæ¶æ¯æè¿° |
| | | |
| | | WarningRes(int stat, const char* msg) { |
| | | head.type = WARNING_RES; |
| | | head.len = sizeof(WarningRes); |
| | | status = stat; |
| | | message = msg; |
| | | } |
| | | }; |
| | | |
| | | //ç产计å管ç |
| | | struct PdplanInfo |
| | | { |
| | | int planId;//订åç¼å· |
| | | char planName[32];//订ååå |
| | | char startDate[32];//èµ·å§æ¥æ |
| | | char closingDate[32];//äº¤ä»æ¥æ |
| | | char pdName[8];//产åå |
| | | double plannedPd;//计åç产é |
| | | double actualPd;//å®é
ç产é |
| | | double progress;//ç产è¿åº¦ |
| | | int finishOntime;//æ¯å¦ææå®æ |
| | | }; |
| | | |
| | | struct MonoutputInfo |
| | | { |
| | | int month;//æä»½ |
| | | double aOutput;//a产åæäº§é |
| | | double bOutput;//b产åæäº§é |
| | | double cOutput;//c产åæäº§é |
| | | }; |
| | | |
| | | //æ·»å 䏿¡ç产计åç请æ±ç»æä½ |
| | | struct AddPdplanReq |
| | | { |
| | | Head head; |
| | | PdplanInfo info[0]; |
| | | AddPdplanReq() { |
| | | head.type = ADD_PDPLAN_REQ; |
| | | head.len = sizeof(AddPdplanReq); |
| | | } |
| | | }; |
| | | |
| | | //æ·»å 䏿¡ç产计åçååºç»æä½ |
| | | struct AddPdplanRes |
| | | { |
| | | Head head; |
| | | int status;//表示æ¯å¦æ·»å æåï¼0å¦1æ¯ |
| | | AddPdplanRes() { |
| | | head.type = ADD_PDPLAN_RES; |
| | | head.len = sizeof(AddPdplanRes); |
| | | } |
| | | }; |
| | | |
| | | //å é¤ä¸æ¡ç产计åç请æ±ç»æä½ |
| | | struct DelPdplanReq |
| | | { |
| | | Head head; |
| | | PdplanInfo info[0]; |
| | | DelPdplanReq() { |
| | | head.type = DEL_PDPLAN_REQ; |
| | | head.len = sizeof(DelPdplanReq); |
| | | } |
| | | }; |
| | | |
| | | //å é¤ä¸æ¡ç产计åçååºç»æä½ |
| | | struct DelPdplanRes |
| | | { |
| | | Head head; |
| | | int status;//表示æ¯å¦å 餿åï¼0å¦1æ¯ |
| | | DelPdplanRes() { |
| | | head.type = DEL_PDPLAN_RES; |
| | | head.len = sizeof(DelPdplanRes); |
| | | } |
| | | }; |
| | | |
| | | //æ´æ¹ä¸æ¡ç产计åç请æ±ç»æä½. |
| | | struct UpdatePdplanReq |
| | | { |
| | | Head head; |
| | | PdplanInfo info[0]; |
| | | UpdatePdplanReq() { |
| | | head.type = UPDATE_PDPLAN_REQ; |
| | | head.len = sizeof(UpdatePdplanReq); |
| | | } |
| | | }; |
| | | |
| | | //æ´æ¹ä¸æ¡ç产计åçååºç»æä½ |
| | | struct UpdatePdplanRes |
| | | { |
| | | Head head; |
| | | int status;//表示æ¯å¦æ´æ°æåï¼0å¦1æ¯ |
| | | PdplanInfo info[0]; |
| | | UpdatePdplanRes() { |
| | | head.type = UPDATE_PDPLAN_RES; |
| | | head.len = sizeof(UpdatePdplanRes); |
| | | } |
| | | }; |
| | | |
| | | //æ¥è¯¢ä¸æ¡ç产计åç请æ±ç»æä½ |
| | | struct QueryPdplanReq |
| | | { |
| | | Head head; |
| | | int planId;//订åç¼å· |
| | | char planName[32];//订åååå |
| | | char startDate[32];//èµ·å§æ¥æ |
| | | char closingDate[32];//äº¤ä»æ¥æ |
| | | char pdName[8];//产åå |
| | | double plannedPd;//计åç产é |
| | | double actualPd;//å®é
ç产é |
| | | double progress;//ç产è¿åº¦ |
| | | int finishOntime;//æ¯å¦ææå®æ |
| | | QueryPdplanReq() { |
| | | head.type = QUERY_PDPLAN_REQ; |
| | | head.len = sizeof(QueryPdplanReq); |
| | | } |
| | | }; |
| | | |
| | | //æ¥è¯¢ä¸æ¡ç产计åçååºç»æä½ |
| | | struct QueryPdplanRes |
| | | { |
| | | Head head; |
| | | int status;//表示æ¯å¦æ·»å æåï¼0å¦1æ¯ |
| | | PdplanInfo info[0]; |
| | | QueryPdplanRes() { |
| | | head.type = QUERY_PDPLAN_RES; |
| | | head.len = sizeof(QueryPdplanRes); |
| | | } |
| | | }; |
| | | |
| | | |
| | | //æ·»å æäº§éç请æ±ç»æä½ |
| | | struct AddMonoutputReq |
| | | { |
| | | Head head; |
| | | MonoutputInfo info[0]; |
| | | AddMonoutputReq() { |
| | | head.type = ADD_MONOUTPUT_REQ; |
| | | head.len = sizeof(AddMonoutputReq); |
| | | } |
| | | }; |
| | | |
| | | //æ·»å æäº§éçååºç»æä½ |
| | | struct AddMonoutputRes |
| | | { |
| | | Head head; |
| | | int status;//表示æ¯å¦æ·»å æåï¼0å¦1æ¯ |
| | | AddMonoutputRes() { |
| | | head.type = ADD_MONOUTPUT_RES; |
| | | head.len = sizeof(AddMonoutputRes); |
| | | } |
| | | }; |
| | | |
| | | //å é¤æäº§éç请æ±ç»æä½ |
| | | struct DelMonoutputReq |
| | | { |
| | | Head head; |
| | | MonoutputInfo info[0]; |
| | | DelMonoutputReq() { |
| | | head.type = DEL_MONOUTPUT_REQ; |
| | | head.len = sizeof(DelMonoutputReq); |
| | | } |
| | | }; |
| | | |
| | | //å é¤æäº§éçååºç»æä½ |
| | | struct DelMonoutputRes |
| | | { |
| | | Head head; |
| | | int status;//表示æ¯å¦å 餿åï¼0å¦1æ¯ |
| | | DelMonoutputRes() { |
| | | head.type = DEL_MONOUTPUT_RES; |
| | | head.len = sizeof(DelMonoutputRes); |
| | | } |
| | | }; |
| | | |
| | | //æ´æ¹æäº§éç请æ±ç»æä½. |
| | | struct UpdateMonoutputReq |
| | | { |
| | | Head head; |
| | | MonoutputInfo info[0]; |
| | | UpdateMonoutputReq() { |
| | | head.type = UPDATE_MONOUTPUT_REQ; |
| | | head.len = sizeof(UpdateMonoutputReq); |
| | | } |
| | | }; |
| | | |
| | | //æ´æ¹æäº§éçååºç»æä½ |
| | | struct UpdateMonoutputRes |
| | | { |
| | | Head head; |
| | | int status;//表示æ¯å¦æ´æ°æåï¼0å¦1æ¯ |
| | | MonoutputInfo info[0]; |
| | | UpdateMonoutputRes() { |
| | | head.type = UPDATE_MONOUTPUT_RES; |
| | | head.len = sizeof(UpdateMonoutputRes); |
| | | } |
| | | }; |
| | | |
| | | //æ¥è¯¢æäº§éç请æ±ç»æä½ |
| | | struct QueryMonoutputReq |
| | | { |
| | | Head head; |
| | | int month;//æä»½ |
| | | double aOutput;//a产åæäº§é |
| | | double bOutput;//b产åæäº§é |
| | | double cOutput;//c产åæäº§é |
| | | QueryMonoutputReq() { |
| | | head.type = QUERY_MONOUTPUT_REQ; |
| | | head.len = sizeof(QueryMonoutputReq); |
| | | } |
| | | }; |
| | | |
| | | //æ¥è¯¢æäº§éçååºç»æä½ |
| | | struct QueryMonoutputRes |
| | | { |
| | | Head head; |
| | | int status;//表示æ¯å¦æ·»å æåï¼0å¦1æ¯ |
| | | MonoutputInfo info[0]; |
| | | QueryMonoutputRes() { |
| | | head.type = QUERY_MONOUTPUT_RES; |
| | | head.len = sizeof(QueryMonoutputRes); |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | //å岿¥è¯¢åæ |
| | | // å岿¥è¯¢è¯·æ±ç»æä½ |
| | | struct HistoryQueryReq { |
| | | Head head; |
| | | //æ ¹æ®æ¶é´èå´æ¥è¯¢ |
| | | char startTime[32]; |
| | | char endTime[32]; |
| | | //å
³é®åæ¥è¯¢ |
| | | char keyWord[32]; |
| | | HistoryQueryReq() { |
| | | // åå§åæ°æ®å¤´ |
| | | head.type = QUERY_MONOUTPUT_REQ; |
| | | head.len = sizeof(HistoryQueryReq); |
| | | // åå§åæ¥è¯¢æ¡ä»¶å段 |
| | | memset(startTime, 0, sizeof(startTime)); |
| | | memset(endTime, 0, sizeof(endTime)); |
| | | |
| | | } |
| | | }; |
| | | |
| | | // å岿¥è¯¢ååºç»æä½ |
| | | |
| | | // ç³»ç»è¿è¡ç¶æè¡¨ç¸å
³ä¿¡æ¯ |
| | | struct HistroyInfo { |
| | | WarningRes warn;//è¦æ¥æ¥è¯¢ |
| | | QDRes dev;//è®¾å¤æ¥è¯¢ |
| | | QueryPdplanRes pro;//çäº§è®¡åæ¥è¯¢ |
| | | }; |
| | | struct HistoryQueryRes { |
| | | Head head; |
| | | //HistroyInfo sys[0]; |
| | | HistoryQueryRes() { |
| | | // åå§åæ°æ®å¤´ |
| | | head.type = QUERY_MONOUTPUT_RES; |
| | | head.len = sizeof(HistoryQueryRes); |
| | | } |
| | | }; |
| | | |
| | | |
| | | //èªå¨å级 |
| | | struct VersionNumReq // çæ¬å·è¯·æ± |
| | | { |
| | | Head head; |
| | | VersionNumReq() { |
| | | head.type = VERSION_NUM_REQ; |
| | | head.len = sizeof(VersionNumReq); |
| | | } |
| | | }; |
| | | |
| | | struct VersionNumRes // çæ¬å·ååº |
| | | { |
| | | Head head; |
| | | char versionId[64]; // çæ¬å· |
| | | VersionNumRes() { |
| | | head.type = VERSION_NUM_RES; |
| | | head.len = sizeof(VersionNumRes); |
| | | } |
| | | }; |
| | | |
| | | // æä»¶ä¼ è¾ |
| | | struct FileInfo |
| | | { |
| | | char fileName[256]; |
| | | long long fileSize; |
| | | char s_filepath[128]; |
| | | char content[0]; |
| | | }; |
| | | |
| | | struct UploadFileReq // ä¸ä¼ æä»¶çè¯·æ± |
| | | { |
| | | Head head; |
| | | FileInfo fileInfo; |
| | | UploadFileReq() { |
| | | head.type = UPLOAD_FILE_REQ; |
| | | head.len = sizeof(UploadFileReq); |
| | | } |
| | | }; |
| | | |
| | | struct UploadFileRes { // ä¸ä¼ æä»¶çååº |
| | | Head head; |
| | | bool state = false; |
| | | char fileName[256]; |
| | | long long file_size; |
| | | UploadFileRes() |
| | | { |
| | | head.type = UPLOAD_FILE_RES; |
| | | head.len = sizeof(UploadFileRes); |
| | | } |
| | | }; |
| | | |
| | | // çæ¬ä¿¡æ¯å½å
¥ |
| | | // è¯·æ± |
| | | struct VersionInfoEntryReq { |
| | | Head head; |
| | | char versionId[64]; // çæ¬å· |
| | | char versionIdOld[64]; // ä¸ä¸ä¸ªçæ¬å· |
| | | int fileNum; |
| | | char context[0]; //å
å«ä¸è½½æä»¶ä¿¡æ¯ |
| | | |
| | | VersionInfoEntryReq() |
| | | { |
| | | head.type = VERSION_INFOENTRY_REQ; |
| | | head.len = sizeof(VersionInfoEntryReq); |
| | | } |
| | | }; |
| | | |
| | | // çæ¬ä¿¡æ¯å½å
¥ååº |
| | | struct VersionInfoEntryRes { |
| | | Head head; |
| | | bool state = false; |
| | | VersionInfoEntryRes() |
| | | { |
| | | head.type = VERSION_INFOENTRY_RES; |
| | | head.len = sizeof(VersionInfoEntryRes); |
| | | } |
| | | }; |
| | | |
| | | // çæ¬æ´æ°è¯·æ± |
| | | struct VersionUpdateReq { |
| | | Head head; |
| | | |
| | | char curVersionId[64]; // çæ¬å· |
| | | VersionUpdateReq() |
| | | { |
| | | head.type = VERSION_UPDATE_REQ; |
| | | head.len = sizeof(VersionUpdateReq); |
| | | } |
| | | }; |
| | | |
| | | // çæ¬æ´æ°ååº |
| | | struct VersionUpdateRes { |
| | | Head head; |
| | | bool state = false; |
| | | char versionId[64]; // çæ¬å· |
| | | char updateDate[32]; // æ´æ°æ¶é´ |
| | | char versionDescription[1024]; //æ´æ°æè¿° |
| | | |
| | | VersionUpdateRes() |
| | | { |
| | | head.type = VERSION_UPDATE_RES; |
| | | head.len = sizeof(VersionUpdateRes); |
| | | } |
| | | }; |
| | | |
| | | // çæ¬æ´æ°æä»¶ä¸è½½è¯·æ± |
| | | struct FileDownloadsReq { |
| | | Head head; |
| | | char versionId[64]; // çæ¬å· |
| | | FileDownloadsReq() |
| | | { |
| | | head.type = FILE_DOWNLOADS_REQ; |
| | | head.len = sizeof(FileDownloadsReq); |
| | | } |
| | | }; |
| | | |
| | | // çæ¬æ´æ°æä»¶ä¸è½½ååº |
| | | struct FileDownloadsRes { |
| | | Head head; |
| | | char versionId[64]; // çæ¬å· |
| | | char filename[128]; //æä»¶å |
| | | long long filesize; //æä»¶å¤§å° |
| | | char c_filepath[128]; //客æ·ç«¯æ¾ææ°çæ¬çæ¬å°è·¯å¾ |
| | | int fileNum; // æä»¶æ°é |
| | | long long allFileSize; // æä»¶æ»å¤§å° |
| | | char content[0]; |
| | | FileDownloadsRes() |
| | | { |
| | | head.type = FILE_DOWNLOADS_RES; |
| | | head.len = sizeof(FileDownloadsRes); |
| | | } |
| | | }; |
| | | |
| | | // æ´æ°æä»¶ä¸è½½æåçååº |
| | | struct DownloadSuccessfullyRes { |
| | | Head head; |
| | | bool state = false; |
| | | char fileName[256]; |
| | | long long fileSize; |
| | | DownloadSuccessfullyRes() |
| | | { |
| | | head.type = DOWNLOAD_SUCCESSFULLY_RES; |
| | | head.len = sizeof(DownloadSuccessfullyRes); |
| | | } |
| | | }; |
| | | |
| | | |
| | | //æ¥å¿ |
| | | struct ParsedLog { |
| | | char timeStamp[64]; // æ¶é´æ³ |
| | | char deviceId[64]; // 设å¤ID |
| | | char level[16]; // æ¥å¿çº§å« |
| | | char content[256]; // æ¥å¿å
容 |
| | | char userId[64]; // ç¨æ·ID |
| | | char fileName[32]; //æä»¶å |
| | | char functionName[32]; //彿°å |
| | | int problemLine; //产çé误è¡å· |
| | | }; |
| | | |
| | | // æ¥å¿æ¥è¯¢è¯·æ±ç»æä½ |
| | | // æ¥å¿æ¥è¯¢è¯·æ±ç»æä½ |
| | | struct LogQueryReq { |
| | | Head head; // æ°æ®å¤´ |
| | | char timeStamp[64]; // æ¶é´æ³ |
| | | char content[256]; // æ¥å¿å
容 |
| | | char level[16]; //æ¥å¿çº§å« |
| | | char deviceId[64]; // 设å¤ID |
| | | // æ åæé 彿° |
| | | LogQueryReq() { |
| | | head.type = LOGSEARCH_REQ; |
| | | head.len = sizeof(LogQueryReq); |
| | | } |
| | | }; |
| | | |
| | | // æ¥å¿æ¥è¯¢ååºç»æä½ |
| | | struct LogQueryRes { |
| | | Head head; |
| | | int status; // ååºç¶æ (å¦ 0 表示æåï¼é 0 表示失败) |
| | | char errorMessage[256]; // é误信æ¯ï¼å¦ææï¼ |
| | | |
| | | // æ åæé 彿° |
| | | LogQueryRes() { |
| | | head.type = LOGSEARCH_RES; |
| | | head.len = sizeof(LogQueryRes); |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | #endif // COMMON_H |
| | |
| | | #include "stdafx.h" |
| | | #include "ConnectionPool.h" |
| | | ConnectionPool::ConnectionPool() |
| | | { |
| | | if (!parseXmlFile()) |
| | | |
| | | #include <fstream> |
| | | #include <iostream> |
| | | #include <thread> |
| | | |
| | | ConnectionPool* ConnectionPool::getInstance() { |
| | | static ConnectionPool connPool; |
| | | return &connPool; |
| | | } |
| | | |
| | | ConnectionPool::ConnectionPool() { |
| | | // å è½½é
ç½®æä»¶ |
| | | if (!parseJsonFile()) { |
| | | std::cout << "parseJsonFile is failed!" << std::endl; |
| | | return; |
| | | for (m_num = 0; m_num < m_minSize;) { |
| | | bool flag = addConnection(); |
| | | if (!flag) { |
| | | return; |
| | | } |
| | | } |
| | | // 妿å线ç¨çä»»å¡å½æ°æ¯ç±»çééæå½æ°ï¼æä»¬éè¦æå®ä»»å¡å½æ°çå°ååä»»å¡å½æ°çææè
|
| | | thread producer(&ConnectionPool::productConnection, this); // åå»ºè¿æ¥ |
| | | thread recycler(&ConnectionPool::recycleConnection, this); // æ£æµå¹¶éæ¯è¿æ¥ |
| | | // 线ç¨å离ï¼é²æ¢é»å¡ä¸»çº¿ç¨ |
| | | for ( int i = 0 ; i < m_min_conn ; i++ ) { |
| | | addConnection( ); |
| | | } |
| | | // å建ä¸ä¸ªçº¿ç¨ï¼å¯¹è¿æ¥æ°è¿è¡çæ§ ï¼è¿æ¥æ°ä¸è¶³å°±åç»§ç»å建 |
| | | std::thread producer(&ConnectionPool::produce, this); |
| | | // å¯¹è¿æ¥æ°è¿è¡çæ§ ï¼å¦ææå¤ªå¤ç©ºé²å¾çº¿ç¨ ï¼é£ä¹å°±å¯¹å
¶è¿è¡éæ¯ |
| | | std::thread recycler( &ConnectionPool::recycle, this); |
| | | |
| | | // 线ç¨å离 |
| | | producer.detach(); |
| | | recycler.detach(); |
| | | } |
| | | ConnectionPool::~ConnectionPool() |
| | | { |
| | | while (!m_connections.empty()) { |
| | | MysqlConn* conn = m_connections.front(); |
| | | m_connections.pop(); |
| | | delete conn; |
| | | } |
| | | } |
| | | bool ConnectionPool::parseXmlFile() |
| | | { |
| | | TiXmlDocument xml("mysql.xml"); |
| | | // å è½½æä»¶ |
| | | bool res = xml.LoadFile(); |
| | | if (!res) { |
| | | return false; // æç¤º |
| | | } |
| | | // æ ¹ |
| | | TiXmlElement* rootElement = xml.RootElement(); |
| | | TiXmlElement* childElement = rootElement->FirstChildElement("mysql"); |
| | | // 读åä¿¡æ¯ |
| | | m_ip = childElement->FirstChildElement("ip")->GetText(); |
| | | m_port = static_cast<unsigned short>(stoi(string(childElement->FirstChildElement("port")->GetText()))); |
| | | m_user = childElement->FirstChildElement("username")->GetText(); |
| | | m_passwd = childElement->FirstChildElement("password")->GetText(); |
| | | m_dbName = childElement->FirstChildElement("dbName")->GetText(); |
| | | m_minSize = static_cast<int>(stoi(string(childElement->FirstChildElement("minSize")->GetText()))); |
| | | m_maxSize = static_cast<int>(stoi(string(childElement->FirstChildElement("maxSize")->GetText()))); |
| | | m_maxIdleTime = static_cast<int>(stoi(string(childElement->FirstChildElement("maxIdleTime")->GetText()))); |
| | | m_timeout = static_cast<int>(stoi(string(childElement->FirstChildElement("timeout")->GetText()))); |
| | | return true; |
| | | } |
| | | bool ConnectionPool::addConnection() |
| | | { |
| | | MysqlConn* conn = new MysqlConn; |
| | | bool res = conn->connect(m_user, m_passwd, m_dbName, m_ip, m_port); |
| | | if (res) { |
| | | // å·æ°ç©ºé²æ¶é´ |
| | | conn->refreashAliveTime(); |
| | | m_connections.push(conn); |
| | | ++m_num; |
| | | |
| | | bool ConnectionPool::parseJsonFile() { |
| | | |
| | | /*std::ifstream ifs("dbconf.json"); |
| | | Reader rd; |
| | | Value root; |
| | | rd.parse(ifs, root); |
| | | if ( root.isObject( ) ) { |
| | | m_ip = root["ip"].asString(); |
| | | m_port = root["port"].asInt(); |
| | | m_userName = root["userName"].asString(); |
| | | m_passwd = root["password"].asString(); |
| | | m_db = root["dbName"].asString(); |
| | | m_min_conn = root["minSize"].asInt(); |
| | | m_max_conn = root["maxSize"].asInt(); |
| | | max_del_time = root["maxDleTime"].asInt(); |
| | | m_timeout = root["timeout"].asInt(); |
| | | return true; |
| | | }*/ |
| | | return false; |
| | | } |
| | | |
| | | void ConnectionPool::description() { |
| | | std::cout << m_ip << ". " << m_userName << ". " << m_passwd << ". " << m_db << ". " |
| | | << m_port << ". " << m_max_conn << ". " << m_min_conn << ". " << m_timeout << ". " |
| | | << max_del_time << std::endl; |
| | | } |
| | | |
| | | ConnectionPool::~ConnectionPool() { |
| | | while (!m_connkQueue.empty()) { |
| | | MysqlConn* conn = m_connkQueue.front(); |
| | | m_connkQueue.pop(); |
| | | delete conn; |
| | | } |
| | | else { |
| | | |
| | | } |
| | | |
| | | void ConnectionPool::addConnection() { |
| | | MysqlConn* conn = new MysqlConn(); |
| | | if ( !conn->connect( m_ip, m_userName, m_passwd, m_db, m_port ) ) { |
| | | std::cout << "ConnectionPool connect to mysql is failed!" << std::endl; |
| | | delete conn; |
| | | return false; // æç¤º |
| | | return; |
| | | } |
| | | conn->refreshActiveTime( ); |
| | | m_connkQueue.push(conn); |
| | | m_cond.notify_one(); // å¤éä¸ä¸ªçº¿ç¨ |
| | | } |
| | | void ConnectionPool::productConnection() |
| | | { |
| | | |
| | | void ConnectionPool::produce(){ |
| | | while (true) { |
| | | unique_lock<mutex> lc(m_mutex); |
| | | m_cond.wait(lc, [this]() {return m_connections.empty(); }); |
| | | if (m_num < m_maxSize) { |
| | | bool flag = addConnection(); |
| | | if (!flag) { |
| | | return; |
| | | } |
| | | std::unique_lock<std::mutex> lock(m_mutex); |
| | | while (m_connkQueue.size() >= m_min_conn) { // è¿æ¥éåçæ°éå¤§äºæå°çè¿æ¥æ° |
| | | m_cond.wait(lock); |
| | | } |
| | | // å¤é |
| | | m_cond1.notify_all(); |
| | | addConnection(); |
| | | } |
| | | } |
| | | void ConnectionPool::recycleConnection() |
| | | { |
| | | while (true) { |
| | | // ä¼ç 䏿®µæ¶é´ 0.5s |
| | | this_thread::sleep_for(milliseconds(500)); |
| | | lock_guard<mutex> lc(m_mutex); |
| | | while (!m_connections.empty() && m_num > m_minSize) { |
| | | MysqlConn* conn = m_connections.front(); |
| | | if (conn->getAliveTime() >= m_maxIdleTime) { |
| | | m_connections.pop(); |
| | | |
| | | // å é¤ç©ºé²è¿æ¥ |
| | | void ConnectionPool::recycle() { |
| | | while ( true ) { |
| | | std::this_thread::sleep_for( std::chrono::milliseconds(500)); // ä¼ç 500 ms |
| | | std::unique_lock<std::mutex>lock(m_mutex); |
| | | while ( m_connkQueue.size() > m_min_conn ) { |
| | | MysqlConn* conn = m_connkQueue.front( ); |
| | | if (conn->getActiveTime() >= max_del_time) { |
| | | m_connkQueue.pop(); |
| | | delete conn; |
| | | --m_num; |
| | | } |
| | | else { |
| | | break; |
| | |
| | | } |
| | | } |
| | | } |
| | | ConnectionPool* ConnectionPool::getConnectPool() |
| | | { |
| | | // ä¸ä½¿ç¨äºæ¥éç线ç¨å®å
¨çææ±æ¨¡å¼ |
| | | static ConnectionPool pool; // åªå¨ç¬¬ä¸æ¬¡è°ç¨å½æ°æ¶åå§å |
| | | return &pool; |
| | | } |
| | | shared_ptr<MysqlConn> ConnectionPool::getConnection() |
| | | { |
| | | unique_lock<mutex> lc(m_mutex); |
| | | while (m_connections.empty()) { |
| | | if (cv_status::timeout == m_cond1.wait_for(lc, chrono::milliseconds(m_timeout))) { |
| | | if (m_connections.empty()) { |
| | | // cout << "out of time" << endl; |
| | | return nullptr; // ç»æ // æç¤º |
| | | // continue; // å©ç¨whileé
åcontinue ç»§ç»é»å¡ |
| | | } |
| | | |
| | | std::shared_ptr<MysqlConn> ConnectionPool::getMysqlConn() { |
| | | |
| | | std::unique_lock<std::mutex>lock(m_mutex); |
| | | while ( m_connkQueue.empty()) { |
| | | // 妿çå¾
䏿®µæ¶é´å,éåè¿æ¯ä¸ºç©º,è¿åä¸ä¸ª null |
| | | if ( std::cv_status::timeout == m_cond.wait_for(lock, std::chrono::milliseconds(m_timeout)) ) { |
| | | if( m_connkQueue.empty( ) ) return nullptr; |
| | | } |
| | | } |
| | | // è¦æå®å é¤å¨destructorï¼æ¥ä¿è¯è¿æ¥çå½è¿ |
| | | shared_ptr<MysqlConn> conn(m_connections.front(), [this](MysqlConn* conn) { |
| | | // å éä¿è¯éå线ç¨å®å
¨ |
| | | // m_mutex.lock(); // 1 |
| | | unique_lock<mutex> lc(m_mutex); // 2 |
| | | // lock_guard<mutex> lc(m_mutex); // 3 |
| | | conn->refreashAliveTime(); |
| | | m_connections.push(conn); |
| | | // m_mutex.unlock(); // 1 |
| | | std::shared_ptr<MysqlConn> connPtr(std::move(m_connkQueue.front()), [this](MysqlConn* conn) { |
| | | std::unique_lock <std::mutex>lock(m_mutex) ; |
| | | conn->refreshActiveTime(); |
| | | m_connkQueue.push(conn); |
| | | }); |
| | | m_connections.pop(); |
| | | m_cond.notify_all(); |
| | | return conn; |
| | | } |
| | | m_connkQueue.pop(); |
| | | m_cond.notify_one(); // å¤éé»å¡çç产è
线ç¨,å¼å§ç产 |
| | | return connPtr; |
| | | } |
| | |
| | | #pragma once |
| | | #include "MysqlConn.h" |
| | | #include "./tinyxml/tinyxml.h" |
| | | |
| | | #include <queue> |
| | | #include <mutex> |
| | | #include <thread> |
| | | #include <atomic> |
| | | #include <condition_variable> |
| | | //#include <json/json.h> |
| | | |
| | | #include "MysqlConn.h" |
| | | |
| | | #pragma comment(lib, "./tinyxml/x64/Debug/tinyxml.lib") |
| | | //using namespace Json; |
| | | |
| | | // åºç¨-å便¨¡å¼ï¼ææ±æ¨¡å¼[éè¦èèå¤çº¿ç¨å®å
¨é®é¢] |
| | | class ConnectionPool |
| | | { |
| | | private: |
| | | ConnectionPool(); |
| | | // ç§»å¨æ·è´æç»è¿æ¯æä¸ä»
æä¸ä¸ªå¯¹è±¡ï¼æä»¥ä¾æ§æ¯å±äºå便¨¡å¼ã |
| | | // delete 黿¢æ·è´æé åæ·è´èµå¼çç±»å¯¹è±¡çæ |
| | | ConnectionPool(ConnectionPool&) = delete; |
| | | ConnectionPool& operator=(ConnectionPool&) = delete; |
| | | ~ConnectionPool(); |
| | | // è§£æxmlé
ç½®æä»¶ è¯»åæ°æ®åºåè¿æ¥æ± çç¸å
³ä¿¡æ¯ |
| | | bool parseXmlFile(); |
| | | // æ·»å è¿æ¥ |
| | | bool addConnection(); |
| | | // 线ç¨å½æ° |
| | | void productConnection(); |
| | | void recycleConnection(); |
| | | |
| | | // åæ¾æ°æ®åºè¿æ¥æ± 建ç«çè¿æ¥ |
| | | queue<MysqlConn*> m_connections; |
| | | // ä¸äºåºæ¬ä¿¡æ¯ |
| | | string m_ip; // IP |
| | | unsigned short m_port; // ç«¯å£ |
| | | string m_user; // ç¨æ·å |
| | | string m_passwd; // å¯ç |
| | | string m_dbName; // æ°æ®åºåç§° |
| | | int m_minSize; // åå§è¿æ¥é(æå°è¿æ¥é) |
| | | int m_maxSize; // æå¤§è¿æ¥é |
| | | int m_timeout; // è¶
æ¶æ¶é¿ |
| | | int m_maxIdleTime; // æå¤§ç©ºé²æ¶é¿ |
| | | // 线ç¨å®å
¨ç¸å
³ |
| | | mutex m_mutex; |
| | | condition_variable m_cond; // ä»
ç¨ä¸ä¸ªæ¡ä»¶å鿥å¤é线ç¨ï¼ä½å¹¶ä¸å½±å线ç¨è¿è¡ |
| | | condition_variable m_cond1; |
| | | // è¿æ¥æ°é |
| | | atomic_int m_num; // è¿æ¥çæ»æ°é |
| | | public: |
| | | // è·ååä¾å¯¹è±¡çæ¥å£ |
| | | static ConnectionPool* getConnectPool(); |
| | | // ç¨æ·è·åè¿æ¥çæ¥å£, 妿è·å失败ï¼ä¼è¿ånullptr |
| | | shared_ptr<MysqlConn> getConnection(); |
| | | static ConnectionPool* getInstance( ); |
| | | |
| | | std::shared_ptr<MysqlConn> getMysqlConn(); // 仿°æ®åºè¿æ¥æ± è·åè¿æ¥ |
| | | |
| | | ConnectionPool(const ConnectionPool& other) = delete; |
| | | ConnectionPool& operator = (const ConnectionPool & other ) = delete; |
| | | |
| | | ~ConnectionPool(); |
| | | |
| | | void description(); |
| | | |
| | | protected: |
| | | ConnectionPool( ); // æé 彿° |
| | | private: |
| | | bool parseJsonFile(); // è§£æé
ç½® |
| | | |
| | | void produce(); |
| | | void recycle(); |
| | | void addConnection(); // å¢å è¿æ¥æ° |
| | | |
| | | std::string m_ip; |
| | | std::string m_userName; |
| | | std::string m_passwd; |
| | | std::string m_db; |
| | | unsigned short m_port; |
| | | |
| | | int m_max_conn; |
| | | int m_min_conn; |
| | | |
| | | int m_timeout; // è¿æ¥è¶
æ¶æ¶é´ |
| | | int max_del_time; // æå¤§å 餿¶é´( è¿æ¥ç©ºé²æ¶é´è¶
è¿è¿ä¸ª,å°±ç»å½åè¿æ¥å
³é ) |
| | | std::queue<MysqlConn*>m_connkQueue ; // è¿æ¥éå |
| | | std::mutex m_mutex; // äºæ¥é |
| | | std::condition_variable m_cond; // æ¡ä»¶åé |
| | | }; |
| | | |
| | |
| | | #include "stdafx.h" |
| | | #include "MysqlConn.h" |
| | | #include <regex> |
| | | |
| | | MysqlConn::MysqlConn()//åå§åæ°æ®åº |
| | | { |
| | | m_result = nullptr; |
| | | m_mysqlRow = nullptr; |
| | | // ä¼ å
¥nullptr空æéæ¶ï¼ä¼èªå¨åé
ä¸ä¸ªMYSQL对象 |
| | | m_conn = mysql_init(nullptr); |
| | | } |
| | | MysqlConn::~MysqlConn()//éæ¾æ°æ®åºè¿æ¥ |
| | | { |
| | | freeRes(); // éæ¾ç»æé |
| | | if (m_conn != nullptr) { |
| | | mysql_close(m_conn); |
| | | m_conn = nullptr; |
| | | } |
| | | } |
| | | void MysqlConn::freeRes()//ç»æééæ¾ |
| | | { |
| | | if (m_result) { |
| | | mysql_free_result(m_result); |
| | | m_result = nullptr; |
| | | } |
| | | } |
| | | bool MysqlConn::connect(const string user, const string passwd, \ |
| | | const string dbName, string ip, \ |
| | | const unsigned short port)//è¿æ¥æ°æ®åº |
| | | { |
| | | MYSQL* res = mysql_real_connect(m_conn, ip.c_str(), user.c_str(), \ |
| | | passwd.c_str(), dbName.c_str(), port, nullptr, 0); |
| | | // ä¿®æ¹ç¼ç |
| | | mysql_set_character_set(m_conn, "gb2312"); |
| | | return res != nullptr; |
| | | } |
| | | bool MysqlConn::update(const string sql) const |
| | | { |
| | | // æ§è¡æåè¿å0ï¼ |
| | | int res = mysql_real_query(m_conn, sql.c_str(), static_cast<unsigned int>(sql.size())); |
| | | if (res != 0) { |
| | | return false; // æç¤º |
| | | } |
| | | return true; |
| | | } |
| | | bool MysqlConn::query(const string sql) |
| | | { |
| | | freeRes(); |
| | | int res = mysql_real_query(m_conn, sql.c_str(), static_cast<unsigned int>(sql.size())); |
| | | if (res != 0) { |
| | | return false; // æç¤º |
| | | } |
| | | m_result = mysql_store_result(m_conn); |
| | | return true; |
| | | } |
| | | bool MysqlConn::getRes() |
| | | { |
| | | if (m_result != nullptr) { |
| | | // char** è·ååè¡è®°å½ |
| | | m_mysqlRow = mysql_fetch_row(m_result); |
| | | if (m_mysqlRow != nullptr) { |
| | | return true; |
| | | } |
| | | freeRes(); |
| | | } |
| | | return false; |
| | | } |
| | | string MysqlConn::getValue(const int fieldIndex) const |
| | | { |
| | | int fieldCount = mysql_num_fields(m_result); |
| | | if (fieldIndex >= fieldCount || fieldIndex < 0) { |
| | | return string(); // æç¤º |
| | | } |
| | | char* value = m_mysqlRow[fieldIndex]; |
| | | // å¾å°ä¸ä¸ªä¿åååæ®µå¼é¿åº¦çæ°ç» |
| | | unsigned long* len = mysql_fetch_lengths(m_result); |
| | | unsigned long length = len[fieldIndex]; |
| | | // 鲿¢ç»æä¸åå¨\0å¯¼è´æ°æ®ä¸¢å¤± |
| | | return string(value, length); |
| | | } |
| | | bool MysqlConn::selectDB(const string dbName) const |
| | | { |
| | | int res = mysql_select_db(m_conn, dbName.c_str()); |
| | | if (res != 0) { |
| | | return false; // æç¤º |
| | | } |
| | | return true; |
| | | } |
| | | void MysqlConn::backupCurrentDB(const string path) |
| | | { |
| | | string sql = "show tables"; |
| | | int r = mysql_real_query(m_conn, sql.c_str(), static_cast<unsigned long>(sql.size())); |
| | | if (r != 0) { |
| | | return; // æç¤º |
| | | } |
| | | MYSQL_RES* tableRes = mysql_store_result(m_conn); |
| | | for (int i = 0; i < mysql_num_rows(tableRes); ++i) { |
| | | MYSQL_ROW tableName = mysql_fetch_row(tableRes); |
| | | backupCurrentTable(path, tableName[0]); |
| | | } |
| | | } |
| | | void MysqlConn::backupCurrentTable(const string path, const string tableName) |
| | | { |
| | | string file = path + tableName + ".sql"; |
| | | ofstream ofs(file); |
| | | if (!ofs.is_open()) { |
| | | return; // æç¤º |
| | | } |
| | | // è¡¨ç»æåå
¥ |
| | | string showCreate = "show create table " + tableName + ";"; |
| | | bool res = query(showCreate); |
| | | if (!res) { |
| | | return; // æç¤º |
| | | } |
| | | if (getRes()) { |
| | | string writeSQL = getValue(1) + ";\n"; |
| | | ofs.write(writeSQL.c_str(), writeSQL.size()); |
| | | // cout << writeSQL << endl; |
| | | } |
| | | // è¡¨æ°æ®åå
¥ |
| | | string sql = "select * from " + tableName + ";"; |
| | | res = query(sql); |
| | | if (!res) { |
| | | return; // æç¤º |
| | | } |
| | | while (getRes()) { |
| | | string writeSQL = "insert into `" + tableName + "` values("; |
| | | for (int i = 0; !getValue(i).empty(); ++i) { |
| | | if (i != 0) { |
| | | writeSQL += ","; |
| | | } |
| | | MYSQL_FIELD* valueType = mysql_fetch_field_direct(m_result, i); |
| | | if (valueType->type == MYSQL_TYPE_DECIMAL |
| | | || valueType->type == MYSQL_TYPE_TINY |
| | | || valueType->type == MYSQL_TYPE_SHORT |
| | | || valueType->type == MYSQL_TYPE_LONG |
| | | || valueType->type == MYSQL_TYPE_FLOAT |
| | | || valueType->type == MYSQL_TYPE_DOUBLE |
| | | || valueType->type == MYSQL_TYPE_TIMESTAMP |
| | | || valueType->type == MYSQL_TYPE_LONGLONG |
| | | || valueType->type == MYSQL_TYPE_INT24) { |
| | | writeSQL += getValue(i); |
| | | } |
| | | else { |
| | | writeSQL += "'" + getValue(i) + "'"; |
| | | } |
| | | } |
| | | writeSQL += ");\n"; |
| | | ofs.write(writeSQL.c_str(), writeSQL.size()); |
| | | } |
| | | ofs.close(); |
| | | } |
| | | bool MysqlConn::transaction() const |
| | | { |
| | | // å°äºå¡æäº¤è®¾ç½®ä¸ºæå¨æäº¤ |
| | | return mysql_autocommit(m_conn, false); |
| | | } |
| | | bool MysqlConn::commit() const |
| | | { |
| | | return mysql_commit(m_conn); |
| | | } |
| | | bool MysqlConn::rollback() const |
| | | { |
| | | return mysql_rollback(m_conn); |
| | | } |
| | | void MysqlConn::refreashAliveTime() |
| | | { |
| | | m_alivetime = steady_clock::now(); |
| | | } |
| | | ll MysqlConn::getAliveTime() |
| | | { |
| | | // æ¯«ç§ <<= 纳ç§:精度éä½ |
| | | milliseconds res = duration_cast<milliseconds>(steady_clock::now() - m_alivetime); |
| | | return res.count(); |
| | | |
| | | // åå§åè¿æ¥ |
| | | MysqlConn::MysqlConn() { |
| | | mysql_ = mysql_init(mysql_); |
| | | // 设置å符é |
| | | if (mysql_) mysql_set_character_set(mysql_, "gbk"); |
| | | } |
| | | |
| | | // è¿æ¥æ°æ®åº |
| | | bool MysqlConn::connect(std::string ip, std::string userName, std::string passwd, std::string db, int port) { |
| | | mysql_ = mysql_real_connect(mysql_, ip.c_str(), userName.c_str(), passwd.c_str(), db.c_str(), port, nullptr, 0); |
| | | if (!mysql_) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | // éæ¾èµæº |
| | | MysqlConn::~MysqlConn() { |
| | | if (mysql_) { |
| | | mysql_close(mysql_); |
| | | mysql_ = nullptr; |
| | | } |
| | | freeRes(); |
| | | } |
| | | |
| | | // æ´æ°æ°æ® |
| | | bool MysqlConn::update(std::string sql) { |
| | | // åæ°åæ¥è¯¢ä¼ååçå®å
¨æ£æ¥ |
| | | MYSQL_STMT* stmt = mysql_stmt_init(mysql_); |
| | | if (!stmt) { |
| | | return false; |
| | | } |
| | | if (mysql_stmt_prepare(stmt, sql.c_str(), sql.length())) { |
| | | mysql_stmt_close(stmt); |
| | | return false; |
| | | } |
| | | int paramCount = mysql_stmt_param_count(stmt); |
| | | if (paramCount > 0) { |
| | | // 妿æåæ°ï¼éè¦è¿è¡åæ°ç»å®çæä½ï¼è¿éæä¸å®ç° |
| | | mysql_stmt_close(stmt); |
| | | return false; |
| | | } |
| | | if (mysql_stmt_execute(stmt)) { |
| | | mysql_stmt_close(stmt); |
| | | return false; |
| | | } |
| | | mysql_stmt_close(stmt); |
| | | return true; |
| | | } |
| | | |
| | | // æ¥è¯¢æ°æ®åº |
| | | bool MysqlConn::query(std::string sql) { |
| | | freeRes(); |
| | | // åæ°åæ¥è¯¢ä¼ååçå®å
¨æ£æ¥ |
| | | MYSQL_STMT* stmt = mysql_stmt_init(mysql_); |
| | | if (!stmt) { |
| | | return false; |
| | | } |
| | | if (mysql_stmt_prepare(stmt, sql.c_str(), sql.length())) { |
| | | mysql_stmt_close(stmt); |
| | | return false; |
| | | } |
| | | int paramCount = mysql_stmt_param_count(stmt); |
| | | if (paramCount > 0) { |
| | | // 妿æåæ°ï¼éè¦è¿è¡åæ°ç»å®çæä½ï¼è¿éæä¸å®ç° |
| | | mysql_stmt_close(stmt); |
| | | return false; |
| | | } |
| | | if (mysql_stmt_execute(stmt)) { |
| | | mysql_stmt_close(stmt); |
| | | return false; |
| | | } |
| | | res_ = mysql_stmt_result_metadata(stmt); |
| | | if (!res_) { |
| | | mysql_stmt_close(stmt); |
| | | return false; |
| | | } |
| | | mysql_stmt_close(stmt); |
| | | return true; |
| | | } |
| | | |
| | | // å¾å°ç»æé |
| | | bool MysqlConn::getResult() { |
| | | if (res_) { |
| | | row_ = mysql_fetch_row(res_); |
| | | if (row_) return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | // è·åç»æéçåæ®µ |
| | | std::string MysqlConn::getField(int index) { |
| | | int cols = mysql_num_fields(res_); |
| | | if (index >= cols || index < 0) return std::string(""); |
| | | |
| | | char* value = row_[index]; |
| | | unsigned long len = mysql_fetch_lengths(res_)[index]; |
| | | return std::string(value, len); |
| | | } |
| | | |
| | | // äºå¡æä½ |
| | | bool MysqlConn::transaction() { |
| | | return mysql_autocommit(mysql_, false); |
| | | } |
| | | |
| | | // æäº¤äºå¡ |
| | | bool MysqlConn::commit() { |
| | | return mysql_commit(mysql_); |
| | | } |
| | | |
| | | // äºå¡åæ» |
| | | bool MysqlConn::rollback() { |
| | | return mysql_rollback(mysql_); |
| | | } |
| | | |
| | | void MysqlConn::refreshActiveTime() { |
| | | activeTime_ = std::chrono::steady_clock::now(); |
| | | } |
| | | |
| | | long long MysqlConn::getActiveTime() { |
| | | // 纳米 |
| | | std::chrono::nanoseconds nased = std::chrono::steady_clock::now() - activeTime_; |
| | | // è½¬æ¢ææ¯«ç±³ |
| | | std::chrono::microseconds millsed = std::chrono::duration_cast<std::chrono::microseconds>(nased); |
| | | return millsed.count(); // å¤å°æ¯«ç§ |
| | | } |
| | | |
| | | // å®å
¨æ ¡éªå®ç°ï¼è¿éç®åä½¿ç¨æ£å表达å¼å¤ææ¯å¦å
å«å±é©å符 |
| | | bool MysqlConn::isSqlSafe(const std::string& sql) { |
| | | std::regex dangerousPattern(".*(['\";\\-+=]).*"); |
| | | return!std::regex_search(sql, dangerousPattern); |
| | | } |
| | | |
| | | void MysqlConn::freeRes() { |
| | | if (res_) { |
| | | mysql_free_result(res_); |
| | | res_ = nullptr; |
| | | } |
| | | } |
| | |
| | | #pragma once |
| | | #include<iostream> |
| | | #include <memory> |
| | | #include <string> |
| | | #include <mysql.h> |
| | | #include <chrono> // æ¶é |
| | | #include <fstream> |
| | | |
| | | #pragma comment(lib, "./lib/libmysql.lib") // å è½½æ°æ®åºåºæä»¶ |
| | | using namespace std; |
| | | using namespace chrono; |
| | | typedef long long ll; |
| | | #include <string> |
| | | #include <WinSock2.h> |
| | | //#include <mysql.h> |
| | | #include "MySQL/include/mysql.h" |
| | | #include <string.h> |
| | | #include <chrono> |
| | | |
| | | #pragma comment(lib,"./MySQL/lib/libmysql.lib") |
| | | |
| | | class MysqlConn |
| | | { |
| | | private: |
| | | // ç»å¯¹æ¶é |
| | | steady_clock::time_point m_alivetime; |
| | | // è¿æ¥ |
| | | MYSQL* m_conn; |
| | | // æ¥è¯¢çç»æé |
| | | MYSQL_RES* m_result; |
| | | // åè®°å½ç»æé |
| | | MYSQL_ROW m_mysqlRow; |
| | | |
| | | // ç»æééæ¾ |
| | | void freeRes(); |
| | | // å¯¼åºæä¸å¼ 表ä¸çæ°æ® |
| | | void backupCurrentTable(const string path, const string tableName); |
| | | public: |
| | | // åå§åæ°æ®åº |
| | | // åå§åè¿æ¥ |
| | | MysqlConn(); |
| | | // æ°æ®åºè¿æ¥éæ¾ |
| | | ~MysqlConn(); |
| | | // è¿æ¥æ°æ®åº, éæä¾ç¨æ· å¯ç æ°æ®åºåç§° ip ç«¯å£ |
| | | bool connect(const string user, const string passwd, \ |
| | | const string dbName, string ip, \ |
| | | const unsigned short port = 3306U); |
| | | // æ´æ°æ°æ®åº:å¢å æ¹æä½ |
| | | bool update(const string sql) const; |
| | | // è¿æ¥æ°æ®åº |
| | | bool connect(std::string ip, std::string userName, std::string passwd, std::string db , int port = 3306); |
| | | // éæ¾èµæº |
| | | ~MysqlConn( ); |
| | | // æ´æ°æ°æ®åº ( insert update delete ) |
| | | bool update(std::string sql); |
| | | // æ¥è¯¢æ°æ®åº |
| | | bool query(const string sql); |
| | | // éåæ¥è¯¢ç»æé |
| | | bool getRes(); |
| | | // è·åç»æéä¸çåæ®µå¼ |
| | | string getValue(const int fieldIndex) const; |
| | | // åæ¢æ°æ®åº |
| | | bool selectDB(const string dbName) const; |
| | | // å»ºåº |
| | | //bool createDB(const string dbName) const; |
| | | // å¤ä»½æä¸ªåº |
| | | void backupCurrentDB(const string path); |
| | | bool query(std::string sql); |
| | | // å¾å°ç»æé |
| | | bool getResult(); |
| | | // è·åç»æéçåæ®µ |
| | | std::string getField(int index); |
| | | // äºå¡æä½ |
| | | bool transaction() const; |
| | | bool transaction(); |
| | | // æäº¤äºå¡ |
| | | bool commit() const; |
| | | bool commit( ); |
| | | // äºå¡åæ» |
| | | bool rollback() const; |
| | | // å·æ°èµ·å§çç©ºé²æ¶é´ç¹ |
| | | void refreashAliveTime(); |
| | | // 计ç®åæ´»æ»æ¶é¿ |
| | | ll getAliveTime(); |
| | | bool rollback(); |
| | | |
| | | void refreshActiveTime( ); // å·æ°æ´»è·æ¶é´ |
| | | long long getActiveTime(); // è·åå½åæ´»è·çæ¶é´é´é |
| | | // å®å
¨æ ¡éªæ¥å£ |
| | | bool isSqlSafe(const std::string& sql); |
| | | |
| | | private: |
| | | |
| | | void freeRes(); |
| | | MYSQL* mysql_ = NULL ; |
| | | MYSQL_RES* res_ = NULL; |
| | | MYSQL_ROW row_ = nullptr; |
| | | std::chrono::steady_clock::time_point activeTime_; |
| | | }; |
| | | |
| | |
| | | //æ¥å¿ |
| | | LOGSEARCH_REQ,//æ¥å¿æ¥è¯¢è¯·æ± |
| | | LOGSEARCH_RES,//æ¥å¿æ¥è¯¢ååº |
| | | |
| | | //å岿¥è¯¢åæ |
| | | HISTORY_DEV_REQ, //å岿¥è¯¢ç¡¬ä»¶è¯·æ± |
| | | HISTORY_DEV_RES, //å岿¥è¯¢ç¡¬ä»¶ååº |
| | | HISTORY_PRODUCE_REQ, //å岿¥è¯¢çäº§è¯·æ± |
| | | HISTORY_PRODUCE_RES, //å岿¥è¯¢ç产ååº |
| | | HISTORY_ENV_REQ, //å岿¥è¯¢ç¯å¢è¯·æ± |
| | | HISTORY_ENV_RES, //å岿¥è¯¢ç¯å¢ååº |
| | | |
| | | }; |
| | | |
| | |
| | | //设å¤ç®¡ç |
| | | struct DevicesInfo |
| | | { |
| | | int deviceID; |
| | | char deviceName[32];//设å¤åç§° |
| | | char deviceStatus[32];//设å¤ç¶æ |
| | | char area[32]; // å°åº |
| | | double longitude;//ç»åº¦ |
| | | double latitude;//纬度 |
| | | char purchasingTime[15];//è´ä¹°æ¶é´ |
| | | char installTime[15];//å®è£
æ¶é´ |
| | | char manufacturer[100];//åå®¶ |
| | | char devicesSerialNumber[32];//设å¤ç¼ç |
| | | char devicesType[32];//设å¤ç±»å |
| | | double longitude;//ç»åº¦ |
| | | double latitude;//纬度 |
| | | char purchasingTime[15];//è´ä¹°æ¶é´ |
| | | char installTime[15];//å®è£
æ¶é´ |
| | | char devicesSerialNumber[32];//设å¤ç¼ç |
| | | }; |
| | | //æ·»å è®¾å¤ |
| | | struct ADReq//æ·»å è¯·æ± |
| | | { |
| | | Head head; |
| | | char deviceName[32]; |
| | | DevicesInfo devInfo[0]; |
| | | ADReq() { |
| | | head.type = AD_REQ; |
| | | head.len = sizeof(ADReq); |
| | |
| | | struct ADRes//æ·»å ååº |
| | | { |
| | | Head head; |
| | | int type; |
| | | int status; |
| | | ADRes() { |
| | | head.type = AD_RES; |
| | | head.len = sizeof(ADRes); |
| | |
| | | |
| | | }; |
| | | //ä¿®æ¹è®¾å¤ |
| | | struct MDRes//ä¿®æ¹è¯·æ± |
| | | struct MDReq//ä¿®æ¹è¯·æ± |
| | | { |
| | | Head head; |
| | | DevicesInfo info; |
| | | MDRes() { |
| | | head.type = MD_RES; |
| | | head.len = sizeof(MDRes); |
| | | } |
| | | }; |
| | | struct MDReq//ä¿®æ¹ååº |
| | | { |
| | | Head head; |
| | | int type; |
| | | |
| | | MDReq() { |
| | | head.type = MD_REQ; |
| | | head.len = sizeof(MDReq); |
| | | } |
| | | }; |
| | | struct MDRes//ä¿®æ¹ååº |
| | | { |
| | | Head head; |
| | | DevicesInfo info; |
| | | int status; |
| | | MDRes() { |
| | | head.type = MD_RES; |
| | | head.len = sizeof(MDRes); |
| | | } |
| | | }; |
| | | //æ¥è¯¢è®¾å¤ |
| | |
| | | struct QDRes//æ¥è¯¢ååº |
| | | { |
| | | Head head; |
| | | int type; |
| | | int status; |
| | | QDRes() { |
| | | head.type = QD_RES; |
| | | head.len = sizeof(QDRes); |
| | |
| | | |
| | | |
| | | //å岿¥è¯¢åæ |
| | | // å岿¥è¯¢è¯·æ±ç»æä½ |
| | | struct HistoryQueryReq { |
| | | |
| | | //å岿¥è¯¢åæ |
| | | |
| | | struct warningInfo { |
| | | int device_id; |
| | | char des[32]; |
| | | char time[32]; |
| | | float data; |
| | | char type[16]; |
| | | char status[16]; |
| | | }; |
| | | // å岿¥è¯¢è®¾å¤ä¿¡æ¯è¯·æ±ç»æä½ |
| | | struct HistoryDevReq { |
| | | Head head; |
| | | //æ ¹æ®æ¶é´èå´æ¥è¯¢ |
| | | char startTime[32]; |
| | | char endTime[32]; |
| | | //å
³é®åæ¥è¯¢ |
| | | char keyWord[32]; |
| | | HistoryQueryReq() { |
| | | HistoryDevReq() { |
| | | // åå§åæ°æ®å¤´ |
| | | head.type = QUERY_MONOUTPUT_REQ; |
| | | head.len = sizeof(HistoryQueryReq); |
| | | head.type = HISTORY_DEV_REQ; |
| | | head.len = sizeof(HISTORY_DEV_REQ); |
| | | // åå§åæ¥è¯¢æ¡ä»¶å段 |
| | | std::memset(startTime, 0, sizeof(startTime)); |
| | | std::memset(endTime, 0, sizeof(endTime)); |
| | | |
| | | } |
| | | }; |
| | | // å岿¥è¯¢ç产计å请æ±ç»æä½ |
| | | struct HistoryProReq { |
| | | Head head; |
| | | //æ ¹æ®æ¶é´èå´æ¥è¯¢ |
| | | char startTime[32]; |
| | | char endTime[32]; |
| | | //å
³é®åæ¥è¯¢ |
| | | char keyWord[32]; |
| | | HistoryProReq() { |
| | | // åå§åæ°æ®å¤´ |
| | | head.type = HISTORY_PRODUCE_REQ; |
| | | head.len = sizeof(HistoryProReq); |
| | | // åå§åæ¥è¯¢æ¡ä»¶å段 |
| | | } |
| | | }; |
| | | // å岿¥è¯¢ç¯å¢ä¿¡æ¯è¯·æ±ç»æä½ |
| | | struct HistoryEnvReq { |
| | | Head head; |
| | | //æ ¹æ®æ¶é´èå´æ¥è¯¢ |
| | | char startTime[32]; |
| | | char endTime[32]; |
| | | //å
³é®åæ¥è¯¢ |
| | | char keyWord[32]; |
| | | HistoryEnvReq() { |
| | | // åå§åæ°æ®å¤´ |
| | | head.type = HISTORY_ENV_REQ; |
| | | head.len = sizeof(HistoryEnvReq); |
| | | // åå§åæ¥è¯¢æ¡ä»¶å段 |
| | | } |
| | | }; |
| | | |
| | | // å岿¥è¯¢ååºç»æä½ |
| | | |
| | | // ç³»ç»è¿è¡ç¶æè¡¨ç¸å
³ä¿¡æ¯ |
| | | struct HistroyInfo { |
| | | WarningRes warn;//è¦æ¥æ¥è¯¢ |
| | | QDRes dev;//è®¾å¤æ¥è¯¢ |
| | | QueryPdplanRes pro;//çäº§è®¡åæ¥è¯¢ |
| | | }; |
| | | struct HistoryQueryRes { |
| | | //æ¥è¯¢è®¾å¤ä¿¡æ¯ååºç»æä½ |
| | | struct HistoryDevRes { |
| | | Head head; |
| | | HistroyInfo sys[0]; |
| | | HistoryQueryRes() { |
| | | DevicesInfo dev[0]; |
| | | HistoryDevRes() { |
| | | // åå§åæ°æ®å¤´ |
| | | head.type = QUERY_MONOUTPUT_RES; |
| | | head.len = sizeof(HistoryQueryRes); |
| | | head.type = HISTORY_DEV_RES; |
| | | head.len = sizeof(HistoryDevRes); |
| | | } |
| | | }; |
| | | //æ¥è¯¢ç产计åååºç»æä½ |
| | | struct HistoryProRes { |
| | | Head head; |
| | | PdplanInfo pro[0]; |
| | | HistoryProRes() { |
| | | // åå§åæ°æ®å¤´ |
| | | head.type = HISTORY_PRODUCE_RES; |
| | | head.len = sizeof(HistoryProRes); |
| | | } |
| | | }; |
| | | //æ¥è¯¢ç¯å¢ä¿¡æ¯ååºç»æä½ |
| | | struct HistoryEnvRes { |
| | | Head head; |
| | | warningInfo env[0]; |
| | | HistoryEnvRes() { |
| | | // åå§åæ°æ®å¤´ |
| | | head.type = HISTORY_ENV_RES; |
| | | head.len = sizeof(HistoryEnvRes); |
| | | } |
| | | }; |
| | | |
File was renamed from kunlun110401.sql |
| | |
| | | |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.data_info çæ°æ®ï¼~0 rows (大约) |
| | | |
| | | -- å¯¼åº è¡¨ mayi_kunlun.devices_management ç»æ |
| | | CREATE TABLE IF NOT EXISTS `devices_management` ( |
| | | `id` int NOT NULL, |
| | | -- å¯¼åº è¡¨ mayi_kunlun.devices_management_info ç»æ |
| | | CREATE TABLE IF NOT EXISTS `devices_management_info` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `devices_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, |
| | | `devices_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, |
| | | `devices_serial_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, |
| | | `devices_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, |
| | | `area` varchar(50) DEFAULT NULL, |
| | | `longitude` double DEFAULT NULL, |
| | | `latitude` double DEFAULT NULL, |
| | | `purchasing_time` datetime DEFAULT NULL, |
| | | `install_time` datetime DEFAULT NULL, |
| | | `purchasing_time` varchar(50) DEFAULT NULL, |
| | | `install_time` varchar(50) DEFAULT NULL, |
| | | `manufacturer` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, |
| | | `mark_name` varchar(50) DEFAULT NULL, |
| | | `mark_time` datetime DEFAULT NULL, |
| | | `mark_time` varchar(50) DEFAULT NULL, |
| | | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |
| | | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |
| | | |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.devices_management çæ°æ®ï¼~0 rows (大约) |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.devices_management_info çæ°æ®ï¼~3 rows (大约) |
| | | INSERT INTO `devices_management_info` (`id`, `devices_name`, `devices_type`, `devices_serial_number`, `devices_status`, `area`, `longitude`, `latitude`, `purchasing_time`, `install_time`, `manufacturer`, `mark_name`, `mark_time`) VALUES |
| | | (2, '12', '3', '2', '2', '3', 4, 6, '6', '3', '3', NULL, NULL), |
| | | (3, '3', '1', '3', '3', '1', 2, 5, '6', '3', '6', NULL, NULL), |
| | | (4, '10', '1', '3', '3', '1', 2, 5, '9', '3', '6', NULL, NULL); |
| | | |
| | | -- å¯¼åº è¡¨ mayi_kunlun.month_info ç»æ |
| | | CREATE TABLE IF NOT EXISTS `month_info` ( |
| | |
| | | |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.role_info çæ°æ®ï¼~0 rows (大约) |
| | | |
| | | -- å¯¼åº è¡¨ mayi_kunlun.student ç»æ |
| | | CREATE TABLE IF NOT EXISTS `student` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `name` varchar(50) DEFAULT NULL, |
| | | `age` int DEFAULT NULL, |
| | | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |
| | | |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.student çæ°æ®ï¼~0 rows (大约) |
| | | |
| | | -- å¯¼åº è¡¨ mayi_kunlun.threshold_info ç»æ |
| | | CREATE TABLE IF NOT EXISTS `threshold_info` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | |
| | | -- å¯¼åº è¡¨ mayi_kunlun.user_info ç»æ |
| | | CREATE TABLE IF NOT EXISTS `user_info` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `department` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, |
| | | `user_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, |
| | | `department` varchar(50) DEFAULT NULL, |
| | | `user_name` varchar(32) DEFAULT NULL, |
| | | `password` varchar(32) DEFAULT NULL, |
| | | `user_no` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, |
| | | `user_no` varchar(10) DEFAULT NULL, |
| | | `age` int DEFAULT NULL, |
| | | `sex` varchar(10) DEFAULT NULL, |
| | | `role_id` int DEFAULT NULL, |
| | | `email` varchar(32) DEFAULT NULL, |
| | | `telephone` varchar(32) DEFAULT NULL, |
| | | `status` int DEFAULT NULL, |
| | | `role_id` int DEFAULT NULL, |
| | | `login_time` datetime DEFAULT NULL, |
| | | `register_time` datetime DEFAULT NULL, |
| | | PRIMARY KEY (`id`) |
| | | PRIMARY KEY (`id`), |
| | | KEY `role_id` (`role_id`), |
| | | CONSTRAINT `user_info_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `role_info` (`id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |
| | | |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.user_info çæ°æ®ï¼~0 rows (大约) |
| | |
| | | `c_filepath` varchar(256) NOT NULL, |
| | | `uploader` char(64) NOT NULL DEFAULT '', |
| | | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |
| | | |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.version_file çæ°æ®ï¼~3 rows (大约) |
| | | INSERT INTO `version_file` (`id`, `version_id`, `filename`, `fliesize`, `s_filepath`, `c_filepath`, `uploader`) VALUES |
| | | (1, '1.3', '1.jpd', 12555, './versoin', './2', ''), |
| | | (2, '1.4', '2.jpd', 1255, './', './2', ''), |
| | | (3, '1.5', '3.jpd', 122, './', './2', ''); |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.version_file çæ°æ®ï¼~0 rows (大约) |
| | | |
| | | -- å¯¼åº è¡¨ mayi_kunlun.version_info ç»æ |
| | | CREATE TABLE IF NOT EXISTS `version_info` ( |
| | |
| | | `version_description` char(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '', |
| | | `version_creatime` datetime NOT NULL, |
| | | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |
| | | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |
| | | |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.version_info çæ°æ®ï¼~3 rows (大约) |
| | | -- æ£å¨å¯¼åºè¡¨ mayi_kunlun.version_info çæ°æ®ï¼~2 rows (大约) |
| | | INSERT INTO `version_info` (`id`, `version_id`, `version_id_old`, `version_description`, `version_creatime`) VALUES |
| | | (1, '1.3', '1.3', '225', '2024-10-29 15:47:00'), |
| | | (2, '1.4', '1.4', '226', '2024-10-30 02:47:30'), |