package counter

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
)

type CreateDto struct {
	Code       string  `json:"code"`
	Name       string  `json:"name"`
	Number     uint8   `json:"number"`
	Parent_Id  *uint16 `json:"parent_id"`
	Type_Code  string  `json:"type_code"`
	Queue_Code string  `json:"queue_code"`
}

type ReadListDto struct {
	Code       string  `json:"code"`
	Name       string  `json:"name"`
	Number     uint8   `json:"number"`
	Parent_Id  *uint16 `json:"parent-id"`
	Type_Code  string  `json:"type-code"`
	Queue_Code string  `json:"queue-code"`
	Pagination ecore.Pagination
}

type ReadDetailDto struct {
	Id         uint16  `json:"id"`
	Code       string  `json:"code"`
	Name       string  `json:"name"`
	Number     uint8   `json:"number"`
	Parent_Id  *uint16 `json:"parent_id"`
	Type_Code  string  `json:"type_code"`
	Queue_Code string  `json:"queue_code"`
}

type UpdateDto struct {
	Id uint16 `json:"id"`
	CreateDto
}

type DeleteDto struct {
	Id uint16 `json:"id"`
}

type MetaDto struct {
	PageNumber int `json:"page_number"`
	PageSize   int `json:"page_size"`
	Count      int `json:"count"`
}

type ResponseDto struct {
	ecore.SmallMain
	Code       string  `json:"code"`
	Name       string  `json:"name"`
	Number     uint8   `json:"number"`
	Parent_Id  *uint16 `json:"parent_id"`
	Type_Code  string  `json:"type_code"`
	Queue_Code string  `json:"queue_code"`
}

func (d Counter) ToResponse() ResponseDto {
	resp := ResponseDto{
		Code:       d.Code,
		Name:       d.Name,
		Number:     d.Number,
		Parent_Id:  d.Parent_Id,
		Type_Code:  d.Type_Code,
		Queue_Code: d.Queue_Code,
	}
	resp.SmallMain = d.SmallMain
	return resp
}

func ToResponseList(data []Counter) []ResponseDto {
	resp := make([]ResponseDto, len(data))
	for i, u := range data {
		resp[i] = u.ToResponse()
	}
	return resp
}
