60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
package model
|
|
|
|
import (
|
|
"approveflow/app/base"
|
|
"approveflow/app/provider/flow_definition"
|
|
)
|
|
|
|
// InstancePathConfig 动态路径配置表结构
|
|
type InstancePathConfig struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"` // 主键ID
|
|
NodeID int64 `gorm:"type:bigint;index;not null" json:"node_id"`
|
|
FromNodeKey string `gorm:"type:varchar(50);index;not null" json:"from_node_key"`
|
|
ToNodeKey string ` gorm:"type:varchar(50);index;not null" json:"to_node_key"`
|
|
IsParallel bool `gorm:"not null;default:false" json:"is_parallel"` // 是否并行
|
|
IsDynamic bool `gorm:"not null;default:false" json:"is_dynamic"` // 是否为动态步骤
|
|
Priority int `gorm:"not null;default:0" json:"priority"` // 路径优先级
|
|
flow_definition.ApprovalConditionCommon
|
|
base.Model
|
|
}
|
|
|
|
func (d InstancePathConfig) GetKey() string {
|
|
return d.Key
|
|
}
|
|
|
|
func (d InstancePathConfig) GetNodeID() int64 {
|
|
return d.NodeID
|
|
}
|
|
|
|
func (d InstancePathConfig) GetFromNodeKey() string {
|
|
return d.FromNodeKey
|
|
}
|
|
|
|
func (d InstancePathConfig) GetToNodeKey() string {
|
|
return d.ToNodeKey
|
|
}
|
|
|
|
// NewDynamicPathConfig 创建动态路径
|
|
func NewDynamicPathConfig(instanceID, nodeId int64, FromStepKey, ToStepKey string, isParallel bool) *InstancePathConfig {
|
|
pathConfig := &InstancePathConfig{
|
|
NodeID: nodeId,
|
|
FromNodeKey: FromStepKey,
|
|
ToNodeKey: ToStepKey,
|
|
IsParallel: isParallel,
|
|
Priority: 0,
|
|
}
|
|
return pathConfig
|
|
}
|
|
|
|
// IsConditionMet 判断路径条件是否满足
|
|
func (a *InstancePathConfig) IsConditionMet(data map[string]interface{}) (bool, error) {
|
|
if a.ConditionExpression == "" {
|
|
return true, nil // 无条件,默认满足
|
|
}
|
|
result, err := a.EvaluateCondition(data)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return result, nil
|
|
}
|