package com.tsiwebserver.controller;

import java.util.List;

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.pageService.PageClass;
import com.tsiwebserver.service.impl.HistoryServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;


@Controller
@Slf4j
@RequiredArgsConstructor
public class HistoryController {
	
	private final HistoryServiceImpl historyServiceImpl;
	
	@GetMapping("/history.do")
    public String history(Model model){
		model.addAttribute("menu","record");
		return "history";
    }
	// API접속일자별 조회
	@PostMapping("/api/searchDateRecodeInvoke.do")
	@ResponseBody
    public PageClass searchDateRecodeInvoke(String searchStartDate, String searchEndDate, String page){
		//log.info("searchDateRecodeInvoke = {}, {}, {}", serachCategory, searchStartDate, searchEndDate, page);
		log.info("searchStartDate {},searchEndDate {}, String page {}", searchStartDate, searchEndDate,page);
		return historyServiceImpl.searchDateRecodeInvoke(searchStartDate, searchEndDate, page);
		
    }
	// API사용자별 조회
    @PostMapping("/api/searchCustomerInvoke.do")
    @ResponseBody
    public PageClass searchCustomerInvoke(String userId, String page){
    	return historyServiceImpl.searchCustomerInvoke(userId, page);
    }

    // 시스템리소스 접속일자별 
    @PostMapping("/api/SystemResourceDateSearch.do")
	@ResponseBody
    public PageClass SystemResourceDateSearch(String searchStartDate, String searchEndDate, String page){
		log.info("SystemResourceDateSearch = {}, {}",searchStartDate, searchEndDate);
		return historyServiceImpl.SystemResourceDateSearch(searchStartDate, searchEndDate, page);
    }
    
    // 시스템리소스 사용자별 조회
    @PostMapping("/api/systemResourceUserSearch.do")
    @ResponseBody
    public PageClass systemResourceUserSearch(String userId, String page){
    	log.info("systemResourceUserSearch = {}, {}", userId, page);
    	return historyServiceImpl.systemResourceUserSearch(userId, page);
    	
    }
    
    //옵션세팅 api 사용자목록
  	@GetMapping("/api/setOptionApiUser.do")
  	@ResponseBody
  	public List<String> setOptionApiUser(){
  		return historyServiceImpl.setOptionApiUser();
  	}

	//옵션세팅 rusource 사용자목록 옵션세팅
  	@GetMapping("/api/setOptionResourceUser.do")
  	@ResponseBody
  	public List<String> setOptionResourceUser(){
  		return historyServiceImpl.setOptionResourceUser();
  	}

}
