mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
feat(BE-229,234,235,230,231,232,233): purchase request and purchase order and fix master data dto
This commit is contained in:
@@ -12,16 +12,17 @@ import (
|
||||
// === DTO Structs ===
|
||||
|
||||
type NonstockBaseDTO struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
UomID uint `json:"uom_id"`
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Uom *uomDTO.UomBaseDTO `json:"uom,omitempty"`
|
||||
Flags []string `json:"flags"`
|
||||
}
|
||||
|
||||
type NonstockListDTO struct {
|
||||
NonstockBaseDTO
|
||||
Uom *uomDTO.UomBaseDTO `json:"uom,omitempty"`
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Uom *uomDTO.UomBaseDTO `json:"uom"`
|
||||
Suppliers []supplierDTO.SupplierBaseDTO `json:"suppliers"`
|
||||
Flags []string `json:"flags"`
|
||||
CreatedUser *userDTO.UserBaseDTO `json:"created_user"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
@@ -35,10 +36,22 @@ type NonstockDetailDTO struct {
|
||||
// === Mapper Functions ===
|
||||
|
||||
func ToNonstockBaseDTO(e entity.Nonstock) NonstockBaseDTO {
|
||||
var uomRef *uomDTO.UomBaseDTO
|
||||
if e.Uom.Id != 0 {
|
||||
mapped := uomDTO.ToUomBaseDTO(e.Uom)
|
||||
uomRef = &mapped
|
||||
}
|
||||
|
||||
flags := make([]string, len(e.Flags))
|
||||
for i, f := range e.Flags {
|
||||
flags[i] = f.Name
|
||||
}
|
||||
|
||||
return NonstockBaseDTO{
|
||||
Id: e.Id,
|
||||
Name: e.Name,
|
||||
UomID: e.UomId,
|
||||
Uom: uomRef,
|
||||
Flags: flags,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,13 +79,13 @@ func ToNonstockListDTO(e entity.Nonstock) NonstockListDTO {
|
||||
}
|
||||
|
||||
return NonstockListDTO{
|
||||
NonstockBaseDTO: ToNonstockBaseDTO(e),
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
CreatedUser: createdUser,
|
||||
Uom: uomRef,
|
||||
Suppliers: suppliers,
|
||||
Flags: flags,
|
||||
Id: e.Id,
|
||||
Name: e.Name,
|
||||
Uom: uomRef,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
CreatedUser: createdUser,
|
||||
Suppliers: suppliers,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user