Browse Source

CP, shop, fix product loading with NULL parent

Vova Tkach 5 years ago
parent
commit
eebec3738f
2 changed files with 36 additions and 29 deletions
  1. 14 15
      modules/module_shop.go
  2. 22 14
      utils/mysql_struct_shop_product.go

+ 14 - 15
modules/module_shop.go

@@ -810,20 +810,19 @@ func (this *Modules) RegisterModule_Shop() *Module {
 			}
 
 			data := utils.MySql_shop_product{
-				A_id:        0,
-				A_parent_id: 0,
-				A_user:      0,
-				A_currency:  0,
-				A_price:     0,
-				A_name:      "",
-				A_alias:     "",
-				A_vendor:    "",
-				A_quantity:  0,
-				A_category:  0,
-				A_briefly:   "",
-				A_content:   "",
-				A_datetime:  0,
-				A_active:    0,
+				A_id:       0,
+				A_user:     0,
+				A_currency: 0,
+				A_price:    0,
+				A_name:     "",
+				A_alias:    "",
+				A_vendor:   "",
+				A_quantity: 0,
+				A_category: 0,
+				A_briefly:  "",
+				A_content:  "",
+				A_datetime: 0,
+				A_active:   0,
 			}
 
 			if wrap.CurrSubModule == "modify" {
@@ -856,7 +855,7 @@ func (this *Modules) RegisterModule_Shop() *Module {
 					utils.StrToInt(wrap.UrlArgs[2]),
 				).Scan(
 					&data.A_id,
-					&data.A_parent_id,
+					&data.A_parent,
 					&data.A_user,
 					&data.A_currency,
 					&data.A_price,

+ 22 - 14
utils/mysql_struct_shop_product.go

@@ -1,18 +1,26 @@
 package utils
 
+import (
+	"database/sql"
+)
+
 type MySql_shop_product struct {
-	A_id        int
-	A_parent_id int
-	A_user      int
-	A_currency  int
-	A_price     float64
-	A_name      string
-	A_alias     string
-	A_vendor    string
-	A_quantity  int
-	A_category  int
-	A_briefly   string
-	A_content   string
-	A_datetime  int
-	A_active    int
+	A_id       int
+	A_parent   sql.NullInt64
+	A_user     int
+	A_currency int
+	A_price    float64
+	A_name     string
+	A_alias    string
+	A_vendor   string
+	A_quantity int
+	A_category int
+	A_briefly  string
+	A_content  string
+	A_datetime int
+	A_active   int
+}
+
+func (this *MySql_shop_product) A_parent_id() int {
+	return int(this.A_parent.Int64)
 }