Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
java-devop-sentry
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhouzihao
java-devop-sentry
Commits
c476b21c
Commit
c476b21c
authored
Mar 13, 2020
by
zhouzihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev-添加获取车辆信息的接口
parent
a44aa406
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
1 deletion
+48
-1
src/main/java/com/vandyo/sentry/core/Tmp.java
src/main/java/com/vandyo/sentry/core/Tmp.java
+2
-0
src/main/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
...n/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
+45
-1
src/main/java/com/vandyo/sentry/core/cases/CarListDecorator.java
...n/java/com/vandyo/sentry/core/cases/CarListDecorator.java
+1
-0
No files found.
src/main/java/com/vandyo/sentry/core/Tmp.java
View file @
c476b21c
package
com
.
vandyo
.
sentry
.
core
;
import
com.vandyo.sentry.core.cases.CarInfoDecorator
;
import
com.vandyo.sentry.core.cases.CarListDecorator
;
import
com.vandyo.sentry.core.cases.Case
;
import
com.vandyo.sentry.core.cases.LoginCase
;
...
...
@@ -29,6 +30,7 @@ public class Tmp {
Case
case1
=
null
;
case1
=
new
LoginCase
(
mobile
,
pwd
);
case1
=
new
CarListDecorator
(
case1
);
case1
=
new
CarInfoDecorator
(
case1
);
case1
.
check
();
}
...
...
src/main/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
View file @
c476b21c
package
com
.
vandyo
.
sentry
.
core
.
cases
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* 获取车信息接口
*/
public
class
CarInfoDecorator
extends
CaseDecorator
{
private
final
static
String
carInfoUrl
=
"/car/my_car/info"
;
public
CarInfoDecorator
(
Case
aCase
)
{
super
(
aCase
);
}
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
return
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
newRes
.
setSId
(
oldRes
.
getSId
());
newRes
.
setUId
(
oldRes
.
getUId
());
if
(
Objects
.
isNull
(
carMap
)
||
!
carMap
.
containsKey
(
"cid"
)){
newRes
.
setStatus
(
ErrStatus
.
ErrUnexpected
);
newRes
.
setSuccess
(
false
);
}
else
{
String
cid
=
carMap
.
get
(
"cid"
);
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carInfoUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
).
execute
();
if
(
response
.
isOk
()){
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
//todo 检测 返回值可用性
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
else
{
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
}
return
newRes
;
}
else
{
return
oldRes
;
}
}
}
src/main/java/com/vandyo/sentry/core/cases/CarListDecorator.java
View file @
c476b21c
...
...
@@ -47,6 +47,7 @@ public class CarListDecorator extends CaseDecorator {
newRes
.
setSuccess
(
true
);
}
}
else
{
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
return
newRes
;
...
...
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