package com.base.biz.controller;

import com.base.biz.model.dto.StationInfoDTO;
import com.base.biz.model.dto.request.QueryStationAddDTO;
import com.base.biz.model.dto.request.StationInfoDTOListReq;
import com.base.biz.model.dto.response.StationTypeListDTO;
import com.base.biz.model.entity.StationInfo;
import com.base.biz.service.StationService;
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/station")
public class StationController {

    @Resource
    StationService stationService;

    @ApiOperation(value = "地面站信息查询" ,response = StationInfoDTO.class)
    @GetMapping("/list")
    public Object getStationInfoDTOList(StationInfoDTOListReq req){
        return Result.success(stationService.getStationInfoDTOList(req));
    }

    @ApiOperation(value = "站Type类型字段查询")
    @GetMapping("/station/type")
    public Result<StationTypeListDTO> queryStationTypeListDTO() throws Exception {
        return Result.success(stationService.queryStationTypeListDTO());
    }

    @ApiOperation(value = "根据资源类型查询地面站")
    @GetMapping("/station/list/resource/type")
    public Result<List<StationInfo>> selListByResourceType(String resourceType){
        return Result.success(stationService.selListByResourceType(resourceType));
    }

    @ApiOperation(value = "新增站信息")
    @PostMapping("/add")
    public Result addStation(@RequestBody QueryStationAddDTO queryStationAddDTO) {
        stationService.addStation(queryStationAddDTO);
        return Result.success();
    }

    @ApiOperation(value = "修改站信息")
    @PostMapping("/update")
    public Result updateStation(@RequestBody QueryStationAddDTO queryStationUpdateDTO) {
        stationService.updateStation(queryStationUpdateDTO);
        return Result.success();
    }

    @ApiOperation(value = "根据ID删除地面站")
    @PostMapping("/delete")
    public Result deleteStation(@RequestBody List<String> ids) {
        return stationService.deleteStation(ids);
    }
}
