package com.base.biz.controller.rpc;


import com.base.api.model.request.FzTaskInfoUpdateRpcDTO;
import com.base.api.model.request.UpdateSatelliteRpcDTO;
import com.base.biz.model.dto.SatelliteInfoDTO;
import com.base.biz.model.dto.request.FzTaskInfoUpdateDTO;
import com.base.biz.model.dto.request.SatelliteInfoDTOListReq;
import com.base.biz.model.dto.request.UpdateSatelliteDTOReq;
import com.base.biz.service.SatelliteService;
import com.base.api.model.SatelliteRpcDTO;
import com.base.orbit.utils.BizUtils;
import com.base.orbit.web.Result;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController

@RequestMapping("/rpc/satellite")
public class SatelliteRpcController {

    @Autowired
    private SatelliteService SatelliteService;

    /**
     * 查询卫星信息
     *
     */
    @RequestMapping(value = "/listall", method = RequestMethod.GET)
    public List<SatelliteRpcDTO> list(){
        SatelliteInfoDTOListReq req=new SatelliteInfoDTOListReq();
        List<SatelliteInfoDTO> list = SatelliteService.getSatelliteInfoDTOList(req);
        return BizUtils.copyEntityToDto(SatelliteRpcDTO.class,list);
    }

    /**
     * 查询卫星信息
     *@param ids
     */
    @PostMapping("/listbyids")
    public List<SatelliteRpcDTO> listByIds(@RequestBody List<String> satelliteCodes){
        List<SatelliteInfoDTO> list = SatelliteService.listByIds(satelliteCodes);
        return BizUtils.copyEntityToDto(SatelliteRpcDTO.class,list);
    }

    /**
     * 查询卫星信息
     *@param ids
     */
    @PostMapping("/queryAllSatelliteByIds")
    public List<SatelliteRpcDTO> queryAllSatelliteByIds(@RequestBody List<String> satelliteids){
        List<SatelliteInfoDTO> list = SatelliteService.queryAllSatelliteByIds(satelliteids);
        return BizUtils.copyEntityToDto(SatelliteRpcDTO.class,list);
    }

    @PostMapping("/update")
    public Object update(@RequestBody UpdateSatelliteRpcDTO req) {
        UpdateSatelliteDTOReq updateSatelliteDTOReq = new UpdateSatelliteDTOReq();
        BeanUtils.copyProperties(req, updateSatelliteDTOReq);
        SatelliteService.update(updateSatelliteDTOReq);
        return Result.success();
    }
}
