package com.ruoyi.system.service.impl;

import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.CountyAndDistrictMisprint;
import com.ruoyi.system.domain.MunicipalErrorLinkMonitor;
import com.ruoyi.system.mapper.CountyAndDistrictMisprintMapper;
import com.ruoyi.system.mapper.MunicipalErrorLinkMonitorMapper;
import com.ruoyi.system.service.ICountyAndDistrictMisprintService;
import com.ruoyi.system.service.IMunicipalErrorLinkMonitorService;
import com.ruoyi.websocket.WebSocketUsers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static com.ruoyi.common.core.domain.AjaxResult.success;


@Service
public class MunicipalErrorLinkMonitorServiceImpl implements IMunicipalErrorLinkMonitorService {


    @Autowired
    private MunicipalErrorLinkMonitorMapper municipalErrorLinkMonitorMapper;


    @Override
    public List<MunicipalErrorLinkMonitor> selectMunicipalErrorLinkMonitorList() {
        return municipalErrorLinkMonitorMapper.selectMunicipalErrorLinkMonitorList();
    }

    @Override
    public void insertBatch(List<MunicipalErrorLinkMonitor> list) {
        if (!CollectionUtils.isEmpty(list)) {
            municipalErrorLinkMonitorMapper.deleteMunicipalErrorLinkMonitorAll();
        }
        municipalErrorLinkMonitorMapper.insertBatch(list);
        WebSocketUsers.sendMessageToUsersByText(JSON.toJSONString(success(AjaxResult.Type.TYPE_TEN,list)));
//        WebSocketUsers.sendMessageToUsersByText(JSON.toJSONString(success((AjaxResult.Type.TYPE_TEN,list)));
    }
}
