package com.jiayue.ipfcst.service;

import com.jiayue.ipfcst.common.data.entity.WindTowerInfo;
import com.jiayue.ipfcst.common.data.entity.WindTowerStatusData;
import com.jiayue.ipfcst.common.data.repository.WindTowerInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * 测风塔设备信息业务层
 *
 * @author yh
 * @version 1.0
 * @since 2019/8/5 16:02
 */
@Service
public class WindTowerInfoService {
    private final WindTowerInfoRepository windTowerInfoRepository;
    @Autowired
    public WindTowerInfoService( WindTowerInfoRepository windTowerInfoRepository){
        this.windTowerInfoRepository = windTowerInfoRepository;
    }
    /**
     * 根据ID排序查出所有 测风塔设备信息
     * yh
     */
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public List<WindTowerInfo> findAllByOrderByIdAsc(){
        return windTowerInfoRepository.findAllByOrderByIdAsc();
    }


  /**
   * 获取测风塔数据实体所有私有属性名称集合
   * @return 属性名称集合
   */
    public List<String> getWindTowerStatusDataAttributeName(){
      List<String> attributeName = new ArrayList<>();
      WindTowerStatusData windTowerStatusData = new WindTowerStatusData();
      Class  c  = windTowerStatusData.getClass();
      Field[] fs= c.getDeclaredFields();

      for(Field f :fs){
        attributeName.add(f.getName());
      }
        return attributeName;
    }


}
