package mapper

import (
	"58team_blog/internal/application/common"
	"58team_blog/internal/application/queries"
	"58team_blog/internal/domain/entities"
)

func CreatePostsResultFromEntity(entity *entities.Posts) *common.PostsResult {
	return &common.PostsResult{
		Id:     entity.Id,
		UserId: entity.UserId,
		PostId: entity.PostId,
	}
}

func CreatePostsResultListFromEntityList(entity_list []*entities.Posts) *common.PostsResultList {
	var result common.PostsResultList
	for _, e := range entity_list {
		result.Result = append(result.Result, CreatePostsResultFromEntity(e))
	}

	return &result
}

func CreatePostsFindByUserIdResultFromEntity(entity *entities.Posts) *queries.PostsFindByUserIdResult {
	return &queries.PostsFindByUserIdResult{
		Result: CreatePostsResultFromEntity(entity),
	}
}

func CreatePostsFindByPostIdResultFromEntity(entity *entities.Posts) *queries.PostsFindByPostIdResult {
	return &queries.PostsFindByPostIdResult{
		Result: CreatePostsResultFromEntity(entity),
	}
}

func CreatePostsFindAllByUserIdResultFromEntity(entity_list []*entities.Posts) *queries.PostsFindAllByUserIdResult {
	return &queries.PostsFindAllByUserIdResult{
		Result: CreatePostsResultListFromEntityList(entity_list),
	}
}

func CreatePostsGetAllResultFromEntity(entity_list []*entities.Posts) *queries.PostsGetAllResult {
	return &queries.PostsGetAllResult{
		Result: CreatePostsResultListFromEntityList(entity_list),
	}
}
