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.MunicipalMisprint;
import com.ruoyi.system.mapper.CountyAndDistrictMisprintMapper;
import com.ruoyi.system.mapper.MunicipalMisprintMapper;
import com.ruoyi.system.service.ICountyAndDistrictMisprintService;
import com.ruoyi.system.service.IMunicipalMisprintService;
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 CountyAndDistrictMisprintServiceImpl implements ICountyAndDistrictMisprintService {


    @Autowired
    private CountyAndDistrictMisprintMapper countyAndDistrictMisprintMapper;


    @Override
    public List<CountyAndDistrictMisprint> selectCountyAndDistrictMisprintList() {
        return countyAndDistrictMisprintMapper.selectCountyAndDistrictMisprintList();
    }

    @Override
    public void insertBatch(List<CountyAndDistrictMisprint> list) {
        if (!CollectionUtils.isEmpty(list)) {
            countyAndDistrictMisprintMapper.deleteCountyAndDistrictMisprintAll();
        }
        countyAndDistrictMisprintMapper.insertBatch(list);
        WebSocketUsers.sendMessageToUsersByText(JSON.toJSONString(success(AjaxResult.Type.TYPE_TWELVE,list)));

    }
}
