mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
50 lines
843 B
Go
50 lines
843 B
Go
package dto
|
|
|
|
import (
|
|
"time"
|
|
|
|
model "gitlab.com/mbugroup/lti-api.git/internal/modules/master/uoms/models"
|
|
)
|
|
|
|
// === DTO Structs ===
|
|
|
|
type UomBaseDTO struct {
|
|
Id uint `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type UomListDTO struct {
|
|
UomBaseDTO
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type UomDetailDTO struct {
|
|
UomListDTO
|
|
}
|
|
|
|
// === Mapper Functions ===
|
|
|
|
func ToUomBaseDTO(m model.Uom) UomBaseDTO {
|
|
return UomBaseDTO{
|
|
Id: m.Id,
|
|
Name: m.Name,
|
|
}
|
|
}
|
|
|
|
func ToUomListDTO(m model.Uom) UomListDTO {
|
|
return UomListDTO{
|
|
UomBaseDTO: ToUomBaseDTO(m),
|
|
CreatedAt: m.CreatedAt,
|
|
UpdatedAt: m.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func ToUomListDTOs(m []model.Uom) []UomListDTO {
|
|
result := make([]UomListDTO, len(m))
|
|
for i, r := range m {
|
|
result[i] = ToUomListDTO(r)
|
|
}
|
|
return result
|
|
}
|