From 3e8c6b20f536de7188830725a03e98cc5714bc73 Mon Sep 17 00:00:00 2001 From: 123 <123@qq.com> Date: Mon, 28 Apr 2025 08:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=90=8E=E5=8F=B0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/UserLoginController.java | 277 +++++++++--------- .../templates/admin/dashboard/index.html | 179 +++++------ 2 files changed, 228 insertions(+), 228 deletions(-) diff --git a/src/main/java/cc/iteachyou/cms/controller/admin/UserLoginController.java b/src/main/java/cc/iteachyou/cms/controller/admin/UserLoginController.java index 2a5c18a..b9192c6 100644 --- a/src/main/java/cc/iteachyou/cms/controller/admin/UserLoginController.java +++ b/src/main/java/cc/iteachyou/cms/controller/admin/UserLoginController.java @@ -1,27 +1,5 @@ package cc.iteachyou.cms.controller.admin; -import java.io.IOException; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authc.DisabledAccountException; -import org.apache.shiro.crypto.hash.SimpleHash; -import org.apache.shiro.util.ByteSource; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.ModelAndView; - -import com.wf.captcha.ArithmeticCaptcha; -import com.wf.captcha.utils.CaptchaUtil; - import cc.iteachyou.cms.annotation.Log; import cc.iteachyou.cms.annotation.Log.OperatorType; import cc.iteachyou.cms.common.BaseController; @@ -36,138 +14,157 @@ import cc.iteachyou.cms.security.token.TokenManager; import cc.iteachyou.cms.service.MenuService; import cn.hutool.crypto.asymmetric.KeyType; import cn.hutool.crypto.asymmetric.RSA; +import com.wf.captcha.ArithmeticCaptcha; +import com.wf.captcha.utils.CaptchaUtil; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.DisabledAccountException; +import org.apache.shiro.crypto.hash.SimpleHash; +import org.apache.shiro.util.ByteSource; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.ModelAndView; + +import java.io.IOException; +import java.util.List; /** * 用户登录相关,不需要做登录限制 - * */ @Slf4j @Controller @RequestMapping("/admin/u") public class UserLoginController extends BaseController { - @Autowired - private MenuService menuService; + @Autowired + private MenuService menuService; - // 产生验证码 - @RequestMapping("/getVerifyCode") - public void getKaptcha() throws IOException { - ArithmeticCaptcha captcha = new ArithmeticCaptcha(130, 48); + // 产生验证码 + @RequestMapping("/getVerifyCode") + public void getKaptcha() throws IOException { + ArithmeticCaptcha captcha = new ArithmeticCaptcha(130, 48); captcha.getArithmeticString(); // 获取运算的公式:3+2=? captcha.text(); // 获取运算的结果:5 - CaptchaUtil.out(captcha, request, response); - } + CaptchaUtil.out(captcha, request, response); + } - /** - * 登录跳转 - * - * @return - */ - @RequestMapping("toLogin") - public ModelAndView toLogin() { - ModelAndView mv = new ModelAndView(); - User user = (User) SecurityUtils.getSubject().getPrincipal(); - RSA rsa = new RSA(); - - session.setAttribute(Constant.RSA_PRIVATE_KEY, rsa.getPrivateKeyBase64()); - - mv.addObject("publicKey", rsa.getPublicKeyBase64()); - mv.setViewName("admin/login"); - return mv; - } - - /** - * 首页跳转 - * - * @return - */ - @RequestMapping("toIndex") - public ModelAndView toIndex() { - ModelAndView mv = new ModelAndView(); - String userId = TokenManager.getUserId(); - /** - * 查询当前用户所拥有的菜单权限 - */ - List