|
|
package com.monitor.other.degrade.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.monitor.common.util.HttpClientUtil;
|
|
|
import com.monitor.model.domain.AppDegradeConfig;
|
|
|
import com.monitor.model.request.AppDegradeInfoReq;
|
...
|
...
|
@@ -8,6 +10,7 @@ import com.monitor.mysql.mapper.AppDegradeConfigMapper; |
|
|
import com.monitor.other.degrade.service.AppDegradeService;
|
|
|
import com.yoho.core.common.utils.MD5;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
...
|
...
|
@@ -38,37 +41,37 @@ public class AppDegradeServiceImpl implements AppDegradeService { |
|
|
|
|
|
@Override
|
|
|
public int updateAppDegradeConfig(AppDegradeInfoReq req) {
|
|
|
int result = appDegradeConfigMapper.updateByPrimaryKeySelective(req);
|
|
|
if (result == 1) {
|
|
|
List<AppDegradeConfig> list = appDegradeConfigMapper.getAllDegradeApi();
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
for (AppDegradeConfig appDegradeConfig : list) {
|
|
|
sb.append(appDegradeConfig.getApiCode()).append(",");
|
|
|
}
|
|
|
sb.append(";");
|
|
|
}
|
|
|
SortedMap<String, String> param = new TreeMap<>();
|
|
|
param.put("client_type", "iphone");
|
|
|
param.put("private_key", "a85bb0674e08986c6b115d5e3a4884fa");
|
|
|
param.put("app_version", "9.9.9");
|
|
|
param.put("config_key", "demoteapi");
|
|
|
param.put("method", "resources.config.syncAppDegrade");
|
|
|
param.put("config_value", sb.toString().replace(",;", "").replace(";", ""));
|
|
|
String cs = getClientSecret(param);
|
|
|
param.put("client_secret", cs);
|
|
|
param.remove("private_key");
|
|
|
HttpClientUtil.doget("http://api.yoho.cn", param, null);
|
|
|
}
|
|
|
return result;
|
|
|
return appDegradeConfigMapper.updateByPrimaryKeySelective(req);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int addAppDegradeConfig(AppDegradeInfoReq req) {
|
|
|
return 0;
|
|
|
public int sync() {
|
|
|
List<AppDegradeConfig> list = appDegradeConfigMapper.getAllDegradeApi();
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
for (AppDegradeConfig appDegradeConfig : list) {
|
|
|
sb.append(appDegradeConfig.getApiCode()).append(",");
|
|
|
}
|
|
|
sb.append(";");
|
|
|
}
|
|
|
SortedMap<String, String> param = new TreeMap<>();
|
|
|
param.put("client_type", "iphone");
|
|
|
param.put("private_key", "a85bb0674e08986c6b115d5e3a4884fa");
|
|
|
param.put("app_version", "9.9.9");
|
|
|
param.put("config_key", "demoteapi");
|
|
|
param.put("method", "resources.config.syncAppDegrade");
|
|
|
param.put("config_value", sb.toString().replace(",;", "").replace(";", ""));
|
|
|
String cs = getClientSecret(param);
|
|
|
param.put("client_secret", cs);
|
|
|
param.remove("private_key");
|
|
|
String result = HttpClientUtil.doget("http://api.yoho.cn", param, null);
|
|
|
if (StringUtils.isNotEmpty(result)) {
|
|
|
JSONObject json = JSON.parseObject(result);
|
|
|
return json.getIntValue("code");
|
|
|
}
|
|
|
return 201;
|
|
|
}
|
|
|
|
|
|
|
|
|
public String getClientSecret(SortedMap<String, String> filtedMap) {
|
|
|
filtedMap.remove("client_secret");
|
|
|
List<String> array = new LinkedList<>();
|
...
|
...
|
@@ -80,4 +83,6 @@ public class AppDegradeServiceImpl implements AppDegradeService { |
|
|
String sign = MD5.md5(signStr);
|
|
|
return sign;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|