package incheon.ags.mrb.chart.web;

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

@Controller
@RequestMapping("/ags/mrb/chart")
public class ChartViewController {

    private final static Logger logger = LoggerFactory.getLogger(ChartViewController.class);

    @GetMapping("/main.do")
    public String chartMain(Model model) {
        return "demo/chart/chartMain";
    }

    @GetMapping("/chart.do")
    public String chart(@RequestParam(value = "chartType", defaultValue = "barChart") String chartType, Model model) {
        // chartType에 따라 JSP 선택 (필요 시 추가 로직)
        String jspPath;
        switch (chartType) {
            case "barChart":
            case "lineChart":
            case "pieChart":
            case "histogram":
            case "boxplot":
                jspPath = "demo/chart/" + chartType;
                break;
            default:
                jspPath = "demo/chart/barChart"; // 기본값
        }
        return jspPath;
    }
}
