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

import org.springframework.format.annotation.DateTimeFormat;
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 org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDate;
import java.util.Map;

@Controller
public class PortalStatisticsDailyAppTableManController {

    private final PortalStatisticsDailyAppTableManService portalStatisticsDailyAppTableManService;

    public PortalStatisticsDailyAppTableManController(PortalStatisticsDailyAppTableManService portalStatisticsDailyAppTableManService) {
        this.portalStatisticsDailyAppTableManService = portalStatisticsDailyAppTableManService;
    }

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

    @PostMapping(value = "/onl/apim/portalstatistics/portalStatisticsDailyAppTableMan.json", params = "cmd=LIST")
    public ResponseEntity<Map<String, Object>> selectStatisticsList(
            @RequestParam @DateTimeFormat(pattern = "yyyyMMdd") LocalDate startDate,
            @RequestParam @DateTimeFormat(pattern = "yyyyMMdd") LocalDate endDate) {

        Map<String, Object> result = portalStatisticsDailyAppTableManService.selectStatisticsList(startDate, endDate);
        return ResponseEntity.ok(result);
    }
}