package diagnosesrc

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

type CreateDto struct {
	Code    *string `json:"code" validate:"maxLength=10"`
	Name    string  `json:"name" validate:"maxLength=2048"`
	IndName string  `json:"indName" validate:"maxLength=2048"`
}

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

type FilterDto struct {
	Code    string `json:"code"`
	Name    string `json:"name"`
	IndName string `json:"indName"`
	Search  string `json:"search" gormhelper:"searchColumns=Code,Name"`
}

type ReadDetailDto struct {
	Id   *uint16 `json:"id"`
	Code *string `json:"code"`
}

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

type DeleteDto struct {
	Id   *uint16 `json:"id"`
	Code *string `json:"code"`
}

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

type ResponseDto struct {
	ecore.Main
	Code    string `json:"code"`
	Name    string `json:"name"`
	IndName string `json:"indName"`
}

func (d DiagnoseSrc) ToResponse() ResponseDto {
	resp := ResponseDto{
		Code:    d.Code,
		Name:    d.Name,
		IndName: d.IndName,
	}
	resp.Main = d.Main
	return resp
}

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