package micromcuorderitem

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ems "simrs-vx/internal/domain/main-entities/mcu-src"
	emro "simrs-vx/internal/domain/main-entities/micro-mcu-order"
	erc "simrs-vx/internal/domain/references/common"
	"time"
)

type CreateDto struct {
	MicroMcuOrder_Id uint64 `json:"microMcuOrder_id"`
	McuSrc_Code      string `json:"mcuSrc_code"`
}

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

type FilterDto struct {
	MicroMcuOrder_Id *uint64            `json:"micro-mcu-order-id"`
	McuSrc_Code      *string            `json:"mcu-src-code"`
	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 SetScheduleDto struct {
	Id              uint       `json:"id"`
	ExaminationDate *time.Time `json:"examinationDate"`
}

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

type ResponseDto struct {
	ecore.BigMain
	MicroMcuOrder_Id uint64              `json:"microMcuOrder_id"`
	MicroMcuOrder    *emro.MicroMcuOrder `json:"microMcuOrder,omitempty"`
	McuSrc_Code      string              `json:"mcuSrc_code"`
	McuSrc           *ems.McuSrc         `json:"mcuSrc,omitempty"`
	Result           *string             `json:"result"`
	Status_Code      erc.DataStatusCode  `json:"status_code"`
}

func (d MicroMcuOrderItem) ToResponse() ResponseDto {
	resp := ResponseDto{
		MicroMcuOrder_Id: d.MicroMcuOrder_Id,
		MicroMcuOrder:    d.MicroMcuOrder,
		McuSrc_Code:      d.McuSrc_Code,
		McuSrc:           d.McuSrc,
		Result:           d.Result,
		Status_Code:      d.Status_Code,
	}
	resp.BigMain = d.BigMain
	return resp
}

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