package com.ruoyi.system.service.impl;

import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.CensusItemNegativeInformation;
import com.ruoyi.system.mapper.CensusItemNegativeInformationMapper;
import com.ruoyi.system.service.ICensusItemNegativeInformationService;
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 CensusItemNegativeInformationServiceImpl implements ICensusItemNegativeInformationService {


    @Autowired
    private CensusItemNegativeInformationMapper censusItemNegativeInformationMapper;


    @Override
    public List<CensusItemNegativeInformation> selectCensusItemNegativeInformationList() {
        return censusItemNegativeInformationMapper.selectCensusItemNegativeInformationList();
    }

    @Override
    public void insertBatch(List<CensusItemNegativeInformation> list) {
        if (!CollectionUtils.isEmpty(list)) {
            censusItemNegativeInformationMapper.deleteCensusItemNegativeInformationAll();
        }
        censusItemNegativeInformationMapper.insertBatch(list);
        WebSocketUsers.sendMessageToUsersByText(JSON.toJSONString(success(AjaxResult.Type.TYPE_TWO,list)));
    }
}
