Commit 18ac5786 authored by 杨锐's avatar 杨锐

RuntimeException => DataException,友好提示。

parent c5ba36de
package cn.quantgroup.xyqb.controller.middleoffice.common; package cn.quantgroup.xyqb.controller.middleoffice.common;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.exception.DataException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Objects; import java.util.Objects;
...@@ -22,6 +23,6 @@ public class PwdVerifyStrategy implements IVerifyStrategy { ...@@ -22,6 +23,6 @@ public class PwdVerifyStrategy implements IVerifyStrategy {
return; return;
} }
//todo 自定义异常 //todo 自定义异常
throw new RuntimeException("用户名或密码错误"); throw new DataException("用户名或密码错误");
} }
} }
...@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.controller.middleoffice.login; ...@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.controller.middleoffice.login;
import cn.quantgroup.xyqb.controller.middleoffice.common.VerifyStrategyFactory; import cn.quantgroup.xyqb.controller.middleoffice.common.VerifyStrategyFactory;
import cn.quantgroup.xyqb.controller.middleoffice.common.VerifyTypeEnum; import cn.quantgroup.xyqb.controller.middleoffice.common.VerifyTypeEnum;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.exception.DataException;
import cn.quantgroup.xyqb.model.AuthBean; import cn.quantgroup.xyqb.model.AuthBean;
import cn.quantgroup.xyqb.model.LoginProperties; import cn.quantgroup.xyqb.model.LoginProperties;
import cn.quantgroup.xyqb.service.register.IUserRegisterService; import cn.quantgroup.xyqb.service.register.IUserRegisterService;
...@@ -41,14 +42,14 @@ public class LoginModule implements ILoginModule { ...@@ -41,14 +42,14 @@ public class LoginModule implements ILoginModule {
user = userRegisterService.register(channelId, phoneNo); user = userRegisterService.register(channelId, phoneNo);
} else { } else {
//todo 自定义异常 //todo 自定义异常
throw new RuntimeException("用户名或密码不正确"); throw new DataException("用户名或密码不正确");
} }
} }
if (!user.getEnable()) { if (!user.getEnable()) {
//用户不存在 //用户不存在
log.info("用户尝试登录,已注销:{}", phoneNo); log.info("用户尝试登录,已注销:{}", phoneNo);
//todo 自定义异常 //todo 自定义异常
throw new RuntimeException("用户名或密码不正确"); throw new DataException("用户名或密码不正确");
} }
//验证 //验证
...@@ -73,7 +74,7 @@ public class LoginModule implements ILoginModule { ...@@ -73,7 +74,7 @@ public class LoginModule implements ILoginModule {
User user = userService.findByPhoneInDb(phoneNo); User user = userService.findByPhoneInDb(phoneNo);
if (user == null) { if (user == null) {
//todo 自定义异常 //todo 自定义异常
throw new RuntimeException("用户不存在"); throw new DataException("用户不存在");
} }
VerifyStrategyFactory.get(type).verify(user, verify); VerifyStrategyFactory.get(type).verify(user, verify);
userService.resetPassword(phoneNo, password); userService.resetPassword(phoneNo, password);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment