package com.tsiwebserver.controller;

import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.tsiwebserver.service.impl.StatisticsServiceImpl;

import lombok.RequiredArgsConstructor;

@Controller
@RequiredArgsConstructor
public class StatisticsController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	private final StatisticsServiceImpl statisticsServiceImpl;
	
	
	@GetMapping("/statistics.do")
	public String showStatistics(Model model) {
		model.addAttribute("menu","statistics");
		return "statistics";
	}
	
	// API 월별조회yy
	@PostMapping("/api/getMonthlyInvokeTableData.do")
	@ResponseBody
	public List<HashMap<String, Object>> getMonthInvokeTableData(String start, String end) {
//		logger.info(start);
//		logger.info(end);
		List<HashMap<String, Object>> list=statisticsServiceImpl.getSearchMonthlyInvoke(start, end);
//		logger.info(list.toString());
		return list;
	} 
	//API 일별조회
	@PostMapping("/api/getDailyInvokeTableData.do")
	@ResponseBody
	public List<HashMap<String, Object>> getDailyInvokeTableData(String start, String end) {
//		logger.info(start);
//		logger.info(end);
		List<HashMap<String, Object>> list=statisticsServiceImpl.getSearchDailyInvoke(start, end);
//		logger.info(list.toString());
		return list;
	}
	
	// SystemResource 월별조회
	@PostMapping("/api/systemResourceMonthlyData.do")
	@ResponseBody
	public List<HashMap<String, Object>> systemResourceMonthlyData(String start, String end) {
//		logger.info("controller start값 = "+start);
//		logger.info("controller end값 = " + end);
		List<HashMap<String, Object>> list=statisticsServiceImpl.systemResourceMonthlyData(start, end);
//		logger.info(list.toString());
		return list;
		
	}
	//SystemResource 일별조회
	@PostMapping("/api/systemResourceDailyData.do")
	@ResponseBody
	public List<HashMap<String, Object>> systemResourceDailyData(String start, String end) {
//		logger.info(start);
//		logger.info(end);
		List<HashMap<String, Object>> list=statisticsServiceImpl.systemResourceDailyData(start, end);
//		logger.info(list.toString());
		return list;
	}
		
	// signalStatusGather 월별조회
	@PostMapping("/api/signalStatusGatherMonthlyData.do")
	@ResponseBody
	public List<HashMap<String, Object>> signalStatusMonthlyData(String start, String end) {
//		logger.info("controller start값 = "+start);
//		logger.info("controller end값 = " + end);
		List<HashMap<String, Object>> list = statisticsServiceImpl.signalStatusGatherMonthlyData(start, end);
//		logger.info("result : {}", list.toString());
		return list;
	}
	// signalStatusGather 일별조회
		@PostMapping("/api/signalStatusGatherDailyData.do")
		@ResponseBody
		public List<HashMap<String, Object>> signalStatusGatherDailyData(String start, String end) {
//			logger.info(start);
//			logger.info(end);
			List<HashMap<String, Object>> list=statisticsServiceImpl.signalStatusGatherDailyData(start, end);
//			logger.info(list.toString());
			return list;
		}
		
	
		// signalStatusSend 월별조회
		@PostMapping("/api/signalStatusSendMonthlyData.do")
		@ResponseBody
		public List<HashMap<String, Object>> signalStatusSendMonthlyData(String start, String end) {
//			logger.info("controller start값 = "+start);
//			logger.info("controller end값 = " + end);
			List<HashMap<String, Object>> list=statisticsServiceImpl.signalStatusSendMonthlyData(start, end);
//			logger.info(list.toString());
			return list;
		}
		// signalStatusSend 일별조회
			@PostMapping("/api/signalStatusSendDailyData.do")
			@ResponseBody
			public List<HashMap<String, Object>> signalStatusSendDailyData(String start, String end) {
//				logger.info(start);
//				logger.info(end);
				List<HashMap<String, Object>> list=statisticsServiceImpl.signalStatusSendDailyData(start, end);
//				logger.info(list.toString());
				return list;
			}
}
