|
@@ -1,12 +1,17 @@
|
|
|
package com.fdkk.sxz.webApi.controller;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkk.sxz.annotation.auth.NoAuthentication;
|
|
|
import com.fdkk.sxz.annotation.log.AroundLog;
|
|
|
import com.fdkk.sxz.base.Result;
|
|
|
import com.fdkk.sxz.util.CreateObjUtil;
|
|
|
import com.fdkk.sxz.util.SnowIdUtil;
|
|
|
import com.fdkk.sxz.util.UploadToOssUtil;
|
|
|
+import com.fdkk.sxz.vo.request.RequestForwardPost;
|
|
|
import com.fdkk.sxz.vo.request.RequestOfflineConvert;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
@@ -39,6 +44,12 @@ public class OfflineController {
|
|
|
@Autowired
|
|
|
private SnowIdUtil snowIdUtil;
|
|
|
|
|
|
+ @Value("${local.network.url}")
|
|
|
+ private String localNetworkUrl;
|
|
|
+
|
|
|
+ @Value("${main.url}")
|
|
|
+ private String mainUrl;
|
|
|
+
|
|
|
/**
|
|
|
* 转换modeldata
|
|
|
*
|
|
@@ -62,4 +73,39 @@ public class OfflineController {
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 转换modeldata
|
|
|
+ *
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("转发内网请求")
|
|
|
+ @RequestMapping(value = "/forwardPost", method = RequestMethod.POST)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "params", value = "参数", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "action", value = "接口名称", dataType = "String")})
|
|
|
+ @NoAuthentication
|
|
|
+ public Object forwardPost(HttpServletRequest request, @RequestBody RequestForwardPost dto) {
|
|
|
+ if (ObjectUtil.isNotNull(request.getHeader("token")) && StrUtil.isNotEmpty(request.getHeader("token"))) {
|
|
|
+ String url = mainUrl + "api/sso/user/checkToken";
|
|
|
+ OfflineController.log.info("验证token的url:{}", url);
|
|
|
+ String res = HttpRequest.post(localNetworkUrl + dto.getAction())
|
|
|
+ .header("token", request.getHeader("token"))
|
|
|
+ .execute().body();
|
|
|
+ JSONObject resObject = JSONObject.parseObject(res);
|
|
|
+ if (null != resObject) {
|
|
|
+ if (resObject.containsKey("code")) {
|
|
|
+ int code = resObject.getInteger("code");
|
|
|
+ if (code != 0) {
|
|
|
+ return resObject;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String result2 = HttpRequest.post(localNetworkUrl + dto.getAction())
|
|
|
+ .body(dto.getParams())
|
|
|
+ .execute().body();
|
|
|
+ return Result.success(result2);
|
|
|
+
|
|
|
+ }
|
|
|
}
|