init
This commit is contained in:
@@ -36,9 +36,6 @@ func CreateProductRequestToModel(apctx *appcontext.ContextInfo, req *contract.Cr
|
||||
if metadata == nil {
|
||||
metadata = make(map[string]interface{})
|
||||
}
|
||||
if req.Image != nil {
|
||||
metadata["image"] = *req.Image
|
||||
}
|
||||
|
||||
return &models.CreateProductRequest{
|
||||
OrganizationID: apctx.OrganizationID,
|
||||
@@ -49,6 +46,8 @@ func CreateProductRequestToModel(apctx *appcontext.ContextInfo, req *contract.Cr
|
||||
Price: req.Price,
|
||||
Cost: cost,
|
||||
BusinessType: businessType,
|
||||
ImageURL: req.ImageURL,
|
||||
PrinterType: req.PrinterType,
|
||||
Metadata: metadata,
|
||||
Variants: variants,
|
||||
}
|
||||
@@ -59,9 +58,7 @@ func UpdateProductRequestToModel(req *contract.UpdateProductRequest) *models.Upd
|
||||
if metadata == nil {
|
||||
metadata = make(map[string]interface{})
|
||||
}
|
||||
if req.Image != nil {
|
||||
metadata["image"] = *req.Image
|
||||
}
|
||||
|
||||
return &models.UpdateProductRequest{
|
||||
CategoryID: req.CategoryID,
|
||||
SKU: req.SKU,
|
||||
@@ -69,6 +66,8 @@ func UpdateProductRequestToModel(req *contract.UpdateProductRequest) *models.Upd
|
||||
Description: req.Description,
|
||||
Price: req.Price,
|
||||
Cost: req.Cost,
|
||||
ImageURL: req.ImageURL,
|
||||
PrinterType: req.PrinterType,
|
||||
Metadata: metadata,
|
||||
IsActive: req.IsActive,
|
||||
}
|
||||
@@ -98,7 +97,7 @@ func ProductModelResponseToResponse(prod *models.ProductResponse) *contract.Prod
|
||||
}
|
||||
}
|
||||
|
||||
response := &contract.ProductResponse{
|
||||
return &contract.ProductResponse{
|
||||
ID: prod.ID,
|
||||
OrganizationID: prod.OrganizationID,
|
||||
CategoryID: prod.CategoryID,
|
||||
@@ -108,14 +107,14 @@ func ProductModelResponseToResponse(prod *models.ProductResponse) *contract.Prod
|
||||
Price: prod.Price,
|
||||
Cost: prod.Cost,
|
||||
BusinessType: string(prod.BusinessType),
|
||||
ImageURL: prod.ImageURL,
|
||||
PrinterType: prod.PrinterType,
|
||||
Metadata: prod.Metadata,
|
||||
IsActive: prod.IsActive,
|
||||
CreatedAt: prod.CreatedAt,
|
||||
UpdatedAt: prod.UpdatedAt,
|
||||
Variants: variantResponses,
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
// Slice conversions
|
||||
|
||||
Reference in New Issue
Block a user