From 115d28edad71a509d9680703aa75d4570ff0a01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=A3=BC=EC=B0=AC?= Date: Fri, 27 Mar 2026 17:39:50 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=8C=94=EB=A1=9C=EC=9A=B0=20=EC=88=98?= =?UTF-8?q?=20=EC=9E=91=EC=97=85=20=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/jpa/FollowJpaRepository.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/prothsync/src/main/java/com/prothsync/prothsync/repository/jpa/FollowJpaRepository.java b/prothsync/src/main/java/com/prothsync/prothsync/repository/jpa/FollowJpaRepository.java index 4f92fbb..6d5444f 100644 --- a/prothsync/src/main/java/com/prothsync/prothsync/repository/jpa/FollowJpaRepository.java +++ b/prothsync/src/main/java/com/prothsync/prothsync/repository/jpa/FollowJpaRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -25,4 +26,20 @@ public interface FollowJpaRepository extends JpaRepository { @Query("SELECT f.followingId FROM Follow f WHERE f.followerId = :followerId") List findFollowingIdsByFollowerId(@Param("followerId") Long followerId); + + @Modifying + @Query("UPDATE User u SET u.followerCount = u.followerCount + 1 WHERE u.userId = :userId") + void incrementFollowerCount(@Param("userId") Long userId); + + @Modifying + @Query("UPDATE User u SET u.followerCount = u.followerCount - 1 WHERE u.userId = :userId AND u.followerCount > 0") + void decrementFollowerCount(@Param("userId") Long userId); + + @Modifying + @Query("UPDATE User u SET u.followingCount = u.followingCount + 1 WHERE u.userId = :userId") + void incrementFollowingCount(@Param("userId") Long userId); + + @Modifying + @Query("UPDATE User u SET u.followingCount = u.followingCount - 1 WHERE u.userId = :userId AND u.followingCount > 0") + void decrementFollowingCount(@Param("userId") Long userId); } \ No newline at end of file