From 62774e3ec9a334dcff82bf63b90ec067b06fc305 Mon Sep 17 00:00:00 2001 From: czt <czt18638530771@163.com> Date: 星期二, 25 三月 2025 16:37:43 +0800 Subject: [PATCH] 优化质检信息同步 --- src/main/java/com/fzzy/web/LoginController.java | 63 ++++++++++++++++++++++++++----- 1 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/fzzy/web/LoginController.java b/src/main/java/com/fzzy/web/LoginController.java index 7ccbb6a..09be401 100644 --- a/src/main/java/com/fzzy/web/LoginController.java +++ b/src/main/java/com/fzzy/web/LoginController.java @@ -1,16 +1,16 @@ package com.fzzy.web; +import com.fzzy.sys.LogLoginService; +import com.fzzy.sys.UserPR; +import com.fzzy.sys.entity.SysUser; import com.wf.captcha.ArithmeticCaptcha; import com.wf.captcha.utils.CaptchaUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -25,6 +25,11 @@ @RequestMapping public class LoginController { + @Autowired + private UserPR userPR; + @Autowired + private LogLoginService logLoginService; + /** * 鐧诲綍楠岃瘉鍏ュ彛 * @@ -33,7 +38,7 @@ * @param captcha * @return */ - @PostMapping("/login-check") + @GetMapping("/login-check") public String login(HttpServletRequest request, @RequestParam(name = "username_") String username, @RequestParam(name = "password_") String password, @@ -42,9 +47,42 @@ if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) { return "redirect:/login?tag=01&username=" + username; } + if (StringUtils.isEmpty(captcha)) { + return "redirect:/login?tag=02&username=" + username; + } + //鏍¢獙楠岃瘉鐮� boolean validateCode = CaptchaUtil.ver(captcha, request); - log.info("-----------楠岃瘉鐮�-----------{}", validateCode); + if (!validateCode) { + return "redirect:/login?tag=04&username=" + username; + } + + //鍒ゆ柇闄愬埗鐧婚檰 + int num = logLoginService.checkLoginLimit(request, username); + if (num >= 3) { + return "redirect:/login?tag=11&username=" + username; + } + + SysUser user = userPR.listById(username); + if (null == user) { + num = logLoginService.addNoUser(request, username); + if (num >= 3) { + return "redirect:/login?tag=12&username=" + username; + } + return "redirect:/login?tag=05&username=" + username; + } + + boolean tag = userPR.checkPassword(password, user); + if (!tag){ + num = logLoginService.addPwdError(request, user); + if (num >= 3) { + return "redirect:/login?tag=11&username=" + username; + } + return "redirect:/login?tag=06&username=" + username; + } + request.getSession().setAttribute("user", user); + //澧炲姞鐧诲綍鏃ュ織 + logLoginService.addLoginInfo(request, user); return "redirect:/home"; } @@ -84,6 +122,12 @@ if ("10".equals(tag)) { tag = "鎮ㄧ殑璐﹀彿鍦ㄥ叾浠栧湴鏂圭櫥褰曪紝琚揩涓嬬嚎"; } + if ("11".equals(tag)) { + tag = "杩炵画3娆¢敊璇紝闄愬埗鐧婚檰60鍒嗛挓"; + } + if ("12".equals(tag)) { + tag = "杩炵画3娆¤緭鍏ヤ笉瀛樺湪璐﹀彿锛岄檺鍒剁櫥闄�60鍒嗛挓"; + } view.addObject("TAG", tag); view.addObject("USERNAME", username); } @@ -101,8 +145,6 @@ public void captcha(HttpServletResponse response, HttpServletRequest request) { //璁剧疆闀垮 try { - //鐢熸垚鏅�氶獙璇佺爜 - // SpecCaptcha specCaptcha = new SpecCaptcha(); //鐢熸垚绠楁暟楠岃瘉鐮� ArithmeticCaptcha arithmeticCaptcha = new ArithmeticCaptcha(); //璁剧疆2涓虹畻鏁� @@ -125,7 +167,8 @@ * @return */ @RequestMapping("/log-out") - public String logOut() { + public String logOut(HttpServletRequest request) { + request.getSession().removeAttribute("user"); return "redirect:/login"; } -- Gitblit v1.9.3