diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java index 0f5eb26c..9a5e35b1 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java @@ -1,25 +1,20 @@ package org.jeecg.modules.system.controller; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.util.CommonUtils; -import org.jeecg.common.util.RestUtil; -import org.jeecg.common.util.TokenUtils; import org.jeecg.common.util.filter.FileTypeFilter; import org.jeecg.common.util.oConvertUtils; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.util.AntPathMatcher; import org.springframework.util.FileCopyUtils; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.HandlerMapping; @@ -28,7 +23,6 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; -import java.net.URLDecoder; /** *
@@ -349,53 +343,4 @@ public class CommonController {
return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
}
- /**
- * 中转HTTP请求,解决跨域问题
- *
- * @param url 必填:请求地址
- * @return
- */
- @RequestMapping("/transitRESTful")
- public Result transitRestful(@RequestParam("url") String url, HttpServletRequest request) {
- try {
- ServletServerHttpRequest httpRequest = new ServletServerHttpRequest(request);
- // 中转请求method、body
- HttpMethod method = httpRequest.getMethod();
- JSONObject params;
- try {
- params = JSON.parseObject(JSON.toJSONString(httpRequest.getBody()));
- } catch (Exception e) {
- params = new JSONObject();
- }
- // 中转请求问号参数
- JSONObject variables = JSON.parseObject(JSON.toJSONString(request.getParameterMap()));
- variables.remove("url");
- // 在 headers 里传递Token
- String token = TokenUtils.getTokenByRequest(request);
- HttpHeaders headers = new HttpHeaders();
- headers.set("X-Access-Token", token);
- // 发送请求
- String httpUrl = URLDecoder.decode(url, "UTF-8");
- ResponseEntity