package com.backendsys.modules.common.utils.views;


import cn.hutool.core.date.DateUtil;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.ui.Model;

import java.util.List;
import java.util.Map;

public class MvcUtil {

    // 初始化 Request
    public static MvcRequest getRequestVO (HttpServletRequest request) {
        MvcRequest req = new MvcRequest();
        req.setUri(request.getRequestURI());
        req.setQueryString(request.getQueryString());
        req.setTimestamp(DateUtil.current());
        return req;
    }

//    // 初始化公共事件
//    public static void initResponse (Model model, HttpServletRequest request,
////         CmsSiteInfoService cmsSiteInfoService, CmsNavigationService cmsNavigationService) {
////        // -- Request (uri, timestamp) ---------------------------
////        model.addAttribute(getRequestVO(request));
////        // -- Language -------------------------------------------
////        String lang = CookieUtil.getCookie("lang", request);
////        lang = (lang != null ? lang : (String) request.getAttribute("lang"));
////        model.addAttribute("lang", lang);
////
////        // -- 初始化 网站信息 ---------------------------------------
////        model.addAttribute("siteInfo", cmsSiteInfoService.querySiteInfo());
////
////        // -- 初始化 导航信息 ---------------------------------------
////        CmsNavigationDTO cmsNavigationDTO = new CmsNavigationDTO();
////        cmsNavigationDTO.setLang((String) model.getAttribute("lang"));
////        List<Map<String, Object>> navigation = cmsNavigationService.queryNavigationPublic(cmsNavigationDTO);
////        List<Map<String, Object>> navigationTree = TreeUtil.buildTree(navigation);
////        model.addAttribute("navigation", navigationTree);
//    }

}
