wisdomisite-java/src/main/java/com/zhgd/xmgl/util/ThirdPartRequestUtil.java

35 lines
1016 B
Java
Raw Normal View History

2023-09-13 14:16:46 +08:00
package com.zhgd.xmgl.util;
import com.gexin.fastjson.JSON;
import com.zhgd.jeecg.common.util.pass.HttpUtils;
import com.zhgd.xmgl.modules.basicdata.entity.ThirdPartRequestLog;
import com.zhgd.xmgl.modules.basicdata.mapper.ThirdPartRequestLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ThirdPartRequestUtil {
@Autowired
ThirdPartRequestLogMapper thirdPartRequestLogMapper;
/**
* 发送http请求json格式
*
* @param url
* @param body
*/
public String post(String url, Object body) {
ThirdPartRequestLog log = new ThirdPartRequestLog();
log.setUrl(url);
log.setMethod(2);
log.setParam(JSON.toJSONString(body));
thirdPartRequestLogMapper.insert(log);
String rs = HttpUtils.post(url, body);
log.setResult(rs);
log.setStatus(1);
thirdPartRequestLogMapper.updateById(log);
return rs;
}
}