|
|
@@ -297,4 +297,18 @@ public class UserService {
|
|
|
List<UserDTO> userDTOS = toDTO(users.getContent());
|
|
|
return new PageImpl<>(userDTOS, users.getPageable(), users.getTotalElements());
|
|
|
}
|
|
|
+
|
|
|
+ public void setTradeCode(Long userId, String code, String tradeCode) {
|
|
|
+ User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
+ smsService.verify(user.getPhone(), code);
|
|
|
+ user.setTradeCode(new BCryptPasswordEncoder().encode(tradeCode));
|
|
|
+ userRepo.save(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void verifyTradeCode(Long userId, String tradeCode) {
|
|
|
+ User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
+ if (!new BCryptPasswordEncoder().matches(tradeCode, user.getTradeCode())) {
|
|
|
+ throw new BusinessException("校验失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|