package cpmcuorderitem

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

type CreateDto struct {
	CpMcuOrder_Id uint64 `json:"cpMcuOrder_id"`
	McuSrc_Code   string `json:"mcuSrc_code"`
}

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

type FilterDto struct {
	CpMcuOrder_Id *uint64            `json:"cp-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
	CpMcuOrder_Id uint64             `json:"cpMcuOrder_id"`
	CpMcuOrder    *emro.CpMcuOrder   `json:"cpMcuOrder,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 CpMcuOrderItem) ToResponse() ResponseDto {
	resp := ResponseDto{
		CpMcuOrder_Id: d.CpMcuOrder_Id,
		CpMcuOrder:    d.CpMcuOrder,
		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 []CpMcuOrderItem) []ResponseDto {
	resp := make([]ResponseDto, len(data))
	for i, u := range data {
		resp[i] = u.ToResponse()
	}
	return resp
}
