package com.tuoheng.admin.service.airportline;

import com.tuoheng.admin.entity.domain.AirportLine;
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;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author ChengWang
 * @Date 2023/3/2
 */
@Service
@Slf4j
public class AirportLineServiceImpl extends BaseServiceImpl<AirportLineMapper, AirportLine> implements IAirportLineService {

    @Autowired
    private QueryAirportLineInfoService queryAirportLineInfoService;

    @Autowired
    private QueryAirportLineByInspectionIdFactory queryAirportLineByInspectionIdFactory;

    @Autowired
    private AddAirportLineService addAirportLineService;

    @Autowired
    private AirportService airportService;


    /**
     * 查询航线信息
     *
     * @param id 航线Id
     * @return
     */
    @Override
    public JsonResult getInfoById(Integer id) {
        return queryAirportLineInfoService.getInfo(id);
    }

    /**
     * 查询航线信息
     *
     * @param inspectionId 任务Id
     * @return
     */
    @Override
    public JsonResult getInfoByInspectionId(String inspectionId) {
        return queryAirportLineByInspectionIdFactory.getAirportLineList(inspectionId);
    }

    /**
     * 查询航线信息
     *
     * @param airportId 任务Id
     * @return
     */
    @Override
    public JsonResult getListByAirportIdId(String airportId) {
        List<AirportLineVo> airportLineVoList = airportService.getAirportLineListByAirportIdAndLineIdList(airportId, null);
        return JsonResult.success(airportLineVoList);
    }


    /**
     *添加航线
     * @param request
     * @return
     */
    @Override
    public JsonResult addAirportLine(AirportLineRequest request) {
        return addAirportLineService.add(request);
    }
}
