diff --git a/controllers/product_templates_controller.go b/controllers/product_templates_controller.go index bc4f684..299fdb1 100644 --- a/controllers/product_templates_controller.go +++ b/controllers/product_templates_controller.go @@ -85,7 +85,7 @@ func GetProductTemplate(c *gin.Context) { return } - err = json.Unmarshal(productTemplate.Config, &productTemplate.ProductTemplateConfig) + err = json.Unmarshal([]byte(productTemplate.Config), &productTemplate.ProductTemplateConfig) if err != nil { log.Printf("GetProductTemplate Error: Could not fetch product template config: %v", err) c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not fetch product template config"}) diff --git a/main.go b/main.go index b0e5b2d..359fba9 100644 --- a/main.go +++ b/main.go @@ -48,6 +48,8 @@ func main() { // Add User and Device resources Admin.AddResource(&models.User{}) Admin.AddResource(&models.Device{}) + Admin.AddResource(&models.Buyer{}) + Admin.AddResource(&models.ProductTemplate{}) // Initialize HTTP request multiplexer mux := http.NewServeMux() // Mount admin interface to mux diff --git a/models/product_template.go b/models/product_template.go index 983a35e..28c9519 100644 --- a/models/product_template.go +++ b/models/product_template.go @@ -1,12 +1,14 @@ package models -import "github.com/jinzhu/gorm" +import ( + "github.com/jinzhu/gorm" +) type ProductTemplate struct { gorm.Model Name string ProductTemplateConfig map[string]interface{} `json:",omitempty" sql:"-"` - Config JSON `json:"-" gorm:"embedded"` + Config string `json:"raw_config" gorm:"type:json"` } func (ProductTemplate) Update() (bool, error) {