diff --git a/backend/src/main/java/com/group1/programminglanguagesforum/Controllers/UserController.java b/backend/src/main/java/com/group1/programminglanguagesforum/Controllers/UserController.java index 0abad96..1318129 100644 --- a/backend/src/main/java/com/group1/programminglanguagesforum/Controllers/UserController.java +++ b/backend/src/main/java/com/group1/programminglanguagesforum/Controllers/UserController.java @@ -42,16 +42,14 @@ public ResponseEntity> getUser() { List questions = questionService.findByAuthorId(user.getId()); List answers = answerService.findByAnsweredBy(user.getId()); selfProfileResponseDto.setFollowedTags( - tagService.getFollowedTags(user.getId()) - ); + tagService.getFollowedTags(user.getId())); selfProfileResponseDto.setReputationPoints(userService.calculateReputation(user)); selfProfileResponseDto.setQuestionCount((long) questions.size()); selfProfileResponseDto.setQuestions( - questions); + questions); selfProfileResponseDto.setAnswerCount((long) answers.size()); selfProfileResponseDto.setAnswers( - answers); - + answers); GenericApiResponse response = ApiResponseBuilder.buildSuccessResponse( selfProfileResponseDto.getClass(), @@ -84,10 +82,13 @@ public ResponseEntity> getUserById( UserProfileResponseDto.class); userProfileResponseDto.setReputationPoints(userService.calculateReputation(user.get())); userProfileResponseDto.setSelfFollowing(userService.selfFollowing(user.get())); - userProfileResponseDto.setFollowedTags( - tagService.getFollowedTags(user.get().getId()) - ); - + List questions = questionService.findByAuthorId(id); + userProfileResponseDto.setQuestions(questions); + userProfileResponseDto.setQuestionCount((long) questions.size()); + List answers = answerService.findByAnsweredBy(id); + userProfileResponseDto.setAnswers(answers); + userProfileResponseDto.setAnswerCount((long) answers.size()); + userProfileResponseDto.setFollowedTags(tagService.getFollowedTags(id)); GenericApiResponse response = ApiResponseBuilder.buildSuccessResponse( userProfileResponseDto.getClass(), diff --git a/backend/src/main/java/com/group1/programminglanguagesforum/DTOs/Responses/UserProfileResponseDto.java b/backend/src/main/java/com/group1/programminglanguagesforum/DTOs/Responses/UserProfileResponseDto.java index 15d12b1..06fb45b 100644 --- a/backend/src/main/java/com/group1/programminglanguagesforum/DTOs/Responses/UserProfileResponseDto.java +++ b/backend/src/main/java/com/group1/programminglanguagesforum/DTOs/Responses/UserProfileResponseDto.java @@ -1,4 +1,5 @@ package com.group1.programminglanguagesforum.DTOs.Responses; + import com.group1.programminglanguagesforum.Entities.ExperienceLevel; import lombok.*; @@ -25,5 +26,7 @@ public class UserProfileResponseDto { private ExperienceLevel experienceLevel; @Builder.Default private List followedTags = new ArrayList<>(); - + private Long questionCount; + private List questions; + private List answers; }