[feat] 依赖调整 git.fsdpf.net/go/contracts => git.fsdpf.net/go/req
This commit is contained in:
+16
-16
@@ -4,8 +4,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.fsdpf.net/go/condition"
|
||||
"git.fsdpf.net/go/contracts"
|
||||
"git.fsdpf.net/go/contracts/support"
|
||||
"git.fsdpf.net/go/condition/contracts"
|
||||
"git.fsdpf.net/go/req"
|
||||
)
|
||||
|
||||
type TestTable struct {
|
||||
@@ -21,23 +21,23 @@ type TestTable struct {
|
||||
func TestEngine(t *testing.T) {
|
||||
engine := Engine[any]{
|
||||
code: "TestTable",
|
||||
g: support.NewGlobalParam(`{"age": 30}`, nil),
|
||||
g: req.NewGlobalParam(`{"age": 30}`, nil),
|
||||
}
|
||||
|
||||
cond1 := condition.New(contracts.ConditionType_AND, "条件1")
|
||||
cond1 := condition.New(contracts.AND, "条件1")
|
||||
|
||||
cond1.SetExpr(condition.NewConditionExpr(
|
||||
"TestTable", "age", "age",
|
||||
contracts.ConditionOperator_EQ, contracts.ConditionTokenType_PARAM,
|
||||
contracts.EQ, contracts.PARAM,
|
||||
false, "", "",
|
||||
))
|
||||
|
||||
engine.Case(cond1, func(data any, g contracts.GlobalParams) error {
|
||||
engine.Case(cond1, func(data any, g req.GlobalParams) error {
|
||||
t.Log("cond1", data)
|
||||
return nil
|
||||
})
|
||||
|
||||
engine.Default(func(data any, g contracts.GlobalParams) error {
|
||||
engine.Default(func(data any, g req.GlobalParams) error {
|
||||
t.Log("default", data)
|
||||
return nil
|
||||
})
|
||||
@@ -60,43 +60,43 @@ func TestEngine(t *testing.T) {
|
||||
func TestRelationEngine(t *testing.T) {
|
||||
engine := Engine[any]{
|
||||
code: "TestTable",
|
||||
g: support.NewGlobalParam(`{"age": 30}`, nil),
|
||||
g: req.NewGlobalParam(`{"age": 30}`, nil),
|
||||
opts: engineOptions{
|
||||
debug: false,
|
||||
relations: []string{"TestTableA"},
|
||||
},
|
||||
}
|
||||
|
||||
cond1 := condition.New(contracts.ConditionType_AND, "条件1").
|
||||
cond1 := condition.New(contracts.AND, "条件1").
|
||||
SetExpr(condition.NewConditionExpr(
|
||||
"TestTable", "age", "age",
|
||||
contracts.ConditionOperator_EQ, contracts.ConditionTokenType_PARAM,
|
||||
contracts.EQ, contracts.PARAM,
|
||||
false, "", "",
|
||||
))
|
||||
|
||||
engine.Case(cond1, func(data any, g contracts.GlobalParams) error {
|
||||
engine.Case(cond1, func(data any, g req.GlobalParams) error {
|
||||
t.Log("cond1", data)
|
||||
return nil
|
||||
})
|
||||
|
||||
cond2 := condition.New(contracts.ConditionType_OR, "条件2").
|
||||
cond2 := condition.New(contracts.OR, "条件2").
|
||||
SetExpr(condition.NewConditionExpr(
|
||||
"TestTableA", "age", "age",
|
||||
contracts.ConditionOperator_EQ, contracts.ConditionTokenType_PARAM,
|
||||
contracts.EQ, contracts.PARAM,
|
||||
false, "", "",
|
||||
)).
|
||||
SetExpr(condition.NewConditionExpr(
|
||||
"TestTable", "age", "age",
|
||||
contracts.ConditionOperator_EQ, contracts.ConditionTokenType_PARAM,
|
||||
contracts.EQ, contracts.PARAM,
|
||||
false, "", "",
|
||||
))
|
||||
|
||||
engine.Case(cond2, func(data any, g contracts.GlobalParams) error {
|
||||
engine.Case(cond2, func(data any, g req.GlobalParams) error {
|
||||
t.Log("cond2", data)
|
||||
return nil
|
||||
})
|
||||
|
||||
engine.Default(func(data any, g contracts.GlobalParams) error {
|
||||
engine.Default(func(data any, g req.GlobalParams) error {
|
||||
t.Log("default", data)
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user