From fe35e2ed6a59911748ab772162a32e245b77c130 Mon Sep 17 00:00:00 2001 From: pk9tv8hgp <1215904376@qq.com> Date: Mon, 24 Apr 2023 13:10:06 +0800 Subject: [PATCH] Add BaseController --- BaseController | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 BaseController diff --git a/BaseController b/BaseController new file mode 100644 index 0000000..1580024 --- /dev/null +++ b/BaseController @@ -0,0 +1,21 @@ +package com.controller.admin; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; + +import com.exception.AdminLoginNoException; +@Controller +public class BaseController { + /** + * 登录权限控制,处理方法执行前执行该方法 + * @throws AdminLoginNoException + */ + @ModelAttribute + public void isLogin(HttpSession session, HttpServletRequest request) throws AdminLoginNoException { + if(session.getAttribute("auser") == null){ + throw new AdminLoginNoException("没有登录"); + } + } +} \ No newline at end of file