package com.jiayue.ipfcst.controller;

import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipfcst.common.data.entity.WindTurbineInfo;
import com.jiayue.ipfcst.service.WindTurbineInfoService;
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 WindTurbineInfoController {

  private final WindTurbineInfoService windTurbineInfoService;

  @Autowired
  public WindTurbineInfoController(WindTurbineInfoService windTurbineInfoService){
    this.windTurbineInfoService=windTurbineInfoService;
  }

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

  }

}
