用户登录问题修改
This commit is contained in:
parent
e764864a99
commit
1c3012232d
|
|
@ -9,11 +9,13 @@ import com.bonus.common.core.constant.UserConstants;
|
|||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.RemoteUserService;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import com.hankcs.hanlp.HanLP;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -82,6 +84,21 @@ public class SysLoginService {
|
|||
public void register(RegisterBody registerBody) {
|
||||
long startTime = System.currentTimeMillis(); // 记录开始时间
|
||||
String result = convertAndAppend(registerBody.getNickName(), registerBody.getMobile());
|
||||
int contactType = getContactType(registerBody.getMobile());
|
||||
|
||||
if (contactType == 0) {
|
||||
R<LoginUser> userResult = remoteUserService.getUserInfoByEmail(Sm4Utils.encrypt(registerBody.getMobile()) , SecurityConstants.INNER);
|
||||
if (userResult.getData() != null) {
|
||||
throw new ServiceException("联系方式已经注册账号");
|
||||
}
|
||||
} else if (contactType == 1) {
|
||||
R<LoginUser> userResult = remoteUserService.getUserInfoByPhone(Sm4Utils.encrypt(registerBody.getMobile()) , SecurityConstants.INNER);
|
||||
if (userResult.getData() != null) {
|
||||
throw new ServiceException("联系方式已经注册账号");
|
||||
}
|
||||
}else {
|
||||
throw new ServiceException("请输入正确的联系方式");
|
||||
}
|
||||
registerBody.setUsername(result);
|
||||
if (StringUtils.isAnyBlank(registerBody.getUsername(), registerBody.getPassword()) ||
|
||||
registerBody.getUsername().length() < UserConstants.USERNAME_MIN_LENGTH ||
|
||||
|
|
@ -93,6 +110,7 @@ public class SysLoginService {
|
|||
passwordValidatorService.checkPhoneCaptcha(registerBody.getMobile(),registerBody.getVerificationCode());
|
||||
}
|
||||
AjaxResult ajaxResult = passwordValidatorService.validatePassword(registerBody.getUsername(), registerBody.getPassword());
|
||||
|
||||
if (ajaxResult.isError()) {
|
||||
throw new ServiceException((String) ajaxResult.get("msg"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue