liuxiulin 2 лет назад
Родитель
Сommit
50f7b3548c
2 измененных файлов с 10 добавлено и 4 удалено
  1. 3 3
      services/knowoapi/model/rule_chain.go
  2. 7 1
      services/knowoapi/services/rule_chain.go

+ 3 - 3
services/knowoapi/model/rule_chain.go

@@ -67,10 +67,10 @@ func (a *RuleChain) Update(ruleChain *models.RuleChain) error {
 }
 
 // UpdateChainRoot 设置规则链
-func (a *RuleChain) UpdateChainRoot(vendorId string, id string, isRoot int) error {
-	err := a.db.Where("vendor_id = ? and record_id = ?", vendorId, id).
+func (a *RuleChain) UpdateChainRoot(vendorId string, id string, isRoot int) (data models.RuleChain, err error) {
+	err = a.db.Model(&data).Where("vendor_id = ? and record_id = ?", vendorId, id).
 		Update(map[string]interface{}{
 			"root": isRoot,
 		}).Error
-	return err
+	return
 }

+ 7 - 1
services/knowoapi/services/rule_chain.go

@@ -74,6 +74,8 @@ func (a ruleChainService) create(ruleChain *models.RuleChain) error {
 	if len(ruleChain.Cell) == 0 {
 		return nil
 	}
+	fmt.Println("=================================")
+	fmt.Println(ruleChain.Cell)
 	marshal, _ := json.Marshal(ruleChain.Cell)
 	ruleChain.Configuration = fmt.Sprintf("%s", marshal)
 	fmt.Println("++++++++++++++++++++++++++++++++")
@@ -235,5 +237,9 @@ func (a ruleChainService) UpdateChainRoot(ruleChain *models.RuleChain) error {
 	if ruleChain.Root {
 		isRoot = 1
 	}
-	return a.model.RuleChain.UpdateChainRoot(ruleChain.VendorID, ruleChain.RecordId, isRoot)
+	_, err := a.model.RuleChain.UpdateChainRoot(ruleChain.VendorID, ruleChain.RecordId, isRoot)
+	if err != nil {
+		return err
+	}
+	return nil
 }