chengf
2025-08-07 4440cdda8530906faf89348a3e480b05c20d4e25
service-api/src/main/java/com/java110/api/controller/component/CallComponentController.java
@@ -17,9 +17,10 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.api.smo.DefaultAbstractComponentSMO;
import com.java110.core.base.controller.BaseController;
import com.java110.core.context.IPageData;
import com.java110.core.context.PageData;
import com.java110.core.language.Java110Lang;
import com.java110.core.log.LoggerFactory;
import com.java110.utils.constant.CommonConstant;
import com.java110.utils.exception.SMOException;
import com.java110.utils.factory.ApplicationContextFactory;
@@ -28,16 +29,13 @@
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
import com.java110.core.log.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -68,6 +66,7 @@
     */
    @RequestMapping(path = "/callComponent/{api}")
    @Java110Lang
    public ResponseEntity<String> callApi(
            @PathVariable String api,
            //@RequestBody String info,
@@ -103,6 +102,7 @@
            logger.error("调用api异常", e);
            responseEntity = new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("调用api异常", e);
            String msg = "";
            if (e instanceof InvocationTargetException) {
@@ -138,6 +138,7 @@
     */
    @RequestMapping(path = "/callComponent/{componentCode}/{componentMethod}")
    @Java110Lang
    public ResponseEntity<String> callComponent(
            @PathVariable String componentCode,
            @PathVariable String componentMethod,
@@ -171,9 +172,11 @@
        } catch (SMOException e) {
            /*MultiValueMap<String, String> headers = new HttpHeaders();
            headers.add("code", e.getResult().getCode());*/
            e.printStackTrace();
            logger.error("调用组件异常", e);
            responseEntity = new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("调用组件异常", e);
            String msg = "";
            if (e instanceof InvocationTargetException) {
@@ -182,7 +185,8 @@
                    msg = targetEx.getMessage();
                }
            } else {
                msg = e.getMessage();
                //msg = e.getMessage();
                msg ="调用异常";
            }
            responseEntity = new ResponseEntity<>(msg, HttpStatus.INTERNAL_SERVER_ERROR);
        } finally {
@@ -210,11 +214,12 @@
     */
    @RequestMapping(path = "/callComponent/upload/{componentCode}/{componentMethod}")
    @Java110Lang
    public ResponseEntity<String> callComponentUploadFile(
            @PathVariable String componentCode,
            @PathVariable String componentMethod,
            @RequestParam("uploadFile") MultipartFile uploadFile,
            //@RequestBody String info,
            @RequestParam(value = "uploadFile", required = false) MultipartFile uploadFile,
            @RequestParam(value = "userId", required = false) String userId,
            HttpServletRequest request) {
        ResponseEntity<String> responseEntity = null;
        Map formParam = null;
@@ -224,6 +229,7 @@
            Assert.hasLength(componentMethod, "参数错误,未传入调用组件方法");
            pd = freshPageDate(request);
            //权限校验
            hasPrivilege(restTemplate, pd, "/callComponent/" + componentCode + "/" + componentMethod);
@@ -279,6 +285,7 @@
     */
    @RequestMapping(path = "/callComponent/download/{componentCode}/{componentMethod}")
    @Java110Lang
    public ResponseEntity<Object> callComponentDownloadFile(
            @PathVariable String componentCode,
            @PathVariable String componentMethod,
@@ -331,7 +338,7 @@
     * @param request HttpServletRequest 对象
     * @return pd 对象
     */
    private IPageData freshPageDate(HttpServletRequest request) {
    public IPageData freshPageDate(HttpServletRequest request) {
        Map<String, String[]> params = request.getParameterMap();
        IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA);
        String reqData = "";