package com.dbnt.faisp.config;

import com.dbnt.faisp.menuMgt.model.MenuMgt;
import com.dbnt.faisp.menuMgt.service.MenuMgtService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


@RestController
@RequiredArgsConstructor
@RequestMapping("/modal")
public class ModalController {

  private final MenuMgtService menuMgtService;

  @GetMapping("/menuModal")
  public ModelAndView menuModalPage(MenuMgt menuMgt){
    ModelAndView mav = new ModelAndView("commonModal/menuModal");
    menuMgt.setQueryInfo();
    mav.addObject("menuMgtList", menuMgtService.selectMenuMgtList(menuMgt));
    menuMgt.setContentCnt(menuMgtService.selectMenuMgtListCnt(menuMgt));
    menuMgt.setPaginationInfo();
    mav.addObject("searchParams", menuMgt);
    return mav;
  }

}
