mirror of
https://gitee.com/freshday/radar.git
synced 2025-12-26 07:16:26 +08:00
feats: http 插件支持多参数,代码优化.
feihu wang
This commit is contained in:
parent
3a9deb6f95
commit
bf762295bb
@ -34,7 +34,7 @@ public class AntiFraudServiceImpl implements AntiFraudService {
|
||||
@Autowired
|
||||
private AntiFraudEngine antiFraudEngine;
|
||||
|
||||
@Autowired
|
||||
@Autowired(required = false)
|
||||
private PluginService pluginService;
|
||||
|
||||
@Autowired
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user