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 | 69 +++++++++++++++++++++++++++++++++- 1 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/flow/controller/LoginController.java b/src/main/java/com/flow/controller/LoginController.java index 27e0a52..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; @@ -46,6 +47,8 @@ LoginJiLuService loginJiLuService; @Autowired CompanyService companyService; + @Autowired + LoginFailRecordService loginFailRecordService; public LoginController() { } @@ -76,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)); + +// company.setLoginphone(DESUtil.encrypt(company.getLoginphone(), DESUtil.key)); if (company.getPassword() != null) { - company.setPassword(DESUtil.encrypt(company.getPassword(), DESUtil.key)); + company.setPassword(company.getPassword()); } Company company1 = this.companyService.findUser(company); if (company1 != null) { @@ -126,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 { @@ -157,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