package com.base.biz.controller.rpc;


import com.base.api.model.PayloadRpcDTO;
import com.base.api.model.StationRpcDTO;
import com.base.biz.model.dto.PayloadInfoDTO;
import com.base.biz.model.dto.StationInfoDTO;
import com.base.biz.model.dto.request.StationInfoDTOListReq;
import com.base.biz.model.dto.request.StationInfoDTOSetReq;
import com.base.biz.service.StationService;
import com.base.api.model.request.QueryStationAddRpcDTO;
import com.base.orbit.utils.BizUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

@RestController

@RequestMapping("/rpc/station")
public class StationRpcController {

    @Autowired
    private StationService yxInfoBasisStationService;


    // 根据地面站代号集合查询地面站信息
    @PostMapping("/listbystationids")
    public List<QueryStationAddRpcDTO> getStationListByStationIdList(@RequestBody List<String> stationIdList) {
        StationInfoDTOListReq req = new StationInfoDTOListReq();
        if (CollectionUtils.isEmpty(stationIdList)) {
        } else {
            req.setIds(stationIdList);
        }
        List<StationInfoDTO> list = yxInfoBasisStationService.getStationInfoDTOList(req);
        return BizUtils.copyEntityToDto(QueryStationAddRpcDTO.class, list);
    }

    // 根据地面站代号集合查询地面站信息
    @PostMapping("/setbystationids")
    public List<QueryStationAddRpcDTO> getStationListByStationIdSet(@RequestBody Set<String> stationIdList) {
        StationInfoDTOSetReq req = new StationInfoDTOSetReq();
        if (CollectionUtils.isEmpty(stationIdList)) {
        } else {
            req.setIds(stationIdList);
        }
        List<StationInfoDTO> list = yxInfoBasisStationService.getStationListByStationIdSet(req);
        return BizUtils.copyEntityToDto(QueryStationAddRpcDTO.class, list);
    }


    @RequestMapping(value = "/getAllList", method = RequestMethod.POST)
    public List<StationRpcDTO> getAllList() {
        List<StationInfoDTO> stationInfoDTOS = yxInfoBasisStationService.getAllList();
        return BizUtils.copyEntityToDto(StationRpcDTO.class, stationInfoDTOS);
    }
}
