|
|
@@ -1,18 +1,18 @@ |
|
|
|
package com.tuoheng.admin.tzhl.service.airport; |
|
|
|
package com.tuoheng.admin.tzhl.service.airportline; |
|
|
|
|
|
|
|
import ch.qos.logback.core.util.StringCollectionUtil; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.tuoheng.admin.tzhl.constant.TZHLConstant; |
|
|
|
import com.tuoheng.admin.tzhl.request.TZHLGetAirportLineListRequest; |
|
|
|
import com.tuoheng.admin.tzhl.response.TZHLAirportLineResponse; |
|
|
|
import com.tuoheng.admin.tzhl.service.token.TZHLGetTokenService; |
|
|
|
import com.tuoheng.common.core.config.common.CommonConfig; |
|
|
|
import com.tuoheng.common.core.exception.ServiceException; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpEntity; |
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.http.*; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.client.RestClientException; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
@@ -31,9 +31,13 @@ public class TZHLGetAirportLineListService { |
|
|
|
@Autowired |
|
|
|
private RestTemplate restTemplate; |
|
|
|
|
|
|
|
public JsonResult getAirportLine(TZHLGetAirportLineListRequest request){ |
|
|
|
public JsonResult getAirportLine(String name, String sn, String lineType){ |
|
|
|
String token = tzhlGetTokenService.getToken(); |
|
|
|
JsonResult result =this.check(request,token); |
|
|
|
TZHLGetAirportLineListRequest request = new TZHLGetAirportLineListRequest(); |
|
|
|
request.setName(name); |
|
|
|
request.setSn(sn); |
|
|
|
request.setLineType(lineType); |
|
|
|
JsonResult result =this.check(token); |
|
|
|
if(result.getCode() != 0){ |
|
|
|
return JsonResult.error(result.getMsg()); |
|
|
|
} |
|
|
@@ -53,23 +57,24 @@ public class TZHLGetAirportLineListService { |
|
|
|
log.info("请求获取机场列表, httpEntity:{}", httpEntity); |
|
|
|
return JsonResult.error("请求获取机场列表失败"); |
|
|
|
} |
|
|
|
if(null == response || !response.hasBody()){ |
|
|
|
log.error("获取机场航线列表失败"); |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"获取机场列表失败"); |
|
|
|
} |
|
|
|
if(response.getBody().getCode() != 200){ |
|
|
|
log.error("获取机场航线列表失"+response.getBody()); |
|
|
|
return JsonResult.error(response.getBody().getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
TZHLAirportLineResponse tzhlAirportLineResponse = JSONObject.parseObject(response.getBody().getData().toString(), |
|
|
|
TZHLAirportLineResponse.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return JsonResult.success(tzhlAirportLineResponse); |
|
|
|
} |
|
|
|
|
|
|
|
private JsonResult check(TZHLGetAirportLineListRequest request,String token) { |
|
|
|
if(StringUtils.isEmpty(request.getName())){ |
|
|
|
return JsonResult.error("机场名称为空"); |
|
|
|
} |
|
|
|
if(StringUtils.isEmpty(request.getSn())){ |
|
|
|
return JsonResult.error("方舱序列号为空"); |
|
|
|
} |
|
|
|
if(StringUtils.isEmpty(request.getLineType())){ |
|
|
|
return JsonResult.error("航线类型为空"); |
|
|
|
} |
|
|
|
private JsonResult check(String token) { |
|
|
|
if(StringUtils.isEmpty(token)){ |
|
|
|
return JsonResult.error("token不存在或已过期"); |
|
|
|
} |