1
|
package com.monitor.other.degrade.service.impl;
|
1
|
package com.monitor.other.degrade.service.impl;
|
2
|
|
2
|
|
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
|
4
|
+import com.alibaba.fastjson.JSONObject;
|
3
|
import com.monitor.common.util.HttpClientUtil;
|
5
|
import com.monitor.common.util.HttpClientUtil;
|
4
|
import com.monitor.model.domain.AppDegradeConfig;
|
6
|
import com.monitor.model.domain.AppDegradeConfig;
|
5
|
import com.monitor.model.request.AppDegradeInfoReq;
|
7
|
import com.monitor.model.request.AppDegradeInfoReq;
|
|
@@ -8,6 +10,7 @@ import com.monitor.mysql.mapper.AppDegradeConfigMapper; |
|
@@ -8,6 +10,7 @@ import com.monitor.mysql.mapper.AppDegradeConfigMapper; |
8
|
import com.monitor.other.degrade.service.AppDegradeService;
|
10
|
import com.monitor.other.degrade.service.AppDegradeService;
|
9
|
import com.yoho.core.common.utils.MD5;
|
11
|
import com.yoho.core.common.utils.MD5;
|
10
|
import org.apache.commons.collections.CollectionUtils;
|
12
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
13
|
+import org.apache.commons.lang3.StringUtils;
|
11
|
import org.springframework.stereotype.Service;
|
14
|
import org.springframework.stereotype.Service;
|
12
|
|
15
|
|
13
|
import javax.annotation.Resource;
|
16
|
import javax.annotation.Resource;
|
|
@@ -38,8 +41,11 @@ public class AppDegradeServiceImpl implements AppDegradeService { |
|
@@ -38,8 +41,11 @@ public class AppDegradeServiceImpl implements AppDegradeService { |
38
|
|
41
|
|
39
|
@Override
|
42
|
@Override
|
40
|
public int updateAppDegradeConfig(AppDegradeInfoReq req) {
|
43
|
public int updateAppDegradeConfig(AppDegradeInfoReq req) {
|
41
|
- int result = appDegradeConfigMapper.updateByPrimaryKeySelective(req);
|
|
|
42
|
- if (result == 1) {
|
44
|
+ return appDegradeConfigMapper.updateByPrimaryKeySelective(req);
|
|
|
45
|
+ }
|
|
|
46
|
+
|
|
|
47
|
+ @Override
|
|
|
48
|
+ public int sync() {
|
43
|
List<AppDegradeConfig> list = appDegradeConfigMapper.getAllDegradeApi();
|
49
|
List<AppDegradeConfig> list = appDegradeConfigMapper.getAllDegradeApi();
|
44
|
StringBuffer sb = new StringBuffer();
|
50
|
StringBuffer sb = new StringBuffer();
|
45
|
if (CollectionUtils.isNotEmpty(list)) {
|
51
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
@@ -58,17 +64,14 @@ public class AppDegradeServiceImpl implements AppDegradeService { |
|
@@ -58,17 +64,14 @@ public class AppDegradeServiceImpl implements AppDegradeService { |
58
|
String cs = getClientSecret(param);
|
64
|
String cs = getClientSecret(param);
|
59
|
param.put("client_secret", cs);
|
65
|
param.put("client_secret", cs);
|
60
|
param.remove("private_key");
|
66
|
param.remove("private_key");
|
61
|
- HttpClientUtil.doget("http://api.yoho.cn", param, null);
|
|
|
62
|
- }
|
|
|
63
|
- return result;
|
67
|
+ String result = HttpClientUtil.doget("http://api.yoho.cn", param, null);
|
|
|
68
|
+ if (StringUtils.isNotEmpty(result)) {
|
|
|
69
|
+ JSONObject json = JSON.parseObject(result);
|
|
|
70
|
+ return json.getIntValue("code");
|
64
|
}
|
71
|
}
|
65
|
-
|
|
|
66
|
- @Override
|
|
|
67
|
- public int addAppDegradeConfig(AppDegradeInfoReq req) {
|
|
|
68
|
- return 0;
|
72
|
+ return 201;
|
69
|
}
|
73
|
}
|
70
|
|
74
|
|
71
|
-
|
|
|
72
|
public String getClientSecret(SortedMap<String, String> filtedMap) {
|
75
|
public String getClientSecret(SortedMap<String, String> filtedMap) {
|
73
|
filtedMap.remove("client_secret");
|
76
|
filtedMap.remove("client_secret");
|
74
|
List<String> array = new LinkedList<>();
|
77
|
List<String> array = new LinkedList<>();
|
|
@@ -80,4 +83,6 @@ public class AppDegradeServiceImpl implements AppDegradeService { |
|
@@ -80,4 +83,6 @@ public class AppDegradeServiceImpl implements AppDegradeService { |
80
|
String sign = MD5.md5(signStr);
|
83
|
String sign = MD5.md5(signStr);
|
81
|
return sign;
|
84
|
return sign;
|
82
|
}
|
85
|
}
|
|
|
86
|
+
|
|
|
87
|
+
|
83
|
} |
88
|
} |