xiongzhu před 4 roky
rodič
revize
cfc151d62b

+ 16 - 0
src/main/java/com/izouma/nineth/repo/UserRepo.java

@@ -135,4 +135,20 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
     @Modifying
     @Transactional
     void updateOrderMinter(Long userId);
+
+    @Query(value = "update token_history join user on token_history.from_user_id = user.id " +
+            "set token_history.from_user        = user.nickname, " +
+            "    token_history.from_avatar = user.avatar " +
+            "where user.id = ?1 ", nativeQuery = true)
+    @Modifying
+    @Transactional
+    void updateHistoryFromUser(Long userId);
+
+    @Query(value = "update token_history join user on token_history.to_user_id = user.id " +
+            "set token_history.to_user        = user.nickname, " +
+            "    token_history.to_avatar = user.avatar " +
+            "where user.id = ?1 ", nativeQuery = true)
+    @Modifying
+    @Transactional
+    void updateHistoryToUser(Long userId);
 }

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

@@ -75,6 +75,8 @@ public class UserService {
         userRepo.updateCollectionMinter(orig.getId());
         userRepo.updateCollectionOwner(orig.getId());
         userRepo.updateOrderMinter(orig.getId());
+        userRepo.updateHistoryFromUser(orig.getId());
+        userRepo.updateHistoryToUser(orig.getId());
         collectionService.clearCache();
         return orig;
     }