修改请求方式 将feign转为http请求
parent
64f4140ad5
commit
8e7d294945
@ -0,0 +1,68 @@
|
||||
package com.hchbox.api;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.hchbox.model.param.CommonResult;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author wujingtao
|
||||
* @date 2021/10/20
|
||||
*/
|
||||
@Component
|
||||
public class RequestCore {
|
||||
private final String API_PREFIX = "/source";
|
||||
@Value("${trade.service.source.url}")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 分页查询主账号的列表
|
||||
*
|
||||
* @param sellerNick
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
public CommonResult<Object> getParentAccount(@RequestParam(value = "sellerNick") String sellerNick, Pageable pageable) {
|
||||
String reqUrl = url + API_PREFIX + "/account/parentAccounts" + "?" + "sellerNick=" + sellerNick + "&pageNumber=" + pageable.getPageNumber() + "&pageSize=" + pageable.getPageSize();
|
||||
return requestApi(reqUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询套餐
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CommonResult<Object> getPayTemplate() {
|
||||
String reqUrl = url + API_PREFIX + "/pay/template";
|
||||
return requestApi(reqUrl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 子账号授权
|
||||
*
|
||||
* @param childrenAccountId
|
||||
* @param payTemplateId
|
||||
* @return
|
||||
*/
|
||||
CommonResult<Object> authorizeChildrenAccount(@RequestParam(value = "childrenAccountId") Long childrenAccountId, @RequestParam(value = "payTemplateId") Long payTemplateId) {
|
||||
String reqUrl = url + API_PREFIX + "/account/authorize" + "?" + "childrenAccountId=" + childrenAccountId + "&payTemplateId=" + payTemplateId;
|
||||
return requestApi(reqUrl);
|
||||
}
|
||||
|
||||
private CommonResult<Object> requestApi(String url) {
|
||||
JSONObject results;
|
||||
String getResult = HttpUtil
|
||||
.createGet(url)
|
||||
.execute()
|
||||
.charset("utf-8")
|
||||
.body();
|
||||
JSONObject o = JSONUtil.parseObj(getResult);
|
||||
results = o.getJSONObject("data");
|
||||
return new CommonResult<>().success(results);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue