dev
parent
a6b7892dd6
commit
99ee2d2245
|
@ -1,18 +1,19 @@
|
||||||
package bokang.xiao.response_deal;
|
package bokang.xiao.response_deal;
|
||||||
|
|
||||||
|
import aiyh.utils.ScriptUtil;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.excention.CustomerException;
|
import aiyh.utils.excention.CustomerException;
|
||||||
import aiyh.utils.httpUtil.ResponeVo;
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
import bokang.xiao.entity.FieldDefinition;
|
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
|
||||||
import bokang.xiao.exception.ResponseException;
|
import bokang.xiao.exception.ResponseException;
|
||||||
import bokang.xiao.response_deal.entity.ResponseConfig;
|
import bokang.xiao.response_deal.entity.ResponseConfig;
|
||||||
|
import bokang.xiao.response_deal.entity.ResponseConfigAlias;
|
||||||
import bokang.xiao.response_deal.entity.ResponseConfigValueChange;
|
import bokang.xiao.response_deal.entity.ResponseConfigValueChange;
|
||||||
import bokang.xiao.response_deal.mapper.ConfigMapper;
|
import bokang.xiao.response_deal.mapper.ConfigMapper;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +29,56 @@ public class ResponseMappingDeal {
|
||||||
private final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class);
|
private final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class);
|
||||||
|
|
||||||
|
|
||||||
|
public void parseConfig(String uniqueCode, ResponeVo responeVo) {
|
||||||
|
if (responeVo.getCode() != 200) {
|
||||||
|
throw new CustomerException("你妈没成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ResponseConfig> responseConfigs = configMapper.queryResponseConfigByUnique(uniqueCode);
|
||||||
|
|
||||||
|
if (CollectionUtil.isEmpty(responseConfigs)) {
|
||||||
|
throw new CustomerException("sb");
|
||||||
|
}
|
||||||
|
for (ResponseConfig responseConfig : responseConfigs) {
|
||||||
|
parseConfigOne(responseConfig, responeVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseConfigOne(ResponseConfig responseConfig, ResponeVo responeVo) {
|
||||||
|
List<ResponseConfigAlias> responseConfigAliasList = responseConfig.getResponseConfigAliasList();
|
||||||
|
String successExp = responseConfig.getSuccessExp();
|
||||||
|
Map<String, Object> responseMap = responeVo.getResponseMap();
|
||||||
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||||
|
if (CollectionUtil.isEmpty(responseMap)) {
|
||||||
|
// 他是一个list,尝试获取一下
|
||||||
|
List<Map> result = responeVo.getResult();
|
||||||
|
if (CollectionUtil.isEmpty(result)) {
|
||||||
|
throw new CustomerException("没有响应结果,你同步个J8");
|
||||||
|
} else {
|
||||||
|
for (Map map : result) {
|
||||||
|
Map<String, Object> tempMap = new HashMap<>();
|
||||||
|
for (Object entry : map.entrySet()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
resultList.add(tempMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resultList.add(responseMap);
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(successExp)) {
|
||||||
|
for (Map<String, Object> map : resultList) {
|
||||||
|
boolean flag = (boolean) ScriptUtil.invokeScript(successExp, map);
|
||||||
|
if (!flag) {
|
||||||
|
throw new CustomerException("失败了!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getConfig(String uniqueCode, ResponeVo responeVo) {
|
public void getConfig(String uniqueCode, ResponeVo responeVo) {
|
||||||
List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode);
|
List<ResponseConfig> responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode);
|
||||||
if (Objects.isNull(responseConfigList) || responseConfigList.isEmpty()) {
|
if (Objects.isNull(responseConfigList) || responseConfigList.isEmpty()) {
|
||||||
|
@ -87,6 +138,4 @@ public class ResponseMappingDeal {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ public class ResponseConfig {
|
||||||
@SqlOracleDbFieldAnn("model_table_name")
|
@SqlOracleDbFieldAnn("model_table_name")
|
||||||
private String modelTableName;
|
private String modelTableName;
|
||||||
|
|
||||||
|
private String successExp;
|
||||||
|
|
||||||
private List<ResponseConfigAlias> responseConfigAliasList;
|
private List<ResponseConfigAlias> responseConfigAliasList;
|
||||||
|
|
||||||
private List<ResponseConfigValueChange> valueChangeList;
|
private List<ResponseConfigValueChange> valueChangeList;
|
||||||
|
|
Loading…
Reference in New Issue