|
|
@@ -5,13 +5,10 @@ import cn.reghao.jutil.jdk.result.ResultStatus;
|
|
|
import cn.reghao.jutil.jdk.security.RandomString;
|
|
|
import cn.reghao.jutil.jdk.string.StringRegexp;
|
|
|
import cn.reghao.tnb.account.api.constant.VerifyChannel;
|
|
|
-import cn.reghao.tnb.account.app.model.constant.AccountRole;
|
|
|
-import cn.reghao.tnb.account.app.model.constant.AccountType;
|
|
|
import cn.reghao.tnb.account.app.model.dto.AccountDetail;
|
|
|
import cn.reghao.tnb.account.app.model.dto.UserRegisterDto;
|
|
|
import cn.reghao.tnb.account.app.db.repository.AccountRepository;
|
|
|
import cn.reghao.tnb.account.app.model.po.UserRegistry;
|
|
|
-import cn.reghao.tnb.account.app.service.AvatarService;
|
|
|
import cn.reghao.tnb.account.app.service.CodeService;
|
|
|
import cn.reghao.tnb.account.app.model.po.UserAccount;
|
|
|
import cn.reghao.tnb.account.app.service.AccountRegistryService;
|
|
|
@@ -33,16 +30,13 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
private final PasswordEncoder passwordEncoder;
|
|
|
private final AccountRepository accountRepository;
|
|
|
private final PubkeyService pubkeyService;
|
|
|
- private final AvatarService avatarService;
|
|
|
|
|
|
public AccountRegistryServiceImpl(CodeService codeService, PasswordEncoder passwordEncoder,
|
|
|
- AccountRepository accountRepository, PubkeyService pubkeyService,
|
|
|
- AvatarService avatarService) {
|
|
|
+ AccountRepository accountRepository, PubkeyService pubkeyService) {
|
|
|
this.codeService = codeService;
|
|
|
this.passwordEncoder = passwordEncoder;
|
|
|
this.accountRepository = accountRepository;
|
|
|
this.pubkeyService = pubkeyService;
|
|
|
- this.avatarService = avatarService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -64,8 +58,8 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
return Result.fail("短信验证码不正确, 请重新获取");
|
|
|
}
|
|
|
|
|
|
- String mobile = null;
|
|
|
- String email = null;
|
|
|
+ String email = "";
|
|
|
+ String mobile = "";
|
|
|
if (StringRegexp.matchEmail(principal)) {
|
|
|
email = principal;
|
|
|
} else if (StringRegexp.matchMobile(principal)) {
|
|
|
@@ -83,14 +77,7 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
long userId = getNextUserId();
|
|
|
String salt = RandomString.getSalt(64);
|
|
|
String encodedPassword = passwordEncoder.encode(decryptCredential + salt);
|
|
|
- int accountType = AccountType.tnb.getValue();
|
|
|
- String role = AccountRole.user.getValue();
|
|
|
- String avatarUrl = avatarService.getAccountAvatar(userId);
|
|
|
- if (avatarUrl == null) {
|
|
|
- return Result.result(ResultStatus.FAIL, "头像创建失败");
|
|
|
- }
|
|
|
-
|
|
|
- UserAccount userAccount = new UserAccount(userId, email, mobile, encodedPassword, salt, accountType, role, avatarUrl);
|
|
|
+ UserAccount userAccount = new UserAccount(userId, email, mobile, encodedPassword, salt);
|
|
|
accountRepository.saveAccount(userAccount);
|
|
|
return Result.result(ResultStatus.SUCCESS, "帐号已创建");
|
|
|
}
|
|
|
@@ -108,11 +95,17 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AccountDetail createAccount(String mobile, String password) {
|
|
|
+ public AccountDetail createAccount(String principal, String password) {
|
|
|
+ String email = "";
|
|
|
+ String mobile = "";
|
|
|
+ if (StringRegexp.matchEmail(principal)) {
|
|
|
+ email = principal;
|
|
|
+ } else if (StringRegexp.matchMobile(principal)) {
|
|
|
+ mobile = principal;
|
|
|
+ }
|
|
|
+
|
|
|
long userId = getNextUserId();
|
|
|
- String salt = RandomString.getSalt(64);
|
|
|
- String encodedPassword = passwordEncoder.encode(password + salt);
|
|
|
- UserAccount userAccount = new UserAccount(userId, mobile, encodedPassword, salt);
|
|
|
+ UserAccount userAccount = new UserAccount(userId, email, mobile);
|
|
|
accountRepository.saveAccount(userAccount);
|
|
|
return accountRepository.getUserDetailByMobile(mobile);
|
|
|
}
|