package devicepackage

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ed "simrs-vx/internal/domain/main-entities/device"
	edp "simrs-vx/internal/domain/main-entities/device-package"
)

type CreateDto struct {
	DevicePackage_Code string `json:"devicePackage_code" validate:"maxLength=20"`
	Device_Code        string `json:"code" validate:"maxLength=20"`
}

type ReadListDto struct {
	FilterDto
	Includes   string `json:"includes"`
	Pagination ecore.Pagination
}

type FilterDto struct {
	DevicePackage_Code string `json:"devicePackage-code"`
	Device_Code        string `json:"code"`
}

type ReadDetailDto struct {
	Id uint `json:"id"`
}

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

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

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

type ResponseDto struct {
	ecore.Main
	DevicePackage_Code string             `json:"devicePackage_code"`
	DevicePackage      *edp.DevicePackage `json:"devicePackage,omitempty"`
	Device_Code        string             `json:"code"`
	Device             *ed.Device         `json:"device,omitempty"`
}

func (d DevicePackageItem) ToResponse() ResponseDto {
	resp := ResponseDto{
		DevicePackage_Code: d.DevicePackage_Code,
		DevicePackage:      d.DevicePackage,
		Device_Code:        d.Device_Code,
		Device:             d.Device,
	}
	resp.Id = d.Id
	return resp
}

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