package mapper

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

func CreateUserResultFromEntity(entity *entities.User) *common.UserResult {
	return &common.UserResult{
		Id:       entity.Id,
		UserName: entity.UserName,
		Password: entity.Password,
	}
}

func CreateUserResultListFromEntity(entityList []*entities.User) *common.UserResultList {
	var result common.UserResultList

	for _, e := range entityList {
		result.Result = append(result.Result, CreateUserResultFromEntity(e))
	}

	return &result
}

func CreateUserFindByIdResultFromEntity(entity *entities.User) *queries.UserFindByIdResult {
	return &queries.UserFindByIdResult{
		Result: CreateUserResultFromEntity(entity),
	}
}

func CreateUserFindByNameResultFromEntity(entity *entities.User) *queries.UserFindByNameResult {
	return &queries.UserFindByNameResult{
		Result: CreateUserResultFromEntity(entity),
	}
}

func CreateUserGetAllResultFromEntity(entity_list []*entities.User) *queries.UserGetAllResult {
	return &queries.UserGetAllResult{
		Result: CreateUserResultListFromEntity(entity_list),
	}
}
