From 2b79f2033d7606eb9fb449af39ae3c41145edecd Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期一, 20 一月 2025 19:49:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java |   35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
index 8a0b657..2d6ab96 100644
--- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
+++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java
@@ -6,6 +6,7 @@
 import com.ruoyi.company.api.domain.User;
 import com.ruoyi.company.api.model.RegisterUser;
 import lombok.RequiredArgsConstructor;
+import org.jacoco.agent.rt.internal_43f5073.core.internal.flow.IFrame;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import com.ruoyi.common.core.constant.CacheConstants;
@@ -182,11 +183,41 @@
                 throw new CaptchaException("验证码错误");
             }
         }
-        remoteCompanyUserService.registerUser(registerUser, SecurityConstants.INNER);
+        R<Boolean> booleanR = remoteCompanyUserService.registerUser(registerUser, SecurityConstants.INNER);
+        if (R.isError(booleanR)){
+            throw new ServiceException("注册失败");
+        }
     }
 
 
-    public void companyLogin(RegisterUser registerUser)
+    public User companyLogin(RegisterUser registerUser)
     {
+        String accountName = registerUser.getAccountName();
+        String password = registerUser.getPassword();
+
+        R<User> userByPhoneR = remoteCompanyUserService.getUserByPhone(accountName, SecurityConstants.INNER);
+        if (R.isError(userByPhoneR)){
+            throw new ServiceException(userByPhoneR.getMsg());
+        }
+        if (userByPhoneR.getData() == null){
+            throw new ServiceException("账号不存在");
+        }
+
+        if (SecurityUtils.matchesPassword(password, userByPhoneR.getData().getPassword())){
+            return userByPhoneR.getData();
+        }
+
+
+        R<User> r = remoteCompanyUserService.getUserByAccountName(accountName, SecurityConstants.INNER);
+        if (R.isError(r)){
+            throw new ServiceException(r.getMsg());
+        }
+        if (r.getData() == null){
+            throw new ServiceException("账号不存在");
+        }
+        if (!SecurityUtils.matchesPassword(password, r.getData().getPassword())){
+            throw new ServiceException("密码错误");
+        }
+        return r.getData();
     }
 }

--
Gitblit v1.7.1