fix some api
Change-Id: I7179a115c9ed3e7d3473c1761df1bb4f2bf3711e
diff --git a/src/main/java/com/example/g8backend/service/IUserService.java b/src/main/java/com/example/g8backend/service/IUserService.java
index 1f178f8..d980543 100644
--- a/src/main/java/com/example/g8backend/service/IUserService.java
+++ b/src/main/java/com/example/g8backend/service/IUserService.java
@@ -17,6 +17,9 @@
boolean unfollowUser(Long followerId, Long followedId);
List<User> getFollowings(Long userId);
List<User> getFollowers(Long userId);
+ int getFollowingsCount(Long userId);
+ int getFollowersCount(Long userId);
+ boolean isFollowing(Long currentUserId, Long targetUserId);
// 私信功能
Long sendMessage(Long senderId, Long receiverId, String content);
diff --git a/src/main/java/com/example/g8backend/service/impl/TorrentRecommendationServiceImpl.java b/src/main/java/com/example/g8backend/service/impl/TorrentRecommendationServiceImpl.java
index 7adc4c0..263b895 100644
--- a/src/main/java/com/example/g8backend/service/impl/TorrentRecommendationServiceImpl.java
+++ b/src/main/java/com/example/g8backend/service/impl/TorrentRecommendationServiceImpl.java
@@ -103,7 +103,7 @@
// 直接调用mapper更新对应torrent的israre字段
int rows = torrentMapper.updateIsRareByInfoHash(dto.getInfoHash(), israre);
- System.out.println("更新infoHash=" + dto.getInfoHash() + " 的is_rare=" + israre + ",受影响行数=" + rows);
+// System.out.println("更新infoHash=" + dto.getInfoHash() + " 的is_rare=" + israre + ",受影响行数=" + rows);
}
}
diff --git a/src/main/java/com/example/g8backend/service/impl/UserServiceImpl.java b/src/main/java/com/example/g8backend/service/impl/UserServiceImpl.java
index 1d1b6dc..a5f2f5b 100644
--- a/src/main/java/com/example/g8backend/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/example/g8backend/service/impl/UserServiceImpl.java
@@ -38,6 +38,29 @@
private MessageMapper messageMapper;
@Override
+ public int getFollowingsCount(Long userId) {
+ // 实现获取关注数的逻辑
+ return userMapper.countFollowings(userId);
+ }
+
+ @Override
+ public int getFollowersCount(Long userId) {
+ // 实现获取粉丝数的逻辑
+ return userMapper.countFollowers(userId);
+ }
+
+ @Override
+ public boolean isFollowing(Long currentUserId, Long targetUserId) {
+ // 避免自己关注自己的情况
+ if (currentUserId.equals(targetUserId)) {
+ return false;
+ }
+
+ // 查询关注关系是否存在
+ return userMapper.existsFollowRelationship(currentUserId, targetUserId) > 0;
+ }
+
+ @Override
public boolean followUser(Long followerId, Long followedId) {
if (followerId.equals(followedId)) return false;
Follow follow = new Follow();