refactor and add outlet product table
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package transformer
|
||||
|
||||
import (
|
||||
"apskel-pos-be/internal/contract"
|
||||
"apskel-pos-be/internal/models"
|
||||
)
|
||||
|
||||
func CreateProductOutletPriceRequestToModel(req *contract.CreateProductOutletPriceRequest) *models.CreateProductOutletPriceRequest {
|
||||
if req == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &models.CreateProductOutletPriceRequest{
|
||||
ProductID: req.ProductID,
|
||||
OutletID: req.OutletID,
|
||||
Price: req.Price,
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateProductOutletPriceRequestToModel(req *contract.UpdateProductOutletPriceRequest) *models.UpdateProductOutletPriceRequest {
|
||||
if req == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &models.UpdateProductOutletPriceRequest{
|
||||
Price: &req.Price,
|
||||
}
|
||||
}
|
||||
|
||||
func ProductOutletPriceModelToResponse(m *models.ProductOutletPrice) *contract.ProductOutletPriceResponse {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &contract.ProductOutletPriceResponse{
|
||||
ID: m.ID,
|
||||
ProductID: m.ProductID,
|
||||
OutletID: m.OutletID,
|
||||
Price: m.Price,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func ProductOutletPriceModelsToResponses(ms []*models.ProductOutletPrice) []contract.ProductOutletPriceResponse {
|
||||
if ms == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
responses := make([]contract.ProductOutletPriceResponse, len(ms))
|
||||
for i, m := range ms {
|
||||
responses[i] = *ProductOutletPriceModelToResponse(m)
|
||||
}
|
||||
return responses
|
||||
}
|
||||
Reference in New Issue
Block a user