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