package com.qmth.qrzk.web.controller;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/menu")
public class MenuController implements Serializable {

    private static final long serialVersionUID = 1L;

    @RequestMapping(value = "/changeMenu", method = RequestMethod.GET)
    public ModelAndView saveHeaderMenu(HttpServletRequest request, HttpServletResponse response) {
        String headMenu = request.getParameter("headMenu");
        String subMenu = request.getParameter("subMenu");
        String url = request.getParameter("url");
        request.getSession().setAttribute("headMenu", headMenu);
        request.getSession().setAttribute("subMenu", subMenu);
        return new ModelAndView("redirect:" + url);
    }

    @RequestMapping(value = "/saveimportmenu", method = RequestMethod.GET)
    public ModelAndView saveImportMenu(HttpServletRequest request, HttpServletResponse response) {
        String importMenu = request.getParameter("importMenu");
        String url = request.getParameter("url");
        request.getSession().setAttribute("importMenu", importMenu);
        return new ModelAndView("redirect:" + url);
    }

    @RequestMapping(value = "/saveusermenu", method = RequestMethod.GET)
    public ModelAndView saveUserMenu(HttpServletRequest request, HttpServletResponse response) {
        String userMenu = request.getParameter("userMenu");
        String url = request.getParameter("url");
        request.getSession().setAttribute("userMenu", userMenu);
        return new ModelAndView("redirect:" + url);
    }

    @RequestMapping(value = "/savequestionmenu", method = RequestMethod.GET)
    public ModelAndView saveQuestionMenu(HttpServletRequest request, HttpServletResponse response) {
        String questionMenu = request.getParameter("questionMenu");
        String url = request.getParameter("url");
        request.getSession().setAttribute("questionMenu", questionMenu);
        return new ModelAndView("redirect:" + url);
    }
}
