Class CommentService
java.lang.Object
fr.utc.miage.sporttrack.service.user.communication.CommentService
Service layer component responsible for managing
Comment entities
within the SportTrack application.
Provides business logic for adding, retrieving, and deleting comments (social interactions) on activities.
- Author:
- SportTrack Team
-
Constructor Summary
ConstructorsConstructorDescriptionCommentService(CommentRepository commentRepository) Constructs a newCommentServicewith the given repository. -
Method Summary
Modifier and TypeMethodDescriptionaddComment(Athlete author, Activity activity, String content, InteractionType type) Creates and persists a new comment on an activity.voiddeleteComment(int commentId) Deletes the comment with the given identifier.getCommentsForActivity(int activityId) Returns all comments for the specified activity, ordered by creation time descending.
-
Constructor Details
-
CommentService
Constructs a newCommentServicewith the given repository.- Parameters:
commentRepository- the repository for comment data access
-
-
Method Details
-
addComment
Creates and persists a new comment on an activity.- Parameters:
author- the athlete who authored the commentactivity- the activity to which the comment is attachedcontent- the textual content of the commenttype- the type of social interaction (e.g., LIKE, CHEER)- Returns:
- the newly created and persisted
Comment
-
getCommentsForActivity
Returns all comments for the specified activity, ordered by creation time descending.- Parameters:
activityId- the unique identifier of the activity- Returns:
- a list of comments, newest first
-
deleteComment
public void deleteComment(int commentId) Deletes the comment with the given identifier.- Parameters:
commentId- the unique identifier of the comment to delete
-