package com.xtd.project.hkmanager.service.impl;

import com.xtd.project.hkmanager.entity.Alarm;
import com.xtd.project.hkmanager.entity.AlarmForm;
import com.xtd.project.hkmanager.mapper.AlarmMapper;
import com.xtd.project.hkmanager.service.AlarmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @author lym
 * @date 2020/4/14 10:02
 */
@Service
public class AlarmServiceImpl implements AlarmService {

    @Autowired
    AlarmMapper alarmMapper;

    @Override
    public int delByPrimaryKey(String guid) {
        return 0;
    }

    @Override
    public int save(Alarm record) {
        return 0;
    }

    @Override
    public int saveSelective(Alarm record) {
        return 0;
    }

    @Override
    public Alarm queryByPrimaryKey(String guid) {
        return null;
    }

    @Override
    public int modifyByPrimaryKeySelective(Alarm record) {
        return alarmMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int modifyByPrimaryKeyWithBLOBs(Alarm record) {
        return 0;
    }

    @Override
    public int modifyByPrimaryKey(Alarm record) {
        return 0;
    }

    @Override
    public int batchSave(Map<String, Alarm> map) {
        List<String> ids = alarmMapper.findIds();
        for (String id:ids){
            map.remove(id);
        }

        int i = 0;
        if (map.size() > 0){
            Collection<Alarm> values = map.values();
            List<Alarm> list = new ArrayList<>(values);
            i = alarmMapper.batchSave(list);
        }
        return i;
    }

    @Override
    public List<Alarm> selectList(AlarmForm alarmForm) {
        return alarmMapper.selectList(alarmForm);
    }
}
