package com.citygis.web.service.impl;

import com.citygis.common.annotation.DataSource;
import com.citygis.common.core.domain.AjaxResult;
import com.citygis.common.enums.DataSourceType;
import com.citygis.web.mapper.LookMonitorMapper;
import com.citygis.web.service.LookMonitorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: zyl
 * @CreateTime: 2025-01-23
 * @Description: 监控可视化
 * @Version: 1.0
 */
@Service
@DataSource(DataSourceType.SLAVE)
public class LookMonitorServiceimpl implements LookMonitorService {

    @Resource
    LookMonitorMapper lookMonitorMapper;

    @Override
    public AjaxResult getLookMonitor() {

        // 获取今天的日期
        String today = String.valueOf(LocalDate.now());

        Map<String, Object> map = new HashMap<>();

        map.put("今日Api接入总量", lookMonitorMapper.getLookMonitorByUrl(today));
        map.put("库表接入总量", lookMonitorMapper.getLookMonitorByKb(today));
        map.put("KafkaTopic总量", lookMonitorMapper.getLookMonitorByKafka(today));
        map.put("四个框", lookMonitorMapper.getUrlMsg(today));

        return AjaxResult.success(map);
    }

    @Override
    public AjaxResult getLookMonitorByUrlAndStatus() {
        return AjaxResult.success(lookMonitorMapper.getLookMonitorByUrlAndStatus(String.valueOf(LocalDate.now())));
    }
}
