package com.jiayue.ipfcst.controller;

import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipfcst.common.data.entity.WeatherStationInfo;
import com.jiayue.ipfcst.service.WeatherStationInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 气象设备信息restful接口
 *
 * @author yh
 * @version 1.0
 * @since 2019/8/7 10:12
 */
@RestController
@Slf4j
public class WeatherStationInfoController {

  private final WeatherStationInfoService weatherStationInfoService;

  @Autowired
  public WeatherStationInfoController(WeatherStationInfoService weatherStationInfoService){
    this.weatherStationInfoService=weatherStationInfoService;
  }

  /**
   * 查询所有气象设备信息按ID排序 yh
   * @return 结果集
   */
  @GetMapping(value = "/weatherStationInfos")
  public ResponseVO findAllByOrderByIdAsc(){
    List<WeatherStationInfo> list = new ArrayList<>();
    try{
      list = weatherStationInfoService.findAllByOrderByIdAsc();
      return ResponseVO.success(list);
    }catch(Exception e){
      e.printStackTrace();
      log.error("气象设备查询错误");
      return ResponseVO.fail(e.toString());
    }
  }
}
