From 447c6f6eadd1363a6575cbcbc1298f9d8cefdef2 Mon Sep 17 00:00:00 2001
From: ws <ws@123.com>
Date: 星期一, 25 十一月 2024 09:53:54 +0800
Subject: [PATCH] 调整-上海对农接口

---
 src/main/java/com/fzzy/web/LoginController.java |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 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..7edaff0 100644
--- a/src/main/java/com/fzzy/web/LoginController.java
+++ b/src/main/java/com/fzzy/web/LoginController.java
@@ -1,16 +1,15 @@
 package com.fzzy.web;
 
+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 +24,9 @@
 @RequestMapping
 public class LoginController {
 
+    @Autowired
+    private UserPR userPR;
+
     /**
      * 鐧诲綍楠岃瘉鍏ュ彛
      *
@@ -33,7 +35,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 +44,26 @@
         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;
+        }
+
+        SysUser user = userPR.listById(username);
+        if (null == user) {
+            return "redirect:/login?tag=05&username=" + username;
+        }
+
+        boolean tag = userPR.checkPassword(password, user);
+        if (!tag){
+            return "redirect:/login?tag=06&username=" + username;
+        }
+        request.getSession().setAttribute("user", user);
 
         return "redirect:/home";
     }
@@ -101,8 +120,6 @@
     public void captcha(HttpServletResponse response, HttpServletRequest request) {
         //璁剧疆闀垮
         try {
-            //鐢熸垚鏅�氶獙璇佺爜
-            // SpecCaptcha specCaptcha = new SpecCaptcha();
             //鐢熸垚绠楁暟楠岃瘉鐮�
             ArithmeticCaptcha arithmeticCaptcha = new ArithmeticCaptcha();
             //璁剧疆2涓虹畻鏁�
@@ -125,7 +142,8 @@
      * @return
      */
     @RequestMapping("/log-out")
-    public String logOut() {
+    public String logOut(HttpServletRequest request) {
+        request.getSession().removeAttribute("user");
         return "redirect:/login";
     }
 

--
Gitblit v1.9.3