Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_takeaway
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
guanghui.cui
familyMart_takeaway
Commits
d8118330
Commit
d8118330
authored
Feb 02, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码整理
parent
d22c95c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
32 deletions
+8
-32
src/JsonModule.cpp
+5
-24
src/JsonModule.h
+2
-7
src/main.cpp
+1
-1
No files found.
src/JsonModule.cpp
View file @
d8118330
...
...
@@ -66,9 +66,8 @@ JsonModule::~JsonModule()
}
void
JsonModule
::
convertToOrderObj
(
IN
const
char
*
json
,
OUT
std
::
vector
<
orderObj
>
&
vecOrders
)
{
void
JsonModule
::
getPushOrders
(
IN
const
char
*
json
,
OUT
std
::
vector
<
orderObj
>
&
vecOrders
)
{
rapidjson
::
Document
document
;
// 定义一个Document对象
document
.
Parse
(
json
);
// 解析,Parse()无返回值,也不会抛异常
if
(
document
.
HasParseError
())
// 通过HasParseError()来判断解析是否成功
...
...
@@ -86,6 +85,8 @@ void JsonModule::convertToOrderObj(IN const char* json,OUT std::vector<orderObj>
rapidjson
::
Value
&
result_obj
=
document
[
"result"
];
std
::
string
strCode
=
vCode
.
GetString
();
if
(
strCode
.
compare
(
"100"
)
!=
0
)
return
;
std
::
string
strMsg
=
vMsg
.
GetString
();
if
(
result_obj
.
IsObject
()){
rapidjson
::
Value
&
orders_array
=
result_obj
[
"orders"
];
...
...
@@ -175,7 +176,7 @@ void JsonModule::convertToOrderObj(IN const char* json,OUT std::vector<orderObj>
}
}
std
::
string
JsonModule
::
convertToOrderJson
(
orderObj
&
obj
)
std
::
string
JsonModule
::
convertTo
New
OrderJson
(
orderObj
&
obj
)
{
rapidjson
::
StringBuffer
buffer
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
...
...
@@ -457,12 +458,6 @@ std::string JsonModule::convertToOrderJson(orderObj &obj)
return
buffer
.
GetString
();
}
orderStatusObj
JsonModule
::
convertToOrderStatusObj
(
const
char
*
json
)
{
orderStatusObj
obj
;
return
obj
;
}
std
::
string
JsonModule
::
convertToOrderStatusJson
(
orderStatusObj
&
obj
)
{
rapidjson
::
StringBuffer
buffer
;
...
...
@@ -486,14 +481,6 @@ std::string JsonModule::convertToOrderStatusJson(orderStatusObj &obj)
return
buffer
.
GetString
();
}
refundObj
JsonModule
::
convertToRefundObj
(
const
char
*
json
)
{
LOG
(
INFO
)
<<
"refundObj start"
;
refundObj
obj
;
LOG
(
INFO
)
<<
"refundObj define"
;
return
obj
;
}
std
::
string
JsonModule
::
convertToRefundJson
(
refundObj
&
obj
)
{
rapidjson
::
StringBuffer
buffer
;
...
...
@@ -584,12 +571,6 @@ std::string JsonModule::convertToRefundJson(refundObj &obj)
return
buffer
.
GetString
();
}
stockWarnObj
JsonModule
::
convertToStockWarnObj
(
const
char
*
json
)
{
stockWarnObj
obj
;
return
obj
;
}
std
::
string
JsonModule
::
convertToStockWarnJson
(
stockWarnObj
&
obj
)
{
rapidjson
::
StringBuffer
buffer
;
...
...
src/JsonModule.h
View file @
d8118330
...
...
@@ -12,16 +12,11 @@ public:
JsonModule
();
~
JsonModule
();
void
convertToOrderObj
(
IN
const
char
*
json
,
OUT
std
::
vector
<
orderObj
>
&
vecOrders
);
std
::
string
convertToOrderJson
(
orderObj
&
obj
);
void
getPushOrders
(
IN
const
char
*
json
,
OUT
std
::
vector
<
orderObj
>
&
vecOrders
);
orderStatusObj
convertToOrderStatusObj
(
const
char
*
json
);
std
::
string
convertToNewOrderJson
(
orderObj
&
obj
);
std
::
string
convertToOrderStatusJson
(
orderStatusObj
&
obj
);
refundObj
convertToRefundObj
(
const
char
*
json
);
std
::
string
convertToRefundJson
(
refundObj
&
obj
);
stockWarnObj
convertToStockWarnObj
(
const
char
*
json
);
std
::
string
convertToStockWarnJson
(
stockWarnObj
&
obj
);
private
:
...
...
src/main.cpp
View file @
d8118330
...
...
@@ -61,7 +61,7 @@ int main()
product
.
vecSpec
.
push_back
(
spec
);
obj
.
vecProducts
.
push_back
(
product
);
std
::
string
orderInfo
=
jsonMod
.
convertToOrderJson
(
obj
);
std
::
string
orderInfo
=
jsonMod
.
convertTo
New
OrderJson
(
obj
);
LOG
(
INFO
)
<<
"订单信息转换成JSON:"
<<
orderInfo
.
data
();
//------------end---------------
...
...
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