@@ -19,6 +19,11 @@ public class AirportLineController { | |||
@Autowired | |||
private IAirportLineService airportLineService; | |||
@GetMapping("/{id}") | |||
public JsonResult getInfoById(@PathVariable("id") Integer id) { | |||
return airportLineService.getInfoById(id); | |||
} | |||
/** | |||
* 根据任务id获取航线 | |||
* @param inspectionId |
@@ -5,6 +5,7 @@ import com.tuoheng.admin.entity.request.inspection.AirportLineRequest; | |||
import com.tuoheng.admin.entity.vo.airport.AirportLineVo; | |||
import com.tuoheng.admin.mapper.AirportLineMapper; | |||
import com.tuoheng.admin.service.airportline.add.AddAirportLineService; | |||
import com.tuoheng.admin.service.airportline.query.info.QueryAirportLineInfoService; | |||
import com.tuoheng.admin.service.airportline.query.inspection.QueryAirportLineByInspectionIdFactory; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
@@ -23,6 +24,9 @@ import java.util.List; | |||
@Slf4j | |||
public class AirportLineServiceImpl extends BaseServiceImpl<AirportLineMapper, AirportLine> implements IAirportLineService { | |||
@Autowired | |||
private QueryAirportLineInfoService queryAirportLineInfoService; | |||
@Autowired | |||
private QueryAirportLineByInspectionIdFactory queryAirportLineByInspectionIdFactory; | |||
@@ -32,6 +36,18 @@ public class AirportLineServiceImpl extends BaseServiceImpl<AirportLineMapper, A | |||
@Autowired | |||
private AirportService airportService; | |||
/** | |||
* 查询航线信息 | |||
* | |||
* @param id 航线Id | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getInfoById(Integer id) { | |||
return queryAirportLineInfoService.getInfo(id); | |||
} | |||
/** | |||
* 查询航线信息 | |||
* |
@@ -12,6 +12,14 @@ import org.springframework.web.bind.annotation.PathVariable; | |||
*/ | |||
public interface IAirportLineService extends IBaseService<AirportLine> { | |||
/** | |||
* 查询航线信息 | |||
* | |||
* @param id 航线Id | |||
* @return | |||
*/ | |||
JsonResult getInfoById(Integer id); | |||
/** | |||
* 查询航线信息 | |||
* |
@@ -0,0 +1,55 @@ | |||
package com.tuoheng.admin.service.airportline.query.info; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.entity.vo.airport.AirportLineVo; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.http.HttpStatus; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@Slf4j | |||
@Service | |||
public class QueryAirportLineInfoService { | |||
@Autowired | |||
private AirportService airportService; | |||
public JsonResult getInfo(Integer id) { | |||
JsonResult result = this.check(id); | |||
if (0 != result.getCode()) { | |||
log.info("根据id查询航线信息:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
List<Integer> airportLineIdList = new ArrayList<>(); | |||
airportLineIdList.add(id); | |||
List<AirportLineVo> airportLineVoList = airportService.getAirportLineListByAirportIdAndLineIdList(null, airportLineIdList); | |||
if (CollectionUtil.isEmpty(airportLineVoList)) { | |||
log.info("该航线不存在,id={}", id); | |||
return JsonResult.success(); | |||
} | |||
AirportLineVo airportLineVo = airportLineVoList.get(0); | |||
return JsonResult.success(airportLineVo); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(Integer id) { | |||
if (ObjectUtil.isEmpty(id)) { | |||
log.info("参数ID为空"); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "参数ID为空"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |