package com.betriebsratkanzlei.legalconsenthub.comment

import com.betriebsratkanzlei.legalconsenthub_api.model.PagedCommentDto
import org.springframework.data.domain.Page
import org.springframework.stereotype.Component

@Component
class PagedCommentMapper(private val commentMapper: CommentMapper) {
    fun toPagedCommentDto(pagedComment: Page<Comment>): PagedCommentDto {
        return PagedCommentDto(
            content = pagedComment.content.map { commentMapper.toCommentDto(it) },
            number = pagedComment.number,
            propertySize = pagedComment.size,
            numberOfElements = pagedComment.numberOfElements,
            last = pagedComment.isLast,
            totalPages = pagedComment.totalPages,
            totalElements = pagedComment.totalElements,
            empty = pagedComment.isEmpty,
            first = pagedComment.isFirst,
        )
    }
}
