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
3b0b39c9
Commit
3b0b39c9
authored
Mar 23, 2020
by
zhouzihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix-对报错微弱的优化
parent
595f1867
Pipeline
#97
failed with stages
in 25 seconds
Changes
20
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
381 additions
and
219 deletions
+381
-219
src/main/java/com/vandyo/sentry/core/Tmp.java
src/main/java/com/vandyo/sentry/core/Tmp.java
+42
-33
src/main/java/com/vandyo/sentry/core/cases/BannerListDecorator.java
...ava/com/vandyo/sentry/core/cases/BannerListDecorator.java
+24
-14
src/main/java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
...java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
+23
-15
src/main/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
...n/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
+23
-15
src/main/java/com/vandyo/sentry/core/cases/CarListDecorator.java
...n/java/com/vandyo/sentry/core/cases/CarListDecorator.java
+34
-24
src/main/java/com/vandyo/sentry/core/cases/CarLocausPointListDecorator.java
...vandyo/sentry/core/cases/CarLocausPointListDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CarLocusEventDecorator.java
.../com/vandyo/sentry/core/cases/CarLocusEventDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CarLocusPageDecorator.java
...a/com/vandyo/sentry/core/cases/CarLocusPageDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CarLocusStatisticsDecorator.java
...vandyo/sentry/core/cases/CarLocusStatisticsDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
...java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
+23
-15
src/main/java/com/vandyo/sentry/core/cases/Case.java
src/main/java/com/vandyo/sentry/core/cases/Case.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/CaseDecorator.java
...main/java/com/vandyo/sentry/core/cases/CaseDecorator.java
+2
-1
src/main/java/com/vandyo/sentry/core/cases/DayReportDecorator.java
...java/com/vandyo/sentry/core/cases/DayReportDecorator.java
+22
-15
src/main/java/com/vandyo/sentry/core/cases/LoginCase.java
src/main/java/com/vandyo/sentry/core/cases/LoginCase.java
+28
-18
src/main/java/com/vandyo/sentry/core/cases/LogoutDecorator.java
...in/java/com/vandyo/sentry/core/cases/LogoutDecorator.java
+24
-14
src/main/java/com/vandyo/sentry/core/cases/MallGoodsDecorator.java
...java/com/vandyo/sentry/core/cases/MallGoodsDecorator.java
+24
-14
src/main/java/com/vandyo/sentry/core/cases/MsgGetDecorator.java
...in/java/com/vandyo/sentry/core/cases/MsgGetDecorator.java
+28
-17
src/main/java/com/vandyo/sentry/core/cases/UserInfoDecorator.java
.../java/com/vandyo/sentry/core/cases/UserInfoDecorator.java
+27
-17
src/main/java/com/vandyo/sentry/core/exceptions/CaseException.java
...java/com/vandyo/sentry/core/exceptions/CaseException.java
+45
-0
src/main/java/com/vandyo/sentry/core/tools/Signature.java
src/main/java/com/vandyo/sentry/core/tools/Signature.java
+2
-2
No files found.
src/main/java/com/vandyo/sentry/core/Tmp.java
View file @
3b0b39c9
...
@@ -7,6 +7,8 @@ import com.vandyo.sentry.core.collectionMachine.CollectionMachine;
...
@@ -7,6 +7,8 @@ import com.vandyo.sentry.core.collectionMachine.CollectionMachine;
import
com.vandyo.sentry.core.collectionMachine.EmailDealer
;
import
com.vandyo.sentry.core.collectionMachine.EmailDealer
;
import
com.vandyo.sentry.core.config.CheckMetaConfig
;
import
com.vandyo.sentry.core.config.CheckMetaConfig
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -39,43 +41,50 @@ public class Tmp {
...
@@ -39,43 +41,50 @@ public class Tmp {
@Scheduled
(
fixedRate
=
1000
*
30
)
@Scheduled
(
fixedRate
=
1000
*
30
)
public
void
test
()
{
public
void
test
()
{
// log.info("we run it {} times", ++times);
try
{
Case
case1
=
null
;
Case
case1
=
null
;
// 上线前使用这段代码
// 上线前使用这段代码
// 登录
// 登录
case1
=
new
LoginCase
(
mobile
,
pwd
);
case1
=
new
LoginCase
(
mobile
,
pwd
);
// 获取消息接口
// 获取消息接口
case1
=
new
MsgGetDecorator
(
case1
);
case1
=
new
MsgGetDecorator
(
case1
);
// 查询用户信息
// 查询用户信息
case1
=
new
UserInfoDecorator
(
case1
);
case1
=
new
UserInfoDecorator
(
case1
);
case1
=
new
CarListDecorator
(
case1
);
case1
=
new
CarListDecorator
(
case1
);
// 获取车的日志
// 获取车的日志
case1
=
new
DayReportDecorator
(
case1
);
case1
=
new
DayReportDecorator
(
case1
);
// 查询车轨迹接口
// 查询车轨迹接口
case1
=
new
CarLocusPageDecorator
(
case1
);
case1
=
new
CarLocusPageDecorator
(
case1
);
// 查询车轨迹点 接口
// 查询车轨迹点 接口
case1
=
new
CarLocausPointListDecorator
(
case1
);
case1
=
new
CarLocausPointListDecorator
(
case1
);
// 查询车轨迹统计数据
// 查询车轨迹统计数据
case1
=
new
CarLocusStatisticsDecorator
(
case1
);
case1
=
new
CarLocusStatisticsDecorator
(
case1
);
// 轨迹行驶行为接口
// 轨迹行驶行为接口
case1
=
new
CarLocusEventDecorator
(
case1
);
case1
=
new
CarLocusEventDecorator
(
case1
);
case1
=
new
CarInfoDecorator
(
case1
);
case1
=
new
CarInfoDecorator
(
case1
);
case1
=
new
CarDetectDecorator
(
case1
);
case1
=
new
CarDetectDecorator
(
case1
);
case1
=
new
CarStatusDecorator
(
case1
);
case1
=
new
CarStatusDecorator
(
case1
);
// 退出登录
// 退出登录
case1
=
new
LogoutDecorator
(
case1
);
case1
=
new
LogoutDecorator
(
case1
);
case1
.
check
();
case1
.
check
();
// banner接口
// banner接口
Case
case2
=
null
;
Case
case2
=
null
;
case2
=
new
EmptyCase
(
sId
,
uid
);
case2
=
new
EmptyCase
(
sId
,
uid
);
case2
=
new
BannerListDecorator
(
case2
);
case2
=
new
BannerListDecorator
(
case2
);
// 获取商品列表
// 获取商品列表
case2
=
new
MallGoodsDecorator
(
case2
);
case2
=
new
MallGoodsDecorator
(
case2
);
case2
.
check
();
case2
.
check
();
}
catch
(
CaseException
e
){
Res
res
=
new
Res
();
res
.
setKey
(
e
.
getKey
());
res
.
setStatus
(
e
.
getStatus
());
res
.
setSuccess
(
false
);
CollectionMachine
.
post
(
res
);
}
log
.
info
(
"over!"
);
log
.
info
(
"over!"
);
}
}
...
...
src/main/java/com/vandyo/sentry/core/cases/BannerListDecorator.java
View file @
3b0b39c9
...
@@ -4,7 +4,9 @@ import cn.hutool.http.HttpRequest;
...
@@ -4,7 +4,9 @@ import cn.hutool.http.HttpRequest;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -22,7 +24,7 @@ public class BannerListDecorator extends CaseDecorator {
...
@@ -22,7 +24,7 @@ public class BannerListDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
@@ -32,20 +34,28 @@ public class BannerListDecorator extends CaseDecorator {
...
@@ -32,20 +34,28 @@ public class BannerListDecorator extends CaseDecorator {
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"type"
,
"1"
);
paramMap
.
put
(
"type"
,
"1"
);
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
bannerListUrl
)
try
{
.
body
(
JSONUtil
.
parseFromMap
(
paramMap
).
toString
())
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
bannerListUrl
)
.
execute
();
.
body
(
JSONUtil
.
parseFromMap
(
paramMap
).
toString
())
if
(
response
.
isOk
())
{
.
execute
();
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
if
(
response
.
isOk
())
{
//todo 检测 返回值可用性
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
newRes
.
setData
(
carMap
);
//todo 检测 返回值可用性
newRes
.
setSuccess
(
true
);
newRes
.
setData
(
carMap
);
}
else
{
newRes
.
setSuccess
(
true
);
newRes
.
setKey
(
bannerListUrl
);
}
else
{
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setKey
(
bannerListUrl
);
newRes
.
setSuccess
(
false
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
bannerListUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
bannerListUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
return
newRes
;
}
else
{
}
else
{
oldRes
.
setIgnore
(
true
);
oldRes
.
setIgnore
(
true
);
return
oldRes
;
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/CarDetectDecorator.java
View file @
3b0b39c9
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -28,7 +29,7 @@ public class CarDetectDecorator extends CaseDecorator {
...
@@ -28,7 +29,7 @@ public class CarDetectDecorator extends CaseDecorator {
* @return
* @return
*/
*/
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
@@ -44,21 +45,28 @@ public class CarDetectDecorator extends CaseDecorator {
...
@@ -44,21 +45,28 @@ public class CarDetectDecorator extends CaseDecorator {
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carDetectUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
).
execute
();
HttpResponse
response
=
HttpRequest
.
get
(
if
(
response
.
isOk
())
{
Signature
.
host
+
carDetectUrl
+
"?"
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
//todo 检测 返回值可用性
).
execute
();
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
if
(
response
.
isOk
()){
}
else
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
newRes
.
setKey
(
carDetectUrl
);
//todo 检测 返回值可用性
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
false
);
newRes
.
setSuccess
(
true
);
}
}
else
{
}
catch
(
Exception
e
){
newRes
.
setKey
(
carDetectUrl
);
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
throw
new
CaseException
(
carDetectUrl
,
ErrStatus
.
ErrTimeout
);
newRes
.
setSuccess
(
false
);
}
else
{
throw
new
CaseException
(
carDetectUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
}
}
return
newRes
;
return
newRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/CarInfoDecorator.java
View file @
3b0b39c9
...
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
...
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -25,7 +26,7 @@ public class CarInfoDecorator extends CaseDecorator {
...
@@ -25,7 +26,7 @@ public class CarInfoDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
@@ -41,21 +42,28 @@ public class CarInfoDecorator extends CaseDecorator {
...
@@ -41,21 +42,28 @@ public class CarInfoDecorator extends CaseDecorator {
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carInfoUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
).
execute
();
HttpResponse
response
=
HttpRequest
.
get
(
if
(
response
.
isOk
())
{
Signature
.
host
+
carInfoUrl
+
"?"
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
//todo 检测 返回值可用性
).
execute
();
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
if
(
response
.
isOk
()){
}
else
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
newRes
.
setKey
(
carInfoUrl
);
//todo 检测 返回值可用性
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
false
);
newRes
.
setSuccess
(
true
);
}
}
else
{
}
catch
(
Exception
e
){
newRes
.
setKey
(
carInfoUrl
);
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
throw
new
CaseException
(
carInfoUrl
,
ErrStatus
.
ErrTimeout
);
newRes
.
setSuccess
(
false
);
}
else
{
throw
new
CaseException
(
carInfoUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
}
}
CollectionMachine
.
post
(
newRes
);
CollectionMachine
.
post
(
newRes
);
...
...
src/main/java/com/vandyo/sentry/core/cases/CarListDecorator.java
View file @
3b0b39c9
...
@@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil;
...
@@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -23,38 +24,47 @@ public class CarListDecorator extends CaseDecorator {
...
@@ -23,38 +24,47 @@ public class CarListDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"uid"
,
oldRes
.
getUId
());
data
.
put
(
"uid"
,
oldRes
.
getUId
());
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carListUrl
+
"?"
try
{
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
.
execute
();
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carListUrl
+
"?"
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
newRes
.
setSId
(
oldRes
.
getSId
());
.
execute
();
newRes
.
setUId
(
oldRes
.
getUId
());
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
newRes
.
setSId
(
oldRes
.
getSId
());
if
(
response
.
isOk
()){
newRes
.
setUId
(
oldRes
.
getUId
());
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
JSONArray
list
=
json
.
getJSONArray
(
"result"
);
if
(
response
.
isOk
())
{
if
(
Objects
.
isNull
(
list
)
||
list
.
size
()
<
1
){
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
JSONArray
list
=
json
.
getJSONArray
(
"result"
);
if
(
Objects
.
isNull
(
list
)
||
list
.
size
()
<
1
)
{
newRes
.
setSuccess
(
false
);
newRes
.
setStatus
(
ErrStatus
.
ErrUnexpected
);
}
else
{
Map
<
String
,
String
>
carMap
=
new
HashMap
<>();
JSONObject
car
=
(
JSONObject
)
list
.
get
(
0
);
carMap
.
put
(
"cid"
,
car
.
getStr
(
"cid"
));
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
}
else
{
newRes
.
setKey
(
carListUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
newRes
.
setSuccess
(
false
);
newRes
.
setStatus
(
ErrStatus
.
ErrUnexpected
);
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
carListUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
}
else
{
Map
<
String
,
String
>
carMap
=
new
HashMap
<>();
throw
new
CaseException
(
carListUrl
,
ErrStatus
.
ErrUnknown
);
JSONObject
car
=
(
JSONObject
)
list
.
get
(
0
);
carMap
.
put
(
"cid"
,
car
.
getStr
(
"cid"
));
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
}
}
}
else
{
newRes
.
setKey
(
carListUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
else
{
}
else
{
oldRes
.
setIgnore
(
true
);
oldRes
.
setIgnore
(
true
);
return
oldRes
;
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/CarLocausPointListDecorator.java
View file @
3b0b39c9
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -24,7 +25,7 @@ public class CarLocausPointListDecorator extends CaseDecorator{
...
@@ -24,7 +25,7 @@ public class CarLocausPointListDecorator extends CaseDecorator{
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
src/main/java/com/vandyo/sentry/core/cases/CarLocusEventDecorator.java
View file @
3b0b39c9
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -24,7 +25,7 @@ public class CarLocusEventDecorator extends CaseDecorator {
...
@@ -24,7 +25,7 @@ public class CarLocusEventDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
src/main/java/com/vandyo/sentry/core/cases/CarLocusPageDecorator.java
View file @
3b0b39c9
...
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONObject;
...
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -25,7 +26,7 @@ public class CarLocusPageDecorator extends CaseDecorator {
...
@@ -25,7 +26,7 @@ public class CarLocusPageDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
src/main/java/com/vandyo/sentry/core/cases/CarLocusStatisticsDecorator.java
View file @
3b0b39c9
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -24,7 +25,7 @@ public class CarLocusStatisticsDecorator extends CaseDecorator {
...
@@ -24,7 +25,7 @@ public class CarLocusStatisticsDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
...
src/main/java/com/vandyo/sentry/core/cases/CarStatusDecorator.java
View file @
3b0b39c9
...
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
...
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -25,7 +26,7 @@ public class CarStatusDecorator extends CaseDecorator{
...
@@ -25,7 +26,7 @@ public class CarStatusDecorator extends CaseDecorator{
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
@@ -42,21 +43,28 @@ public class CarStatusDecorator extends CaseDecorator{
...
@@ -42,21 +43,28 @@ public class CarStatusDecorator extends CaseDecorator{
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"cid"
,
cid
);
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"uid"
,
oldRes
.
getUId
());
paramMap
.
put
(
"start"
,
String
.
valueOf
(
System
.
currentTimeMillis
()/
1000
));
paramMap
.
put
(
"start"
,
String
.
valueOf
(
System
.
currentTimeMillis
()/
1000
));
try
{
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
carStatusUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
).
execute
();
HttpResponse
response
=
HttpRequest
.
get
(
if
(
response
.
isOk
())
{
Signature
.
host
+
carStatusUrl
+
"?"
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
paramMap
,
oldRes
.
getSId
()))
//todo 检测 返回值可用性
).
execute
();
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
if
(
response
.
isOk
()){
}
else
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
newRes
.
setKey
(
carStatusUrl
);
//todo 检测 返回值可用性
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
false
);
newRes
.
setSuccess
(
true
);
}
}
else
{
}
catch
(
Exception
e
){
newRes
.
setKey
(
carStatusUrl
);
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
throw
new
CaseException
(
carStatusUrl
,
ErrStatus
.
ErrTimeout
);
newRes
.
setSuccess
(
false
);
}
else
{
throw
new
CaseException
(
carStatusUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
}
}
CollectionMachine
.
post
(
newRes
);
CollectionMachine
.
post
(
newRes
);
...
...
src/main/java/com/vandyo/sentry/core/cases/Case.java
View file @
3b0b39c9
package
com
.
vandyo
.
sentry
.
core
.
cases
;
package
com
.
vandyo
.
sentry
.
core
.
cases
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
java.util.Map
;
import
java.util.Map
;
public
abstract
class
Case
{
public
abstract
class
Case
{
public
abstract
Res
<
Map
<
String
,
String
>>
check
();
public
abstract
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
;
}
}
src/main/java/com/vandyo/sentry/core/cases/CaseDecorator.java
View file @
3b0b39c9
package
com
.
vandyo
.
sentry
.
core
.
cases
;
package
com
.
vandyo
.
sentry
.
core
.
cases
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -12,7 +13,7 @@ public abstract class CaseDecorator extends Case {
...
@@ -12,7 +13,7 @@ public abstract class CaseDecorator extends Case {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
// fixme: 依赖上一个请求的数据都要对上一个是否成功进行不同的处理
// fixme: 依赖上一个请求的数据都要对上一个是否成功进行不同的处理
// ?? 如果没有需要的值怎么处理业务逻辑呢??比如车列表内没有车?(这样要保证测试数据都有)
// ?? 如果没有需要的值怎么处理业务逻辑呢??比如车列表内没有车?(这样要保证测试数据都有)
return
this
.
aCase
.
check
();
return
this
.
aCase
.
check
();
...
...
src/main/java/com/vandyo/sentry/core/cases/DayReportDecorator.java
View file @
3b0b39c9
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
...
@@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -24,7 +25,7 @@ public class DayReportDecorator extends CaseDecorator {
...
@@ -24,7 +25,7 @@ public class DayReportDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
Map
<
String
,
String
>
carMap
=
oldRes
.
getData
();
...
@@ -46,20 +47,26 @@ public class DayReportDecorator extends CaseDecorator {
...
@@ -46,20 +47,26 @@ public class DayReportDecorator extends CaseDecorator {
signMap
.
put
(
"Data"
,
JSONUtil
.
parseFromMap
(
paramMap
).
toString
());
signMap
.
put
(
"Data"
,
JSONUtil
.
parseFromMap
(
paramMap
).
toString
());
Map
<
String
,
String
>
signedMap
=
Signature
.
sign
(
signMap
,
oldRes
.
getSId
());
Map
<
String
,
String
>
signedMap
=
Signature
.
sign
(
signMap
,
oldRes
.
getSId
());
signedMap
.
remove
(
"Data"
);
signedMap
.
remove
(
"Data"
);
try
{
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
dayReportUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
signedMap
))
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
dayReportUrl
+
"?"
+
Signature
.
getUrlParamsByMap
(
signedMap
))
.
body
(
JSONUtil
.
parseFromMap
(
paramMap
).
toString
())
.
body
(
JSONUtil
.
parseFromMap
(
paramMap
).
toString
())
.
execute
();
.
execute
();
if
(
response
.
isOk
())
{
if
(
response
.
isOk
()){
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
response
.
body
());
//todo 检测 返回值可用性
//todo 检测 返回值可用性
newRes
.
setData
(
carMap
);
newRes
.
setData
(
carMap
);
newRes
.
setSuccess
(
true
);
newRes
.
setSuccess
(
true
);
}
else
{
}
else
{
newRes
.
setKey
(
dayReportUrl
);
newRes
.
setKey
(
dayReportUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
newRes
.
setSuccess
(
false
);
}
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
dayReportUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
dayReportUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
}
}
return
newRes
;
return
newRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/LoginCase.java
View file @
3b0b39c9
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -24,29 +26,37 @@ public class LoginCase extends Case {
...
@@ -24,29 +26,37 @@ public class LoginCase extends Case {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
Map
<
String
,
String
>
data
=
new
HashMap
<>();
// data.put("mobile", "18623414467");
// data.put("mobile", "18623414467");
data
.
put
(
"mobile"
,
mobile
);
data
.
put
(
"mobile"
,
mobile
);
// data.put("password", "5f83f54fb34e2eed0439d37d80f5b1a3");
// data.put("password", "5f83f54fb34e2eed0439d37d80f5b1a3");
data
.
put
(
"password"
,
pwd
);
data
.
put
(
"password"
,
pwd
);
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
loginUrl
)
try
{
.
body
(
JSONUtil
.
parseFromMap
(
data
).
toString
()).
execute
();
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
loginUrl
)
Res
<
Map
<
String
,
String
>>
res
=
new
Res
<>();
.
body
(
JSONUtil
.
parseFromMap
(
data
).
toString
()).
execute
();
if
(
response
.
isOk
())
{
Res
<
Map
<
String
,
String
>>
res
=
new
Res
<>();
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
if
(
response
.
isOk
())
{
JSONObject
resultJson
=
json
.
getJSONObject
(
"result"
);
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
String
sid
=
resultJson
.
getStr
(
"sid"
);
JSONObject
resultJson
=
json
.
getJSONObject
(
"result"
);
String
uid
=
resultJson
.
getStr
(
"uid"
);
String
sid
=
resultJson
.
getStr
(
"sid"
);
res
.
setUId
(
uid
);
String
uid
=
resultJson
.
getStr
(
"uid"
);
res
.
setSId
(
sid
);
res
.
setUId
(
uid
);
res
.
setSuccess
(
true
);
res
.
setSId
(
sid
);
}
else
{
res
.
setSuccess
(
true
);
res
.
setKey
(
loginUrl
);
}
else
{
res
.
setSuccess
(
false
);
res
.
setKey
(
loginUrl
);
res
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
res
.
setSuccess
(
false
);
res
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
}
CollectionMachine
.
post
(
res
);
return
res
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
loginUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
loginUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
CollectionMachine
.
post
(
res
);
return
res
;
}
}
}
}
src/main/java/com/vandyo/sentry/core/cases/LogoutDecorator.java
View file @
3b0b39c9
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -23,25 +25,33 @@ public class LogoutDecorator extends CaseDecorator {
...
@@ -23,25 +25,33 @@ public class LogoutDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"uid"
,
oldRes
.
getUId
());
data
.
put
(
"uid"
,
oldRes
.
getUId
());
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
logoutUrl
+
"?"
try
{
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
logoutUrl
+
"?"
.
execute
();
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
.
execute
();
if
(
response
.
isOk
())
{
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
if
(
response
.
isOk
())
{
newRes
.
setSuccess
(
true
);
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
}
else
{
newRes
.
setSuccess
(
true
);
newRes
.
setKey
(
logoutUrl
);
}
else
{
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setKey
(
logoutUrl
);
newRes
.
setSuccess
(
false
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
logoutUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
logoutUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
else
{
}
else
{
oldRes
.
setIgnore
(
true
);
oldRes
.
setIgnore
(
true
);
return
oldRes
;
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/MallGoodsDecorator.java
View file @
3b0b39c9
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -23,22 +25,30 @@ public class MallGoodsDecorator extends CaseDecorator {
...
@@ -23,22 +25,30 @@ public class MallGoodsDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
super
.
check
();
super
.
check
();
Map
<
String
,
String
>
data
=
new
HashMap
<>();
Map
<
String
,
String
>
data
=
new
HashMap
<>();
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
mallGoodsUrl
)
try
{
.
body
(
"{}"
)
HttpResponse
response
=
HttpRequest
.
post
(
Signature
.
host
+
mallGoodsUrl
)
.
execute
();
.
body
(
"{}"
)
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
.
execute
();
if
(
response
.
isOk
())
{
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
if
(
response
.
isOk
())
{
newRes
.
setSuccess
(
true
);
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
}
else
{
newRes
.
setSuccess
(
true
);
newRes
.
setKey
(
mallGoodsUrl
);
}
else
{
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setKey
(
mallGoodsUrl
);
newRes
.
setSuccess
(
false
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
mallGoodsUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
mallGoodsUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
}
}
}
src/main/java/com/vandyo/sentry/core/cases/MsgGetDecorator.java
View file @
3b0b39c9
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -23,29 +25,38 @@ public class MsgGetDecorator extends CaseDecorator {
...
@@ -23,29 +25,38 @@ public class MsgGetDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"uid"
,
oldRes
.
getUId
());
data
.
put
(
"uid"
,
oldRes
.
getUId
());
data
.
put
(
"size"
,
String
.
valueOf
(
1
));
data
.
put
(
"size"
,
String
.
valueOf
(
1
));
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
msgHost
+
msgGetUrl
+
"?"
try
{
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
.
execute
();
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
msgHost
+
msgGetUrl
+
"?"
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
newRes
.
setSId
(
oldRes
.
getSId
());
.
execute
();
newRes
.
setUId
(
oldRes
.
getUId
());
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
newRes
.
setSId
(
oldRes
.
getSId
());
if
(
response
.
isOk
())
{
newRes
.
setUId
(
oldRes
.
getUId
());
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
newRes
.
setSuccess
(
true
);
if
(
response
.
isOk
())
{
}
else
{
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
newRes
.
setKey
(
msgGetUrl
);
newRes
.
setSuccess
(
true
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
}
else
{
newRes
.
setSuccess
(
false
);
newRes
.
setKey
(
msgGetUrl
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
){
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
)){
throw
new
CaseException
(
msgGetUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
msgGetUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
else
{
}
else
{
oldRes
.
setIgnore
(
true
);
oldRes
.
setIgnore
(
true
);
return
oldRes
;
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/cases/UserInfoDecorator.java
View file @
3b0b39c9
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
...
@@ -5,7 +5,9 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.collectionMachine.CollectionMachine
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.dto.Res
;
import
com.vandyo.sentry.core.exceptions.CaseException
;
import
com.vandyo.sentry.core.tools.Signature
;
import
com.vandyo.sentry.core.tools.Signature
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -24,28 +26,36 @@ public class UserInfoDecorator extends CaseDecorator {
...
@@ -24,28 +26,36 @@ public class UserInfoDecorator extends CaseDecorator {
}
}
@Override
@Override
public
Res
<
Map
<
String
,
String
>>
check
()
{
public
Res
<
Map
<
String
,
String
>>
check
()
throws
CaseException
{
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
Res
<
Map
<
String
,
String
>>
oldRes
=
super
.
check
();
if
(
oldRes
.
getSuccess
())
{
if
(
oldRes
.
getSuccess
())
{
Map
<
String
,
String
>
data
=
new
HashMap
<>();
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"uid"
,
oldRes
.
getUId
());
data
.
put
(
"uid"
,
oldRes
.
getUId
());
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
UserInfoUrl
+
"?"
try
{
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
HttpResponse
response
=
HttpRequest
.
get
(
Signature
.
host
+
UserInfoUrl
+
"?"
.
execute
();
+
Signature
.
getUrlParamsByMap
(
Signature
.
sign
(
data
,
oldRes
.
getSId
())))
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
.
execute
();
newRes
.
setSId
(
oldRes
.
getSId
());
Res
<
Map
<
String
,
String
>>
newRes
=
new
Res
<>();
newRes
.
setUId
(
oldRes
.
getUId
());
newRes
.
setSId
(
oldRes
.
getSId
());
newRes
.
setUId
(
oldRes
.
getUId
());
if
(
response
.
isOk
())
{
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
if
(
response
.
isOk
())
{
newRes
.
setSuccess
(
true
);
JSONObject
json
=
JSONUtil
.
parseObj
(
response
.
body
());
}
else
{
newRes
.
setSuccess
(
true
);
newRes
.
setKey
(
UserInfoUrl
);
}
else
{
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setKey
(
UserInfoUrl
);
newRes
.
setSuccess
(
false
);
newRes
.
setStatus
(
Signature
.
matchStatus
(
response
.
getStatus
()));
newRes
.
setSuccess
(
false
);
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
catch
(
Exception
e
)
{
if
(
e
.
getMessage
().
toLowerCase
().
contains
(
"timeout"
))
{
throw
new
CaseException
(
UserInfoUrl
,
ErrStatus
.
ErrTimeout
);
}
else
{
throw
new
CaseException
(
UserInfoUrl
,
ErrStatus
.
ErrUnknown
);
}
}
}
CollectionMachine
.
post
(
newRes
);
return
newRes
;
}
else
{
}
else
{
oldRes
.
setIgnore
(
true
);
oldRes
.
setIgnore
(
true
);
return
oldRes
;
return
oldRes
;
...
...
src/main/java/com/vandyo/sentry/core/exceptions/CaseException.java
0 → 100644
View file @
3b0b39c9
package
com
.
vandyo
.
sentry
.
core
.
exceptions
;
import
com.vandyo.sentry.core.dto.ErrStatus
;
public
class
CaseException
extends
Exception
{
private
String
key
;
private
ErrStatus
status
;
public
CaseException
(
String
key
,
ErrStatus
status
)
{
this
.
key
=
key
;
this
.
status
=
status
;
}
public
CaseException
(
String
message
,
String
key
,
ErrStatus
status
)
{
super
(
message
);
this
.
key
=
key
;
this
.
status
=
status
;
}
public
CaseException
(
String
message
,
Throwable
cause
,
String
key
,
ErrStatus
status
)
{
super
(
message
,
cause
);
this
.
key
=
key
;
this
.
status
=
status
;
}
public
CaseException
(
Throwable
cause
,
String
key
,
ErrStatus
status
)
{
super
(
cause
);
this
.
key
=
key
;
this
.
status
=
status
;
}
public
CaseException
(
String
message
,
Throwable
cause
,
boolean
enableSuppression
,
boolean
writableStackTrace
,
String
key
,
ErrStatus
status
)
{
super
(
message
,
cause
,
enableSuppression
,
writableStackTrace
);
this
.
key
=
key
;
this
.
status
=
status
;
}
public
String
getKey
()
{
return
key
;
}
public
ErrStatus
getStatus
()
{
return
status
;
}
}
src/main/java/com/vandyo/sentry/core/tools/Signature.java
View file @
3b0b39c9
...
@@ -13,9 +13,9 @@ public class Signature {
...
@@ -13,9 +13,9 @@ public class Signature {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
Tmp
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
Tmp
.
class
);
// need be change to product env
// need be change to product env
// public static final String host = "http://10.100.12.42:8080";
// public static final String host = "http://10.100.12.42:8080";
public
static
final
String
host
=
"http://api.vandyo.com:80"
;
public
static
final
String
host
=
"http://api.vandyo.com:80
111
"
;
// public static final String msgHost = "http://10.100.12.42:8089";
// public static final String msgHost = "http://10.100.12.42:8089";
public
static
final
String
msgHost
=
"http://msg.vandyo.com:80"
;
public
static
final
String
msgHost
=
"http://msg.vandyo.com:80
11
"
;
/**
/**
* 生成签名
* 生成签名
...
...
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