package com.eactive.eai.rms.onl.apim.portalstatistics;

import com.eactive.eai.rms.common.base.BaseAnnotationController;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

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

@Controller
public class PortalStatisticsDailyManController extends BaseAnnotationController {

	private final PortalStatisticsDailyManService portalStatisticsDailyManService;
	private final ComboService comboService;

	public PortalStatisticsDailyManController(PortalStatisticsDailyManService portalStatisticsDailyManService,
											  ComboService comboService) {
		this.portalStatisticsDailyManService = portalStatisticsDailyManService;
		this.comboService = comboService;
	}

	@GetMapping(value = "/onl/apim/portalstatistics/portalStatisticsDailyMan.view")
	public void view() {
		// view
	}

	@PostMapping(value = "/onl/apim/portalstatistics/portalStatisticsDailyMan.json", params = "cmd=LIST")
	public ResponseEntity<Map<String, List<PortalStatisticsDailyUI>>> selecStatisticsList(PortalStatisticsUI portalStatisticsUI)  {
		Map<String, List<PortalStatisticsDailyUI>> portalStatisticsDailyUI = portalStatisticsDailyManService.selectStatisticsList(portalStatisticsUI);
		return ResponseEntity.ok(portalStatisticsDailyUI);
	}

	@PostMapping(value = "/onl/apim/portalstatistics/portalStatisticsDailyMan.json", params = "cmd=LIST_INIT_COMBO")
	public ResponseEntity<Map<String, Object>> initCombo() {
		List<ComboVo> orgList = comboService.getFromPortalOrgName();
//		List<ComboVo> appList = comboService.getFromAppName();
//		List<ComboVo> apiList = comboService.getFromApiName();

		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("orgList", orgList);
//		resultMap.put("appList", appList);
//		resultMap.put("apiList", apiList);
		return ResponseEntity.ok(resultMap);
	}
}
