Browse Source

2个api测试完成

pull/4/head
zhangsan 4 years ago
parent
commit
8d970ecff4
  1. 2
      QCPShow.pro
  2. 26
      QCPShow.pro.user
  3. 47
      api.http
  4. 4
      deviceservice.cpp
  5. 14
      httpservice.cpp
  6. 1
      httpservice.h
  7. 2
      main.cpp
  8. 2
      mainconfig.cpp
  9. 14
      mainwidget.cpp
  10. 4
      mainwidget.h
  11. 9
      resttest

2
QCPShow.pro

@ -68,4 +68,4 @@ RESOURCES += \
DISTFILES += \
.gitignore \
ReadMe.md \
resttest
api.http

26
QCPShow.pro.user

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.2.1, 2021-10-21T10:14:57. -->
<!-- Written by QtCreator 4.2.1, 2021-10-21T17:16:06. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{0d351c1e-abb6-427c-8d0b-30ca23826ed5}</value>
<value type="QByteArray">{fe03815e-74e2-457e-b60c-e66368cd4ce4}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -66,7 +66,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -90,7 +90,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -106,7 +106,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -144,7 +144,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -160,7 +160,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -198,7 +198,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -214,7 +214,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -231,7 +231,7 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
@ -285,14 +285,14 @@
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">QCPShow</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">QCPShow2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Qt/QtSpace/qt_qcp_show/QCPShow.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:E:/Qt/QtSpace/QCPShow/QCPShow.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">QCPShow.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>

47
api.http

@ -0,0 +1,47 @@
GET https://example.com/comments/1 HTTP/1.1
###
GET https://example.com/topics/1 HTTP/1.1
###
# @name signin
POST http://test.tall.wiki/gateway/tall3/v3.0/users/signin HTTP/1.1
content-type: application/json
{
"client": 1,
"data": {
"credential": "123456",
"identifier": "shoufeichu"
},
"scene": 0,
"type": 3
}
###
POST https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern HTTP/1.1
content-type: application/json
Authorization: Bearer {{signin.response.body.$.data.token}}
{
"param":{
"idcard":"142733198703123919",
"name":"彭于晏",
"sex":"1",
"nation":"汉族"
}
}
###
POST https://test.tall.wiki/gateway/qcp/v3.0/button/buttonStart HTTP/1.1
content-type: application/json
Authorization: Bearer {{signin.response.body.$.data.token}}
{
"param":{
"idcard":"142733198703123919"
}
}

4
deviceservice.cpp

@ -70,8 +70,8 @@ quint8 DeviceService::keyReadOnce()
#ifdef Q_OS_LINUX
return digitalRead(WIRING_PIN_KEY);
#else
qDebug() << "keyReadOnce()";
return 0;
//qDebug() << "keyReadOnce()";
return KEY_Up;
#endif
}

14
httpservice.cpp

@ -103,6 +103,7 @@ QByteArray HttpService::postJson(QUrl url,const QByteArray &json, quint32 timeou
result = reply->readAll();
}
}
qDebug() << result;
return result;
}
@ -114,7 +115,6 @@ void HttpService::login(QString username, QString password)
//发送请求
QByteArray result = postJson(MainConfig::loginUrl,json.toUtf8());
qDebug() << result;
//解析响应
QJsonParseError jerror;
@ -144,7 +144,6 @@ void HttpService::updateStatus(QString firstAidId, QString status)
//发送请求
QByteArray result = postJson(MainConfig::serviceStatusChangedUrl,json.toUtf8());
qDebug() << result;
//解析响应
QJsonParseError jerror;
@ -173,7 +172,6 @@ void HttpService::sendIdcardInfo(QString idcard,QString name, QString sex, QStri
//发送请求
QByteArray result = postJson(MainConfig::sendUserInfoUrl,json.toUtf8());
qDebug() << result;
//解析响应
QJsonParseError jerror;
@ -201,8 +199,7 @@ void HttpService::oneKeyStart(QString idcard)
QString json = rawJson.arg(idcard);
//发送请求
QByteArray result = postJson(MainConfig::sendUserInfoUrl,json.toUtf8());
qDebug() << result;
QByteArray result = postJson(MainConfig::oneKeyStartUrl,json.toUtf8());
//解析响应
QJsonParseError jerror;
@ -222,3 +219,10 @@ void HttpService::oneKeyStart(QString idcard)
qDebug() << "oneKeyStart失败:" << resCode;
}
}
void HttpService::onComplexOneKeyStart(QString idcard, QString name, QString sex, QString nation)
{
qDebug() << "onComplexOneKeyStart" << idcard << name << sex << nation;
sendIdcardInfo(idcard,name,sex,nation);
oneKeyStart(idcard);
}

1
httpservice.h

@ -21,6 +21,7 @@ public slots:
void updateStatus(QString firstAidId,QString status);
void sendIdcardInfo(QString idcard,QString name,QString sex,QString nation);
void oneKeyStart(QString idcard);
void onComplexOneKeyStart(QString idcard,QString name,QString sex,QString nation);
};
#endif // HTTPSERVICE_H

2
main.cpp

@ -38,7 +38,7 @@ int main(int argc, char *argv[])
&w,&MainWidget::onKeyClicked);
QObject::connect(&w,&MainWidget::statusChanged,&httpService,&HttpService::updateStatus);
QObject::connect(&w,&MainWidget::complexOneKeyStart,&httpService,&HttpService::onComplexOneKeyStart);
w.show();
// w.showFullScreen();

2
mainconfig.cpp

@ -5,7 +5,7 @@
#define D_CONFIG_FILE_PATH "./setting.ini"
QString MainConfig::token = "";
QString MainConfig::username = "shoufeichu";
QString MainConfig::username = "fenzhentai";
QString MainConfig::password = "123456";
QString MainConfig::loginUrl = "http://test.tall.wiki/gateway/tall3/v3.0/users/signin";
QString MainConfig::sendUserInfoUrl = "https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern";

14
mainwidget.cpp

@ -3,6 +3,8 @@
#include <QtCore>
#include "mainconfig.h"
#define FIXEDIDCARD ""
MainWidget::MainWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::MainWidget)
@ -183,7 +185,7 @@ void MainWidget::onPatientMergencyStatusChanged(QString firstAidId,QString time,
void MainWidget::onKeyClicked()
{
// emit onKeyStart();
emit complexOneKeyStart("142733198703123918","彭于晏","1","汉族");
qDebug() << "Key Clicked";
}
@ -212,3 +214,13 @@ void MainWidget::deletePatientFromList(QString firstAidId)
}
}
}
void MainWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
if(event->button()==Qt::LeftButton){
//TODO
}
else if(event->button()==Qt::RightButton){
onKeyClicked();
}
}

4
mainwidget.h

@ -19,6 +19,7 @@ public:
~MainWidget();
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
private:
Ui::MainWidget *ui;
@ -45,6 +46,9 @@ public slots:
signals:
void statusChanged(QString firstAidId,QString status);
void complexOneKeyStart(QString idcard,QString name,QString sex,QString nation);
void sendCardInfo(QString idcard,QString name,QString sex,QString nation);
void oneKeyStart(QString idcard);
};
#endif // MAINWIDGET_H

9
resttest

@ -1,9 +0,0 @@
https://example.com/comments/1
POST https://example.com/comments HTTP/1.1
content-type: application/json
{
"name": "sample",
"time": "Wed, 21 Oct 2015 18:27:50 GMT"
}
Loading…
Cancel
Save