1
This commit is contained in:
@@ -5,8 +5,12 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.erp.request.ExpressCompaniesQueryRequest;
|
||||
import com.ruoyi.erp.request.IERPAccount;
|
||||
import com.ruoyi.jarvis.domain.ErpOpenConfig;
|
||||
import com.ruoyi.jarvis.service.IErpOpenConfigService;
|
||||
import com.ruoyi.jarvis.service.erp.ErpAccountResolver;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -20,6 +24,34 @@ public class ErpOpenConfigController extends BaseController {
|
||||
@Resource
|
||||
private IErpOpenConfigService erpOpenConfigService;
|
||||
|
||||
@Resource
|
||||
private ErpAccountResolver erpAccountResolver;
|
||||
|
||||
/**
|
||||
* 查询闲管家快递公司列表(POST body 固定为 {},与签名规则一致)
|
||||
*
|
||||
* @param appKey 与配置中心一致;不传则按 {@link ErpAccountResolver#resolve(String)} 默认账号
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:erpOpenConfig:list')")
|
||||
@GetMapping("/expressCompanies")
|
||||
public AjaxResult expressCompanies(@RequestParam(required = false) String appKey) {
|
||||
try {
|
||||
IERPAccount cred = erpAccountResolver.resolve(appKey);
|
||||
ExpressCompaniesQueryRequest req = new ExpressCompaniesQueryRequest(cred);
|
||||
String resp = req.getResponseBody();
|
||||
JSONObject o = JSONObject.parseObject(resp);
|
||||
if (o == null) {
|
||||
return AjaxResult.error("开放平台返回空");
|
||||
}
|
||||
if (o.getIntValue("code") != 0) {
|
||||
return AjaxResult.error(o.getString("msg") != null ? o.getString("msg") : resp);
|
||||
}
|
||||
return AjaxResult.success(o.get("data"));
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("调用快递公司接口失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:erpOpenConfig:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ErpOpenConfig query) {
|
||||
|
||||
Reference in New Issue
Block a user