package material import ( ecore "simrs-vx/internal/domain/base-entities/core" ein "simrs-vx/internal/domain/main-entities/infra" ei "simrs-vx/internal/domain/main-entities/item" eu "simrs-vx/internal/domain/main-entities/uom" ) type CreateDto struct { Code string `json:"code" validate:"maxLength=10"` Name string `json:"name" validate:"maxLength=50"` Uom_Code string `json:"uom_code" validate:"maxLength=10"` Infra_Code *string `json:"infra_code"` Stock *int `json:"stock"` Item_Code *string `json:"item_code"` } 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"` Uom_Code string `json:"uom-code"` Infra_Code *string `json:"infra-code"` Stock *int `json:"stock"` Item_Code *string `json:"item-code"` Search string `json:"search" gormhelper:"searchColumns=Code,Name"` } type ReadDetailDto struct { Id *uint16 `json:"id"` Code *string `json:"code"` Item_Id *uint `json:"item_id"` } type UpdateDto struct { Id *uint `json:"id"` CreateDto } type DeleteDto struct { Id *uint `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"` Uom_Code string `json:"uom_code"` Uom *eu.Uom `json:"uom,omitempty"` Infra_Code *string `json:"infra_code"` Infra *ein.Infra `json:"infra,omitempty"` Stock *int `json:"stock"` Item_Code *string `json:"item_code"` Item *ei.Item `json:"item,omitempty"` } func (d Material) ToResponse() ResponseDto { resp := ResponseDto{ Code: d.Code, Name: d.Name, Uom_Code: d.Uom_Code, Uom: d.Uom, Infra_Code: d.Infra_Code, Infra: d.Infra, Stock: d.Stock, Item_Code: d.Item_Code, Item: d.Item, } resp.Main = d.Main return resp } func ToResponseList(data []Material) []ResponseDto { resp := make([]ResponseDto, len(data)) for i, u := range data { resp[i] = u.ToResponse() } return resp }