package com.madeu.controller.web.webcontentsboard;

import com.madeu.service.web.webcontentsboard.WebContentsBoardService;
import com.madeu.common.service.LogHistoryService;
import com.madeu.util.HttpUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;

@Slf4j
@Controller
public class WebContentsBoardController {

    @Autowired
    private WebContentsBoardService webContentsBoardService;

    @Autowired
	private LogHistoryService logHistoryService;

    /**
     * 1:1 문의 리스트 화면으로 이동.
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="/webcontentsboard/selectListContentsBoardIntro.do")
    public String  selectListContentsBoardIntro(HttpSession session, HttpServletRequest request, HttpServletResponse response, Model model) {
        log.debug("WebContentsBoardController  selectListContentsBoardIntro START");

        HashMap<String, Object> paramMap = HttpUtil.getParameterMap(request);
        HashMap<String, Object> map = new HashMap<String, Object>();

        try{
            paramMap.put("loginMemberId", String.valueOf(session.getAttribute("loginMemberId")));
            map = webContentsBoardService.selectListContentsBoardIntro(paramMap);

            model.addAttribute("selectUseYn", map.get("selectUseYn"));
            model.addAttribute("insertUseYn", map.get("insertUseYn"));
            model.addAttribute("updateUseYn", map.get("updateUseYn"));
            model.addAttribute("deleteUseYn", map.get("deleteUseYn"));
            model.addAttribute("downloadUseYn", map.get("downloadUseYn"));
        }
        catch (Exception e) {
            e.printStackTrace();
            return "/web/login/logout";
        }
        log.debug("WebContentsBoardController  selectListContentsBoardIntro END");
        return "/web/appcontentsboard/contentsBoardSelectList";
    }
}

