package com.gyee.wisdom.dao.sql.pv_inverter;

import com.gyee.wisdom.common.data.DataUtil;
import com.gyee.wisdom.common.data.photovoltaic.Inverter;
import com.gyee.wisdom.dao.pv_inverter.IInverterDao;
import com.gyee.wisdom.dao.sql.pv_inverter.repsoitory.InverterRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @descrition:光伏逆变器
 * @author:WXW
 * @date:2020-04-29
 */
@Component
public class JpaInverterDao implements IInverterDao {

    @Autowired
    private InverterRepository inverterRepository;

    @Override
    public List<Inverter> findByStation(String station) {
        return DataUtil.convertDataList(inverterRepository.findByStation(station));
    }

    @Override
    public List<Inverter> findByLine(String line) {
        return DataUtil.convertDataList(inverterRepository.findByLine(line));
    }

    @Override
    public List<Inverter> findByProject(String project) {
        return DataUtil.convertDataList(inverterRepository.findByProject(project));
    }

    @Override
    public List<Inverter> findByModel(String model) {
        return DataUtil.convertDataList(inverterRepository.findByModel(model));
    }

    @Override
    public List<Inverter> findByStationAndModel(String station, String model) {
        return DataUtil.convertDataList(inverterRepository.findByStationAndModel(station,model));
    }

    @Override
    public Inverter findbyid(String id) {
        return inverterRepository.findById(id).get().toData();
    }

    @Override
    public List<Inverter> findAllInverter() {
        return DataUtil.convertDataList(inverterRepository.findAll());
    }


}
