package com.ruoyi.system.service.impl;

import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.UnableToAccessWebsiteListToday;
import com.ruoyi.system.domain.WebSiteTenDaysHits;
import com.ruoyi.system.domain.WebsiteAvailabilityMonitor;
import com.ruoyi.system.mapper.UnableToAccessWebsiteListTodayMapper;
import com.ruoyi.system.mapper.WebSiteTenDaysHitsMapper;
import com.ruoyi.system.service.IUnableToAccessWebsiteListTodayService;
import com.ruoyi.system.service.IWebSiteTenDaysHitsService;
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.HashMap;
import java.util.List;
import java.util.Map;

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


@Service
public class UnableToAccessWebsiteListTodayImpl implements IUnableToAccessWebsiteListTodayService {


    @Autowired
    private UnableToAccessWebsiteListTodayMapper unableToAccessWebsiteListTodayMapper;


    @Override
    public List<UnableToAccessWebsiteListToday> selectUnableToAccessWebsiteListTodayList() {
        return unableToAccessWebsiteListTodayMapper.selectUnableToAccessWebsiteListTodayList();
    }

    @Override
    public void insertBatch(List<UnableToAccessWebsiteListToday> list) {
        if (!CollectionUtils.isEmpty(list)) {
            unableToAccessWebsiteListTodayMapper.deleteUnableToAccessWebsiteListTodayAll();
        }
        unableToAccessWebsiteListTodayMapper.insertBatch(list);
        WebSocketUsers.sendMessageToUsersByText(JSON.toJSONString(success(AjaxResult.Type.TYPE_FIFTEEN,list)));
    }
}
