package dto

import (
	"time"

	entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
)

// === DTO Structs ===

type UserRelationDTO struct {
	Id     uint   `json:"id"`
	IdUser int64  `json:"id_user"`
	Email  string `json:"email"`
	Name   string `json:"name"`
}

type UserListDTO struct {
	UserRelationDTO
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type UserDetailDTO struct {
	UserListDTO
}

// === Mapper Functions ===

func ToUserRelationDTO(m entity.User) UserRelationDTO {
	return UserRelationDTO{
		Id:     m.Id,
		IdUser: m.IdUser,
		Email:  m.Email,
		Name:   m.Name,
	}
}

func ToUserListDTO(m entity.User) UserListDTO {
	return UserListDTO{
		UserRelationDTO: ToUserRelationDTO(m),
		CreatedAt:       m.CreatedAt,
		UpdatedAt:       m.UpdatedAt,
	}
}

func ToUserListDTOs(m []entity.User) []UserListDTO {
	result := make([]UserListDTO, len(m))
	for i, r := range m {
		result[i] = ToUserListDTO(r)
	}
	return result
}
