Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
fmp_vip
Commits
4c36b6fb
Commit
4c36b6fb
authored
Nov 03, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 实现新签名算法。
parent
d967b2ef
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
0 deletions
+92
-0
fmvip/task/fmtask.cpp
+37
-0
fmvip/task/fmtask.h
+6
-0
tests/testplugin/tst_testplugin.cpp
+49
-0
No files found.
fmvip/task/fmtask.cpp
View file @
4c36b6fb
...
@@ -227,6 +227,43 @@ QString FMTask::sign() const
...
@@ -227,6 +227,43 @@ QString FMTask::sign() const
return
md5Bt
.
toHex
();
return
md5Bt
.
toHex
();
}
}
QString
FMTask
::
JsonObjToMap
(
const
QJsonObject
&
jsonObj
,
QString
parrent
)
{
parrent
=
parrent
.
isEmpty
()
?
""
:
parrent
+
"."
;
QString
mapStr
;
foreach
(
const
QString
&
key
,
jsonObj
.
keys
())
{
switch
(
jsonObj
[
key
].
type
())
{
case
QJsonValue
:
:
Array
:
break
;
case
QJsonValue
:
:
Null
:
mapStr
.
append
(
QString
(
"Key: %1 Value:%2
\n
"
).
arg
(
parrent
+
key
).
arg
(
""
));
break
;
case
QJsonValue
:
:
Bool
:
mapStr
.
append
(
QString
(
"Key: %1 Value: %2
\n
"
).
arg
(
parrent
+
key
).
arg
(
QString
::
number
(
jsonObj
[
key
].
toBool
())));
break
;
case
QJsonValue
:
:
Double
:
mapStr
.
append
(
QString
(
"Key: %1 Value: %2
\n
"
).
arg
(
parrent
+
key
).
arg
(
QString
::
number
(
jsonObj
[
key
].
toDouble
())));
break
;
case
QJsonValue
:
:
String
:
mapStr
.
append
(
QString
(
"Key: %1 Value: %2
\n
"
).
arg
(
parrent
+
key
).
arg
(
jsonObj
[
key
].
toString
()));
break
;
case
QJsonValue
:
:
Object
:
mapStr
.
append
(
JsonObjToMap
(
jsonObj
[
key
].
toObject
(),
parrent
+
key
));
break
;
default
:
break
;
}
}
return
mapStr
;
}
QString
FMTask
::
Sign
(
const
QJsonObject
&
signJsonObj
)
{
QString
md5str
;
return
md5str
;
}
bool
FMTask
::
checkReqJson
()
bool
FMTask
::
checkReqJson
()
{
{
bool
isOk
=
false
;
bool
isOk
=
false
;
...
...
fmvip/task/fmtask.h
View file @
4c36b6fb
...
@@ -38,6 +38,10 @@ public:
...
@@ -38,6 +38,10 @@ public:
bool
checkReqJson
();
bool
checkReqJson
();
#ifdef FMTEST
friend
class
TestPlugin
;
#endif
protected
:
protected
:
// 从配置文件中拷贝数据信息
// 从配置文件中拷贝数据信息
void
copyPros
();
void
copyPros
();
...
@@ -66,6 +70,8 @@ protected:
...
@@ -66,6 +70,8 @@ protected:
private
:
private
:
QString
sign
()
const
;
QString
sign
()
const
;
static
QString
JsonObjToMap
(
const
QJsonObject
&
jsonObj
,
QString
parrent
=
""
);
static
QString
Sign
(
const
QJsonObject
&
signJsonObj
);
/**
/**
* @brief FMError
* @brief FMError
...
...
tests/testplugin/tst_testplugin.cpp
View file @
4c36b6fb
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <QMessageBox>
#include <QMessageBox>
#include "fmvipdispatcher.h"
#include "fmvipdispatcher.h"
#include "fmtask.h"
class
TestPlugin
:
public
QObject
class
TestPlugin
:
public
QObject
{
{
...
@@ -21,6 +22,12 @@ private slots:
...
@@ -21,6 +22,12 @@ private slots:
void
test_dotask_data
();
void
test_dotask_data
();
void
test_dotask
();
void
test_dotask
();
void
test_JsonObjToMap_data
();
void
test_JsonObjToMap
();
void
test_Sign_data
();
void
test_Sign
();
};
};
TestPlugin
::
TestPlugin
()
TestPlugin
::
TestPlugin
()
...
@@ -92,6 +99,48 @@ void TestPlugin::test_dotask()
...
@@ -92,6 +99,48 @@ void TestPlugin::test_dotask()
QMessageBox
::
information
(
nullptr
,
"Return to POS"
,
QString
(
rspData
));
QMessageBox
::
information
(
nullptr
,
"Return to POS"
,
QString
(
rspData
));
}
}
void
TestPlugin
::
test_JsonObjToMap_data
()
{
QTest
::
addColumn
<
QString
>
(
"Json"
);
QTest
::
addColumn
<
QString
>
(
"Map"
);
QString
json
=
"{
\"
null
\"
:null,
\"
bool
\"
:0,
\"
int
\"
:100,
\"
double
\"
:66.6,
\"
string
\"
:
\"
string
\"
,
\"
array
\"
:[{
\"
a1
\"
:
\"
a1
\"
},{
\"
a2
\"
:
\"
a2
\"
}],
\"
object
\"
:{
\"
o1s
\"
:
\"
o1s
\"
,
\"
o2
\"
:[{
\"
o2a
\"
:
\"
o2a
\"
}],
\"
o3
\"
:{
\"
o3o
\"
:
\"
o3o
\"
}}}"
;
QString
map
=
"Key: bool Value: 0
\n
Key: double Value: 66.6
\n
Key: int Value: 100
\n
Key: null Value:
\n
Key: object.o1s Vlaue: o1s
\n
Key: object.o3.o3o Value: o3o
\n
Key: string Value: string"
;
QTest
::
newRow
(
"Simple"
)
<<
json
<<
map
;
}
void
TestPlugin
::
test_JsonObjToMap
()
{
QFETCH
(
QString
,
Json
);
QFETCH
(
QString
,
Map
);
QJsonObject
obj
=
QJsonDocument
::
fromJson
(
Json
.
toUtf8
()).
object
();
QCOMPARE
(
FMTask
::
JsonObjToMap
(
obj
),
Map
);
}
void
TestPlugin
::
test_Sign_data
()
{
QTest
::
addColumn
<
QString
>
(
"SignJson"
);
QTest
::
addColumn
<
QString
>
(
"SignStr"
);
QString
jsonStr1
=
"{
\"
amount
\"
: 100
\"
data
\"
: {
\"
account
\"
:
\"
123123123
\"\"
products:
\"
[{
\"
pid
\"
:
\"
1001
\"
,
\"
name
\"
:
\"
p1
\"
}]}}"
;
QString
signStr
=
"1ec71402a014d24b9c0934a68e4e42c9"
;
QTest
::
newRow
(
"First"
)
<<
jsonStr1
<<
signStr
;
}
void
TestPlugin
::
test_Sign
()
{
QFETCH
(
QString
,
SignJson
);
QFETCH
(
QString
,
SignStr
);
QJsonObject
jsonObj1
=
QJsonDocument
::
fromJson
(
SignJson
.
toUtf8
()).
object
();
QCOMPARE
(
FMTask
::
Sign
(
jsonObj1
),
SignStr
);
}
QTEST_MAIN
(
TestPlugin
)
QTEST_MAIN
(
TestPlugin
)
#include "tst_testplugin.moc"
#include "tst_testplugin.moc"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment