|
@@ -3,13 +3,13 @@ package cn.jlsxwkj.moudles.userlist;
|
|
|
import cn.dev33.satoken.secure.SaSecureUtil;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.lang.Snowflake;
|
|
|
+import cn.jlsxwkj.common.exception.AccountAuthFailException;
|
|
|
+import cn.jlsxwkj.common.exception.CustomException;
|
|
|
+import cn.jlsxwkj.common.exception.LoginAccountAlreadyLoginException;
|
|
|
+import cn.jlsxwkj.common.exception.LoginWrongPasswordException;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.security.auth.login.AccountException;
|
|
|
-import javax.security.auth.login.FailedLoginException;
|
|
|
-import javax.security.auth.login.LoginException;
|
|
|
-
|
|
|
/**
|
|
|
* @author zh
|
|
|
*/
|
|
@@ -20,13 +20,13 @@ public class UserListService {
|
|
|
private UserListMapper userListMapper;
|
|
|
private final Snowflake snowflake = new Snowflake();
|
|
|
|
|
|
- public UserVO checkOrAddUser(String userName, String userPassword) throws LoginException {
|
|
|
+ public UserVO checkOrAddUser(String userName, String userPassword) throws CustomException {
|
|
|
String sha512pwd = SaSecureUtil.sha512(userPassword);
|
|
|
UserList userList = userListMapper.checkUser(userName);
|
|
|
UserVO userVO = new UserVO();
|
|
|
if (userList != null) {
|
|
|
if (!userList.getUserPassword().contains(sha512pwd)) {
|
|
|
- throw new FailedLoginException("密码错误");
|
|
|
+ throw new LoginWrongPasswordException("密码错误");
|
|
|
}
|
|
|
if (!StpUtil.isLogin()) {
|
|
|
String userId = userList.getUserId();
|
|
@@ -36,7 +36,7 @@ public class UserListService {
|
|
|
userVO.setMessage("登录成功");
|
|
|
return userVO;
|
|
|
}
|
|
|
- throw new LoginException("请勿重复登录");
|
|
|
+ throw new LoginAccountAlreadyLoginException("请勿重复登录");
|
|
|
}
|
|
|
userList = new UserList();
|
|
|
userList.setUserId(snowflake.nextIdStr());
|
|
@@ -52,6 +52,6 @@ public class UserListService {
|
|
|
return userVO;
|
|
|
|
|
|
}
|
|
|
- throw new AccountException("注册失败");
|
|
|
+ throw new AccountAuthFailException("注册失败");
|
|
|
}
|
|
|
}
|