| | |
| | | import com.dy.common.multiDataSource.DataSourceContext; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.mw.protocol.CommandType; |
| | | import com.dy.common.softUpgrade.state.UpgradeTaskVo; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import org.springframework.core.env.Environment; |
| | |
| | | String url = UriComponentsBuilder.fromUriString(toMwUrl) |
| | | .build() |
| | | .toUriString(); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpEntity<?> httpEntity = new HttpEntity<>(headers); |
| | | |
| | | //UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) |
| | | // .queryParam("test", test); |
| | | UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ; |
| | | |
| | | ResponseEntity<BaseResponse> response = null; |
| | | try { |
| | | // 通过Post方式调用接口 |
| | | response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaseResponse.class); |
| | | // 通过Get方式调用接口 |
| | | response = restTemplate.exchange(builder.toUriString(), |
| | | HttpMethod.GET, |
| | | new HttpEntity<>(new HttpHeaders()), |
| | | BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("后端系统出错,中间件调用异常"); |