fix GET /user return the statistics of user
Change-Id: Ic17cd985e45daee3c242b699bfd3bfa11a46298e
diff --git a/src/main/java/com/example/g8backend/controller/UserController.java b/src/main/java/com/example/g8backend/controller/UserController.java
index a41e4d7..c4c701a 100644
--- a/src/main/java/com/example/g8backend/controller/UserController.java
+++ b/src/main/java/com/example/g8backend/controller/UserController.java
@@ -4,6 +4,7 @@
import com.example.g8backend.entity.Message;
import com.example.g8backend.entity.User;
import com.example.g8backend.entity.UserSignin;
+import com.example.g8backend.entity.UserStats;
import com.example.g8backend.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
@@ -53,11 +54,17 @@
int followingCount = userService.getFollowingsCount(userId);
int followersCount = userService.getFollowersCount(userId);
+ UserStats userStats = userService.getUserStats(userId);
+ double totalUpload = userStats != null ? userStats.getTotal_upload() : 0.0;
+ double totalDownload = userStats != null ? userStats.getTotal_download() : 0.0;
+
return ApiResponse.success(Map.of(
"userInfo", user,
"statistics", Map.of(
"followingCount", followingCount,
- "followersCount", followersCount
+ "followersCount", followersCount,
+ "totalUpload", totalUpload,
+ "totalDownload", totalDownload
)
));
}