package com.jiayue.ipfcst.controller;

import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipfcst.common.data.entity.InverterInfo;
import com.jiayue.ipfcst.service.InverterInfoService;
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 InverterInfoController {
  private final InverterInfoService inverterInfoService;
  @Autowired
  public InverterInfoController(InverterInfoService inverterInfoService){
    this.inverterInfoService = inverterInfoService;
  }

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


}
