package com.base.biz.controller.rpc;

import com.base.biz.model.dto.PayloadInfoDTO;
import com.base.biz.model.dto.request.PayloadInfoDTOListReq;
import com.base.biz.service.PayloadService;
import com.base.api.model.PayloadRpcDTO;
import com.base.api.model.request.PayloadRpcReqDTO;
import com.base.orbit.utils.BizUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController

@RequestMapping("/rpc/payload")
public class PayloadRpcController {

    @Resource
    PayloadService payloadService;

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public List<PayloadRpcDTO> getPayloadRpcDTOList(@RequestBody PayloadRpcReqDTO payloadRpcReqDTO){
        PayloadInfoDTOListReq payloadInfoDTOListQReq = new PayloadInfoDTOListReq();
        payloadInfoDTOListQReq.setSatelliteIds(payloadRpcReqDTO.getSatelliteIds());
        payloadInfoDTOListQReq.setSatelliteCodes(payloadRpcReqDTO.getSatelliteCodes());
        payloadInfoDTOListQReq.setIds(payloadRpcReqDTO.getPayloadIds());
        List<PayloadInfoDTO> payloadInfoDTOList = payloadService.getPayloadInfoList(payloadInfoDTOListQReq);
        return BizUtils.copyEntityToDto(PayloadRpcDTO.class,payloadInfoDTOList);
    }

    @RequestMapping(value = "/getAllList", method = RequestMethod.POST)
    public List<PayloadRpcDTO> getAllList() {
        List<PayloadInfoDTO> payloadInfoDTOList = payloadService.getAllList();
        return BizUtils.copyEntityToDto(PayloadRpcDTO.class, payloadInfoDTOList);
    }

}
