|
|
@@ -12,6 +12,7 @@ import com.izouma.nineth.domain.User;
|
|
|
import com.izouma.nineth.dto.*;
|
|
|
import com.izouma.nineth.enums.AuthStatus;
|
|
|
import com.izouma.nineth.enums.AuthorityName;
|
|
|
+import com.izouma.nineth.event.AccountCreatedEvent;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.*;
|
|
|
import com.izouma.nineth.security.Authority;
|
|
|
@@ -33,6 +34,8 @@ import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
@@ -49,23 +52,24 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@AllArgsConstructor
|
|
|
public class UserService {
|
|
|
- private UserRepo userRepo;
|
|
|
- private WxMaService wxMaService;
|
|
|
- private WxMpService wxMpService;
|
|
|
- private SmsService smsService;
|
|
|
- private StorageService storageService;
|
|
|
- private JwtTokenUtil jwtTokenUtil;
|
|
|
- private CaptchaService captchaService;
|
|
|
- private FollowService followService;
|
|
|
- private FollowRepo followRepo;
|
|
|
- private IdentityAuthRepo identityAuthRepo;
|
|
|
- private SysConfigService sysConfigService;
|
|
|
- private CollectionService collectionService;
|
|
|
- private AdapayService adapayService;
|
|
|
- private UserBankCardRepo userBankCardRepo;
|
|
|
- private InviteRepo inviteRepo;
|
|
|
- private NFTService nftService;
|
|
|
- private CacheService cacheService;
|
|
|
+ private UserRepo userRepo;
|
|
|
+ private WxMaService wxMaService;
|
|
|
+ private WxMpService wxMpService;
|
|
|
+ private SmsService smsService;
|
|
|
+ private StorageService storageService;
|
|
|
+ private JwtTokenUtil jwtTokenUtil;
|
|
|
+ private CaptchaService captchaService;
|
|
|
+ private FollowService followService;
|
|
|
+ private FollowRepo followRepo;
|
|
|
+ private IdentityAuthRepo identityAuthRepo;
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
+ private CollectionService collectionService;
|
|
|
+ private AdapayService adapayService;
|
|
|
+ private UserBankCardRepo userBankCardRepo;
|
|
|
+ private InviteRepo inviteRepo;
|
|
|
+ private NFTService nftService;
|
|
|
+ private CacheService cacheService;
|
|
|
+ private ApplicationContext context;
|
|
|
|
|
|
public User update(User user) {
|
|
|
User orig = userRepo.findById(user.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
@@ -119,18 +123,15 @@ public class UserService {
|
|
|
if (StringUtils.isNotBlank(userRegister.getPassword())) {
|
|
|
user.setPassword(new BCryptPasswordEncoder().encode(userRegister.getPassword()));
|
|
|
}
|
|
|
- user = userRepo.save(user);
|
|
|
- User finalUser = user;
|
|
|
- new Thread(() -> {
|
|
|
- NFTAccount account = nftService.createAccount(finalUser.getUsername() + "_");
|
|
|
- finalUser.setNftAccount(account.getAccountId());
|
|
|
- finalUser.setKmsId(account.getAccountKmsId());
|
|
|
- finalUser.setPublicKey(account.getPublicKey());
|
|
|
- userRepo.save(finalUser);
|
|
|
- }).start();
|
|
|
+ user = userRepo.saveAndFlush(user);
|
|
|
+ nftService.createAccount(user.getId());
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
+ @EventListener
|
|
|
+ public void accountCreated(AccountCreatedEvent event) {
|
|
|
+ }
|
|
|
+
|
|
|
public User phoneRegister(String phone, String code, String password, String inviteCode) {
|
|
|
String name = "9th_" + RandomStringUtils.randomAlphabetic(8);
|
|
|
Invite invite = null;
|