java.lang.Object
fr.utc.miage.sporttrack.service.user.communication.CommentService

@Service public class CommentService extends Object
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 Details

    • CommentService

      @Autowired public CommentService(CommentRepository commentRepository)
      Constructs a new CommentService with the given repository.
      Parameters:
      commentRepository - the repository for comment data access
  • Method Details

    • addComment

      public Comment addComment(Athlete author, Activity activity, String content, InteractionType type)
      Creates and persists a new comment on an activity.
      Parameters:
      author - the athlete who authored the comment
      activity - the activity to which the comment is attached
      content - the textual content of the comment
      type - the type of social interaction (e.g., LIKE, CHEER)
      Returns:
      the newly created and persisted Comment
    • getCommentsForActivity

      public List<Comment> getCommentsForActivity(int activityId)
      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