liuxiulin %!s(int64=2) %!d(string=hai) anos
pai
achega
76cfcd856c
Modificáronse 1 ficheiros con 9 adicións e 7 borrados
  1. 9 7
      services/knowoapi/services/rule_chain.go

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

@@ -65,18 +65,20 @@ func (a ruleChainService) Create(ruleChain *models.RuleChain) error {
 	return nil
 }
 
-func (a ruleChainService) create(ruleChain *models.RuleChainParams) error {
-	if len(ruleChain.Cell) == 0 {
+func (a ruleChainService) create(params *models.RuleChainParams) error {
+	if len(params.Cell) == 0 {
 		return nil
 	}
 
-	marshal, _ := json.Marshal(ruleChain.Cell)
+	fmt.Printf("%v", params)
+
+	marshal, _ := json.Marshal(params.Cell)
 	configuration := string(marshal)
 	fmt.Println(configuration)
 
 	nodeMap := make(map[string]models.RuleNode)
 	var inputNodeId string
-	for _, v := range ruleChain.Cell {
+	for _, v := range params.Cell {
 		if v.Shape != "edge" {
 			if v.Shape == "input-node" {
 				inputNodeId = v.Source.Cell
@@ -85,7 +87,7 @@ func (a ruleChainService) create(ruleChain *models.RuleChainParams) error {
 			ruleNode := models.RuleNode{
 				Model:       gorm.Model{},
 				RecordId:    guid.S(),
-				RuleChainID: ruleChain.RecordId,
+				RuleChainID: params.RecordId,
 				Type:        nodeType[v.Data.Type],
 				Name:        v.Data.Name,
 				DebugModel:  true,
@@ -135,11 +137,11 @@ func (a ruleChainService) create(ruleChain *models.RuleChainParams) error {
 		}
 	}
 
-	for _, v := range ruleChain.Cell {
+	for _, v := range params.Cell {
 		if v.Shape == "edge" && v.Source.Cell != inputNodeId {
 			err := a.model.Relation.Create(&models.Relation{
 				RecordId:    guid.S(),
-				RuleChainId: ruleChain.RecordId,
+				RuleChainId: params.RecordId,
 				FromID:      nodeMap[v.Source.Cell].RecordId,
 				//FromType:     nodeMap[v.Source.Cell].Type,
 				ToID:         nodeMap[v.Target.Cell].RecordId,