package com.dbnt.sims.config;

import com.dbnt.sims.menuMgt.model.MenuMgt;
import com.dbnt.sims.menuMgt.service.MenuMgtService;
import com.dbnt.sims.userInfo.model.UserInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
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(@AuthenticationPrincipal UserInfo loginUser, MenuMgt menuMgt){
    ModelAndView mav = new ModelAndView("commonModal/menuModal");
    menuMgt.setUserSeq(loginUser.getUserSeq());
    menuMgt.setQueryInfo();
    mav.addObject("menuMgtList", menuMgtService.selectMenuMgtListToAccessAuth(menuMgt));
    menuMgt.setContentCnt(menuMgtService.selectMenuMgtListToAccessAuthCnt(menuMgt));
    menuMgt.setPaginationInfo();
    mav.addObject("searchParams", menuMgt);
    return mav;
  }

}
