package egovframework.controller;

import egovframework.service.impl.CommonServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RequiredArgsConstructor
@Controller
public class TrafficController {

    private final CommonServiceImpl commonService;

    @RequestMapping(value = "/traffic/cctv.do", method = RequestMethod.GET)
    public String cctv(Model model) {
        model.addAttribute("subTitle", "CCTV");
        return "traffic/cctvNew.tiles";
    }

//    @RequestMapping(value = "/traffic/popupCctv.do", method = RequestMethod.GET)
//    public ModelAndView popupCctv(Model model, @RequestParam Map<String, Object> paramMap) {
//        String cctv_nmbr = paramMap.get("cctv_mngm_nmbr").toString();
//        System.out.println("gg");
//        return new ModelAndView("traffic/cctvPopup.empty", "cctv", this.commonService.getOneCctvCtlr(cctv_nmbr));
//    }
//
//    @RequestMapping(value = "/traffic/popupCctvM.do", method = RequestMethod.GET)
//    public ModelAndView popupCctvM(Model model, @RequestParam Map<String, Object> paramMap, HttpServletRequest req) {
//        String cctv_nmbr = paramMap.get("cctv_mngm_nmbr").toString();
//        System.out.println("gg");
//        return new ModelAndView("traffic/cctvPopupM.empty", "cctv", this.commonService.getOneCctvCtlr(cctv_nmbr));
//    }

    @RequestMapping(value = "/traffic/popupCctv.do", method = RequestMethod.GET)
    public String popupCctv(Model model, @RequestParam Map<String, Object> paramMap, HttpServletResponse response) {
        String cctv_nmbr = paramMap.get("cctv_mngm_nmbr").toString();
        model.addAttribute("cctv", this.commonService.getOneCctvCtlr(cctv_nmbr));
        model.addAttribute("subTitle", "CCTV 영상");
        return "traffic/cctvPopup";
    }

    @RequestMapping(value = "/traffic/popupCctvM.do", method = RequestMethod.GET)
    public String popupCctvM(Model model, @RequestParam Map<String, Object> paramMap, HttpServletResponse response) {
        String cctv_nmbr = paramMap.get("cctv_mngm_nmbr").toString();
        model.addAttribute("cctv", this.commonService.getOneCctvCtlr(cctv_nmbr));
        return "traffic/cctvPopupM";
    }

    @RequestMapping(value = "/traffic/vms.do", method = RequestMethod.GET)
    public String vms(Model model) {
        model.addAttribute("subTitle", "VMS");
        return "traffic/vmsNew.tiles";
    }

    @RequestMapping(value = "/traffic/incd.do", method = RequestMethod.GET)
    public String incd(Model model) {
        model.addAttribute("subTitle", "돌발 정보");
        return "traffic/incdNew.tiles";
    }

    @RequestMapping(value = "/traffic/realtime.do", method = RequestMethod.GET)
    public String realtime(Model model) {
        model.addAttribute("atrdNmList", this.commonService.getAtrdNm());
        model.addAttribute("subTitle", "소통정보");
        return "traffic/realtimeNew.tiles";
    }

}