package com.eactive.eai.rms.common.interceptor;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.eactive.eai.rms.common.acl.menu.MenuManService;

public class MenuInterceptor extends HandlerInterceptorAdapter {

	@Autowired
	private MenuManService service;

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {

		if (request.getServletPath().endsWith(".view")) {

			String menuPath = service.getPosition(request);
			String menuName = service.getMenuName(request);
			String menuAuth = service.getMenuAuth(request);
			request.setAttribute("rmsMenuPath", menuPath);
			request.setAttribute("rmsMenuAuth", menuAuth);
			request.setAttribute("rmsMenuName", menuName);
			request.setAttribute("rmsDefaultRowNum", "20");
			request.setAttribute("rmsDefaultRowList", "10,20,30");

		}
		return true;
	}

}
