package dto

import (
	"58team_blog/internal/application/common"
	"58team_blog/internal/application/queries"
	"58team_blog/internal/interfaces/api/responses"
)

func itemFromResult(item *common.PostResult) responses.GetListPostResponseItem {
	return responses.GetListPostResponseItem{
		Id:          item.Id.String(),
		Title:       item.Title,
		Description: item.Description,
	}
}

func ResponseFromPostGetAllResult(result *queries.PostGetAllResult) responses.GetListPostResponse {
	var resp []responses.GetListPostResponseItem

	for _, r := range result.Result.Result {
		resp = append(resp, itemFromResult(r))
	}

	return resp
}
