package division 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=50"` Parent_Id *uint16 `json:"parent_id"` } type ReadListDto struct { FilterDto Includes string `json:"includes"` Preloads []string `json:"-"` Search string `json:"search"` Pagination ecore.Pagination OnlyHaveChildren bool `json:"only-have-children"` } type FilterDto struct { Code string `json:"code"` Name string `json:"name"` Parent_Id *uint16 `json:"parent-id"` } 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"` } type MetaDto struct { PageNumber int `json:"page_number"` PageSize int `json:"page_size"` Count int `json:"count"` } type ResponseDto struct { ecore.SmallMain Code string `json:"code"` Name string `json:"name"` Parent_Id *uint16 `json:"parent_id"` Parent *Division `json:"parent,omitempty"` Childrens []Division `json:"childrens,omitempty"` } func (d Division) ToResponse() ResponseDto { resp := ResponseDto{ Code: d.Code, Name: d.Name, Parent_Id: d.Parent_Id, Parent: d.Parent, Childrens: d.Childrens, } resp.SmallMain = d.SmallMain return resp } func ToResponseList(data []Division) []ResponseDto { resp := make([]ResponseDto, len(data)) for i, u := range data { resp[i] = u.ToResponse() } return resp }