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 1318129d..0abad964 100644 --- a/backend/src/main/java/com/group1/programminglanguagesforum/Controllers/UserController.java +++ b/backend/src/main/java/com/group1/programminglanguagesforum/Controllers/UserController.java @@ -42,14 +42,16 @@ 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(), @@ -82,13 +84,10 @@ public ResponseEntity> getUserById( UserProfileResponseDto.class); userProfileResponseDto.setReputationPoints(userService.calculateReputation(user.get())); userProfileResponseDto.setSelfFollowing(userService.selfFollowing(user.get())); - 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)); + userProfileResponseDto.setFollowedTags( + tagService.getFollowedTags(user.get().getId()) + ); + 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 06fb45b7..15d12b1a 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,5 +1,4 @@ package com.group1.programminglanguagesforum.DTOs.Responses; - import com.group1.programminglanguagesforum.Entities.ExperienceLevel; import lombok.*; @@ -26,7 +25,5 @@ public class UserProfileResponseDto { private ExperienceLevel experienceLevel; @Builder.Default private List followedTags = new ArrayList<>(); - private Long questionCount; - private List questions; - private List answers; + }