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

import com.gyee.wisdom.common.data.DataUtil;
import com.gyee.wisdom.common.data.power.Status8Snap;
import com.gyee.wisdom.common.data.power.WindturbinePowerCurvefitting;
import com.gyee.wisdom.dao.power.IStatus8SnapDao;
import com.gyee.wisdom.dao.power.IWindturbinePowerCurvefittingDao;
import com.gyee.wisdom.dao.sql.power.entity.Status8SnapEntity;
import com.gyee.wisdom.dao.sql.power.repository.Status8SnapRepository;
import com.gyee.wisdom.dao.sql.power.repository.WindturbinePowerCurvefittingRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

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


@Component
public class JpaStatus8SnapDao implements IStatus8SnapDao {

    @Autowired
    private Status8SnapRepository status8SnapRepository;

    @Override
    public List<Status8Snap> findAll() {
        //return null;
        return DataUtil.convertDataList(status8SnapRepository.findAll());
    }

    @Override
    public void save(List<Status8Snap> lstSS) {

        if (lstSS != null && lstSS.size() > 0) {
            List<Status8SnapEntity> result = new ArrayList<>();
            for(Status8Snap ss: lstSS) {
                result.add(new Status8SnapEntity(ss));
            }

            status8SnapRepository.saveAll(result);
        }

    }

}
