From e15f561a1f9eddfde503d59baf45a860b131928e Mon Sep 17 00:00:00 2001
From: fei.wang <wf18701153496@163.com>
Date: 星期三, 13 八月 2025 14:22:50 +0800
Subject: [PATCH] 更新最新版代码

---
 src/main/java/com/flow/controller/LoginController.java |   87 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 77 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/flow/controller/LoginController.java b/src/main/java/com/flow/controller/LoginController.java
index d1bf674..cac15bb 100644
--- a/src/main/java/com/flow/controller/LoginController.java
+++ b/src/main/java/com/flow/controller/LoginController.java
@@ -9,6 +9,7 @@
 import com.flow.pojo.Loginjilu;
 import com.flow.service.CompanyService;
 import com.flow.service.LoginJiLuService;
+import com.flow.service.LoginFailRecordService;
 import com.flow.util.DESUtil;
 import com.flow.util.IpUtil;
 import com.flow.util.result;
@@ -21,12 +22,14 @@
 import com.tencentcloudapi.sms.v20210111.SmsClient;
 import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
 import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+
 import java.io.IOException;
 import java.util.List;
 import java.util.Random;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -44,6 +47,8 @@
     LoginJiLuService loginJiLuService;
     @Autowired
     CompanyService companyService;
+    @Autowired
+    LoginFailRecordService loginFailRecordService;
 
     public LoginController() {
     }
@@ -52,19 +57,19 @@
     public result<List<Loginjilu>> FindCard(Integer page, Integer limit) throws Exception {
         PageInfo<Loginjilu> cz = this.loginJiLuService.FindLoginJiLu(page, limit);
 
-        for(int i = 0; i < cz.getSize(); ++i) {
-            ((Loginjilu)cz.getList().get(i)).setLoginphone(DESUtil.decrypt(((Loginjilu)cz.getList().get(i)).getLoginphone(), DESUtil.key));
+        for (int i = 0; i < cz.getSize(); ++i) {
+            ((Loginjilu) cz.getList().get(i)).setLoginphone(DESUtil.decrypt(((Loginjilu) cz.getList().get(i)).getLoginphone(), DESUtil.key));
         }
 
         return resultutil.returnSuccess(cz.getTotal(), cz.getList());
     }
 
-    @GetMapping({"FindLoginJiLuZi"})
-    public result<List<Loginjilu>> FindCardZi(String Zong, Integer page, Integer limit) throws Exception {
-        PageInfo<Loginjilu> cz = this.loginJiLuService.FindLoginJiLuZi(Zong, page, limit);
+    @PostMapping({"FindLoginJiLuZi"})
+    public result<List<Loginjilu>> FindCardZi(Loginjilu loginjilu, Integer page, Integer limit) throws Exception {
+        PageInfo<Loginjilu> cz = this.loginJiLuService.FindLoginJiLuZi(loginjilu, page, limit);
 
-        for(int i = 0; i < cz.getSize(); ++i) {
-            ((Loginjilu)cz.getList().get(i)).setLoginphone(DESUtil.decrypt(((Loginjilu)cz.getList().get(i)).getLoginphone(), DESUtil.key));
+        for (int i = 0; i < cz.getSize(); ++i) {
+            ((Loginjilu) cz.getList().get(i)).setLoginphone(DESUtil.decrypt(((Loginjilu) cz.getList().get(i)).getLoginphone(), DESUtil.key));
         }
 
         return resultutil.returnSuccess(cz.getTotal(), cz.getList());
@@ -74,9 +79,10 @@
     @ResponseBody
     public Company Login(Company company, HttpSession session) throws Exception {
         company.setCompanyabbname(company.getCompanyabbname());
-        company.setLoginphone(DESUtil.encrypt(company.getLoginphone(), DESUtil.key));
-        if (company.getPassword()!=null){
-            company.setPassword(DESUtil.encrypt(company.getPassword(), DESUtil.key));
+
+//        company.setLoginphone(DESUtil.encrypt(company.getLoginphone(), DESUtil.key));
+        if (company.getPassword() != null) {
+            company.setPassword(company.getPassword());
         }
         Company company1 = this.companyService.findUser(company);
         if (company1 != null) {
@@ -124,6 +130,39 @@
         return this.loginJiLuService.upuserdate(Zong, userdate);
     }
 
+    @PostMapping({"accountLogin"})
+    @ResponseBody
+    public Company accountLogin(String account, String password, HttpSession session) throws Exception {
+        if (account == null || password == null) {
+            return null;
+        }
+        
+        // 妫�鏌ヨ处鍙锋槸鍚﹁閿佸畾
+        if (loginFailRecordService.isAccountLocked(account)) {
+            // 璐﹀彿琚攣瀹氾紝杩斿洖鐗规畩鏍囪瘑
+            Company lockedCompany = new Company();
+            lockedCompany.setCompanyabbname("LOCKED");
+            return lockedCompany;
+        }
+        
+        // 鏋勯�燙ompany瀵硅薄锛屽亣璁綼ccount涓哄叕鍙哥畝绉版垨鐧诲綍璐﹀彿瀛楁
+        Company company = new Company();
+        company.setLoginphone(account);
+        company.setPassword(password);
+        Company company1 = this.companyService.findUser(company);
+        
+        if (company1 != null) {
+            // 鐧诲綍鎴愬姛锛屾竻闄ゅけ璐ヨ褰�
+            loginFailRecordService.unlockAccount(account);
+            session.setAttribute("admin", company.getCompanyabbname());
+        } else {
+            // 鐧诲綍澶辫触锛岃褰曞け璐ユ鏁�
+            loginFailRecordService.recordLoginFail(account);
+        }
+        
+        return company1;
+    }
+
     @GetMapping({"Login11"})
     @ResponseBody
     public int sms(String phone) throws TencentCloudSDKException {
@@ -155,4 +194,32 @@
 
         return randomNumber;
     }
+    
+    /**
+     * 楠岃瘉鐮佺櫥褰曡В閿佽处鍙�
+     */
+    @PostMapping({"unlockAccountBySms"})
+    @ResponseBody
+    public Company unlockAccountBySms(String phone, String verificationCode, HttpSession session) throws Exception {
+        if (phone == null || verificationCode == null) {
+            return null;
+        }
+        
+        // 楠岃瘉楠岃瘉鐮侊紙杩欓噷闇�瑕佹牴鎹疄闄呯殑楠岃瘉鐮侀獙璇侀�昏緫鏉ュ疄鐜帮級
+        // 鍋囪楠岃瘉鐮侀獙璇佹垚鍔�
+        boolean isCodeValid = true; // 杩欓噷搴旇璋冪敤瀹為檯鐨勯獙璇佺爜楠岃瘉閫昏緫
+        
+        if (isCodeValid) {
+            // 楠岃瘉鐮佹纭紝瑙i攣璐﹀彿
+            loginFailRecordService.unlockAccount(phone);
+            
+            // 杩斿洖鐧诲綍鎴愬姛鐨勪俊鎭�
+            Company company = new Company();
+            company.setCompanyabbname("UNLOCKED");
+            session.setAttribute("admin", phone);
+            return company;
+        } else {
+            return null;
+        }
+    }
 }

--
Gitblit v1.9.3