package com.gyee.wisdom.dao.sql.alarm;
import com.gyee.wisdom.common.data.DataUtil;
import com.gyee.wisdom.common.data.alarm.Warningfj;
import com.gyee.wisdom.common.data.alarm.Warningsyz;
import com.gyee.wisdom.dao.alarm.WarningsyzDao;
import com.gyee.wisdom.dao.sql.alarm.Entity.WarningfjEntity;
import com.gyee.wisdom.dao.sql.alarm.Entity.WarningsyzEntity;
import com.gyee.wisdom.dao.sql.alarm.repository.WarningfjRepository;
import com.gyee.wisdom.dao.sql.alarm.repository.WarningsyzRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class JpaWarningsyzDao implements WarningsyzDao {
    @Autowired
    private WarningsyzRepository warningsyzRepository;
    @Override
    public List<Warningsyz> findAll() {
        List<Warningsyz> warning= DataUtil.convertDataList(warningsyzRepository.findAll());
        return warning;
    }

    @Override
    public Warningsyz findById(String id) {
        Warningsyz warningsyz=warningsyzRepository.findById(id).get().toData();
        return warningsyz;
    }

    @Override
    public void deletebyid(String id) {
        warningsyzRepository.deleteById(id);
    }


    @Override
    public void save(Warningsyz warning) {
        warningsyzRepository.save(new WarningsyzEntity(warning));
    }

    @Override
    public Warningsyz findByprojectId(String id) {
        return warningsyzRepository.findAllById(id).toData();
    }

    @Override
    public Warningsyz findByDescription(String description){
        return warningsyzRepository.findByDescription(description).toData();
    }
    @Override
    public Warningsyz findByPointkey(String id){
        return warningsyzRepository.findByPointkey(id).toData();
    }
}
