package mcuordersubitem

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	emoi "simrs-vx/internal/domain/main-entities/mcu-order-item"
	emss "simrs-vx/internal/domain/main-entities/mcu-sub-src"
	erc "simrs-vx/internal/domain/references/common"
)

type CreateDto struct {
	McuSubSrc_Code  *string            `json:"mcuSubSrc_code"`
	McuOrderItem_Id *uint              `json:"mcuOrderItem_id"`
	Result          *string            `json:"result"`
	Status_Code     erc.DataStatusCode `json:"status_code"`
}

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

type FilterDto struct {
	McuOrder_Id *uint              `json:"mcuOrder-id"`
	McuSrc_Code *string            `json:"mcuSrc-code"`
	Result      *string            `json:"result"`
	Status_Code erc.DataStatusCode `json:"status-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
	McuSubSrc_Code  *string            `json:"mcuSubSrc_code"`
	McuSubSrc       *emss.McuSubSrc    `json:"mcuSubSrc,omitempty"`
	McuOrderItem_Id *uint              `json:"mcuOrderItem_id"`
	McuOrderItem    *emoi.McuOrderItem `json:"mcuOrderItem,omitempty"`
	Result          *string            `json:"result"`
	Status_Code     erc.DataStatusCode `json:"status_code"`
}

func (d McuOrderSubItem) ToResponse() ResponseDto {
	resp := ResponseDto{
		McuSubSrc_Code:  d.McuSubSrc_Code,
		McuSubSrc:       d.McuSubSrc,
		McuOrderItem_Id: d.McuOrderItem_Id,
		McuOrderItem:    d.McuOrderItem,
		Result:          d.Result,
		Status_Code:     d.Status_Code,
	}
	resp.Main = d.Main
	return resp
}

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