package com.base.biz.controller;

import com.base.biz.model.dto.SatelliteInfoDTO;
import com.base.biz.model.dto.request.QuerySatelliteAddDTO;
import com.base.biz.model.dto.request.SatelliteInfoDTOListReq;
import com.base.biz.model.dto.response.SatelliteTypeListDTO;
import com.base.biz.service.SatelliteService;
import com.base.orbit.web.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

@Api(tags = "卫星")
@RestController
@RequestMapping("/api/satellite")
public class SatelliteController {

    @Resource
    SatelliteService satelliteService;

    @ApiOperation(value = "WX信息查询", response = SatelliteInfoDTO.class)
    @GetMapping("/list")
    public Object getSatelliteInfoDTOList(SatelliteInfoDTOListReq req){
        return Result.success(satelliteService.getSatelliteInfoDTOList(req));
    }

    @ApiOperation(value = "卫星Type类型字段查询", response = SatelliteTypeListDTO.class)
    @GetMapping("/type")
    public Result<SatelliteTypeListDTO> querySatelliteTypeListDTO() {
        ;
        return Result.success(satelliteService.querySatelliteTypeListDTO());
    }

    @ApiOperation(value = "新增卫星")
    @PostMapping("/add")
    public Result addSatellite(@RequestBody QuerySatelliteAddDTO querySatelliteAddDTO) throws Exception {
        satelliteService.addSatellite(querySatelliteAddDTO);
        return Result.success();
    }

    @ApiOperation(value = "修改卫星信息")
    @PostMapping("/update")
    public Result updateSatellite(@RequestBody SatelliteInfoDTO param) {
        satelliteService.updateSatellite(param);
        return Result.success();
    }

    @ApiOperation(value = "根据ID删除卫星和载荷")
    @PostMapping("/delete")
    public Result deleteSatellite(@RequestBody List<String> ids) {
        satelliteService.deleteSatellite(ids);
        return Result.success();
    }
}