xiongzhu 4 years ago
parent
commit
46affa0909

+ 1 - 0
src/main/java/com/izouma/nineth/service/UserService.java

@@ -344,6 +344,7 @@ public class UserService {
         return new PageImpl<>(userDTOS, users.getPageable(), users.getTotalElements());
     }
 
+    @CacheEvict(value = "user", allEntries = true)
     public void setTradeCode(Long userId, String token, String tradeCode) {
         String phone = smsService.verifyToken(token);
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));

+ 3 - 1
src/main/java/com/izouma/nineth/web/UserController.java

@@ -201,7 +201,9 @@ public class UserController extends BaseController {
     @GetMapping("/tradeCodeStatus")
     public Object tradeCodeStatus() {
         return new HashMap<String, Object>() {{
-            put("set", !StringUtils.isBlank(SecurityUtils.getAuthenticatedUser().getTradeCode()));
+            put("set", StringUtils.isNotBlank(
+                    userRepo.findById(SecurityUtils.getAuthenticatedUser().getId()).map(User::getTradeCode).orElse(null)
+            ));
         }};
     }
 }