old mode 100644
new mode 100755
| | |
| | | /* |
| | | * Copyright 2017-2020 吴学文 and java110 team. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.java110.front.controller.app; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.base.controller.BaseController; |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.front.smo.api.IApiSMO; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | @Autowired |
| | | private IApiSMO apiSMOImpl; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | /** |
| | | * 资源请求 post方式 |
| | |
| | | headers.put(CommonConstant.HTTP_SERVICE, service); |
| | | headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_POST); |
| | | logger.debug("api:{} 请求报文为:{},header信息为:{}", service, postInfo, headers); |
| | | IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA); |
| | | hasPrivilege(restTemplate, pd, "/app/" + service); |
| | | responseEntity = apiSMOImpl.doApi(postInfo, headers, request); |
| | | } catch (Throwable e) { |
| | | logger.error("请求post 方法[" + service + "]失败:" + postInfo, e); |
| | |
| | | headers.put(CommonConstant.HTTP_SERVICE, service); |
| | | headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_GET); |
| | | logger.debug("api:{} 请求报文为:{},header信息为:{}", "", headers); |
| | | IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA); |
| | | hasPrivilege(restTemplate, pd, "/app/" + service); |
| | | responseEntity = apiSMOImpl.doApi(JSONObject.toJSONString(getParameterStringMap(request)), headers, request); |
| | | } catch (Throwable e) { |
| | | logger.error("请求get 方法[" + service + "]失败:", e); |
| | |
| | | headers.put(CommonConstant.HTTP_ACTION, action); |
| | | headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_GET); |
| | | logger.debug("api:{} 请求报文为:{},header信息为:{}", "", headers); |
| | | IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA); |
| | | hasPrivilege(restTemplate, pd, "/app/" + resource + "/" + action); |
| | | responseEntity = apiSMOImpl.doApi(JSONObject.toJSONString(getParameterStringMap(request)), headers, request); |
| | | } catch (Throwable e) { |
| | | logger.error("请求get 方法[" + action + "]失败:", e); |
| | |
| | | headers.put(CommonConstant.HTTP_ACTION, action); |
| | | headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_POST); |
| | | logger.debug("api:{} 请求报文为:{},header信息为:{}", action, postInfo, headers); |
| | | IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA); |
| | | hasPrivilege(restTemplate, pd, "/app/" + resource + "/" + action); |
| | | responseEntity = apiSMOImpl.doApi(postInfo, headers, request); |
| | | } catch (Throwable e) { |
| | | logger.error("请求post 方法[" + action + "]失败:" + postInfo, e); |
| | |
| | | headers.put(CommonConstant.HTTP_SERVICE, service); |
| | | headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_PUT); |
| | | logger.debug("api:{} 请求报文为:{},header信息为:{}", service, postInfo, headers); |
| | | IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA); |
| | | hasPrivilege(restTemplate, pd, "/app/" + service ); |
| | | responseEntity = apiSMOImpl.doApi(postInfo, headers, request); |
| | | } catch (Throwable e) { |
| | | logger.error("请求put 方法[" + service + "]失败:", e); |
| | |
| | | headers.put(CommonConstant.HTTP_SERVICE, service); |
| | | headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_DELETE); |
| | | logger.debug("api:{} 请求报文为:{},header信息为:{}", service, "", headers); |
| | | |
| | | IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA); |
| | | hasPrivilege(restTemplate, pd, "/app/" + service ); |
| | | responseEntity = apiSMOImpl.doApi(JSONObject.toJSONString(getParameterStringMap(request)), headers, request); |
| | | } catch (Throwable e) { |
| | | logger.error("请求delete 方法[" + service + "]失败:", e); |