package com.base.biz.controller.rpc;

import com.base.biz.model.dto.InstanceInfoDTO;
import com.base.biz.service.InstanceService;
import com.base.api.model.InstanceRpcDTO;
import com.base.orbit.utils.BizUtils;
import org.springframework.web.bind.annotation.*;

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

@RestController
@RequestMapping("/rpc/instance")

public class InstanceRpcController {

    @Resource
    private InstanceService instanceService;


    @GetMapping("/list")
    public List<InstanceRpcDTO> queryNewestInstance(){
        List<InstanceInfoDTO> list = instanceService.queryNewestInstance();
        return BizUtils.copyEntityToDto(InstanceRpcDTO.class,list);
    }

    @RequestMapping(value = "/getListBySatelliteCode", method = RequestMethod.POST)
    public List<InstanceRpcDTO> getListBySatelliteCode(@RequestBody List<String> stringList){
        List<InstanceInfoDTO> list = instanceService.getInstanceListBySatellite(stringList);
        return BizUtils.copyEntityToDto(InstanceRpcDTO.class,list);
    }

    @RequestMapping(value = "/deleteBySatelliteCode", method = RequestMethod.POST)
    public void   deleteBySatelliteCode(@RequestBody String satelliteCode){
        instanceService.deleteBySatelliteCode(satelliteCode);
    }
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public void   save(@RequestBody InstanceRpcDTO instanceRpcDTO){
        instanceService.save(instanceRpcDTO);
    }
}
