feats: http 插件支持多参数,代码优化.

feihu wang
This commit is contained in:
feihu.wang 2020-10-25 12:46:07 +08:00
parent 3a9deb6f95
commit bf762295bb
3 changed files with 10 additions and 6 deletions

View File

@ -34,7 +34,7 @@ public class AntiFraudServiceImpl implements AntiFraudService {
@Autowired
private AntiFraudEngine antiFraudEngine;
@Autowired
@Autowired(required = false)
private PluginService pluginService;
@Autowired

View File

@ -26,7 +26,11 @@ import javax.annotation.PostConstruct;
import java.util.Calendar;
import java.util.List;
@Service
/**
* 建议使用v2.
*/
@Deprecated
//@Service
@ConditionalOnProperty(prefix = "sys.conf",name="app", havingValue = "engine")
public class PluginServiceImpl implements PluginService {
@ -40,7 +44,7 @@ public class PluginServiceImpl implements PluginService {
@Autowired
private MobileInfoService mobileInfoService;
@Autowired
@Autowired(required = false)
private RestTemplate restTemplate;
@PostConstruct

View File

@ -40,13 +40,13 @@ public class HTTP_UTIL implements PluginServiceV2 {
public Object handle(PreItemVO item, Map<String, Object> jsonInfo, String[] sourceField) {
String url = item.getArgs();
String reqType = item.getReqType();
String arg = jsonInfo.get(sourceField[0]).toString();
//String arg = jsonInfo.get(sourceField[0]).toString();
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> entity = new HttpEntity<>(headers);
RestTemplate restTemplate = (RestTemplate) BeanUtils.getBean("restTemplate");
ResponseEntity<JSONObject> responseEntity = restTemplate
.exchange(url, HttpMethod.valueOf(reqType), entity, JSONObject.class, arg);
logger.info("http plugin:{}\n{}\n {}", url, arg, responseEntity.toString());
.exchange(url, HttpMethod.valueOf(reqType), entity, JSONObject.class, sourceField);
logger.info("http plugin:{}\n{}\n {}", url, sourceField, responseEntity.toString());
if (responseEntity.getStatusCode() == HttpStatus.OK) {
return responseEntity.getBody();
}