yjp před 9 měsíci
rodič
revize
53394c1974

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module baize-demo
 go 1.22.3
 
 require (
-	git.sxidc.com/go-framework/baize v1.5.14
+	git.sxidc.com/go-framework/baize v1.5.16
 	git.sxidc.com/go-tools/utils v1.5.29
 	git.sxidc.com/service-supports/fslog v0.5.9
 	git.sxidc.com/service-supports/scm-sdk v0.1.0

+ 4 - 1
project/server/application/service/student.go

@@ -128,7 +128,7 @@ func (svc *StudentService) v1(appInstance *application.App) {
 		},
 	})
 
-	query_rule.AddUseQueryRuleQueryRoute[student.Info](v1Binder, &query_rule.AddUseQueryRuleQueryRouteParams{
+	err := query_rule.AddUseQueryRuleQueryRoute[student.Info](v1Binder, &query_rule.AddUseQueryRuleQueryRouteParams{
 		DBSchema: dbSchema,
 		Object:   &student.Entity{},
 		QueryMiddlewares: []binding.Middleware{
@@ -137,4 +137,7 @@ func (svc *StudentService) v1(appInstance *application.App) {
 			},
 		},
 	})
+	if err != nil {
+		panic(err)
+	}
 }

+ 4 - 2
project/server/main.go

@@ -26,8 +26,10 @@ import (
 // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:31000/example/api/v1/student/create"
 // curl -X PUT -H "Content-Type: application/json" -d '{"id":"d9332801b46c4f0c99fdd381954313d6", "name":"test-new"}' "http://localhost:31000/example/api/v1/student/update"
 // curl -X GET "http://localhost:31000/example/api/v1/student/query?name=test-new&pageNo=1&pageSize=1"
-// curl -X POST -H "Content-Type: application/json" -d '{"pageNo":1, "pageSize":1, "rule": "{\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"contains\", \"value\": \"tes\"}"}' "http://localhost:31000/example/api/v1/student/advancedQuery"
-// 更复杂的高级查询 curl -X POST -H "Content-Type: application/json" -d '{"pageNo":1, "pageSize":1, "rule": "{\"logicalOperator\": \"or\", \"left\": {\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"eq\", \"value\": \"a\"}, \"right\": {\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"contains\", \"value\": \"tes\"}}"}' "http://localhost:31000/example/api/v1/student/advancedQuery"
+// curl -X POST -H "Content-Type: application/json" -d '{"rule": "{\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"contains\", \"value\": \"tes\"}"}' "http://localhost:31000/example/api/v1/student/queryRule/parse"
+// curl -X POST -H "Content-Type: application/json" -d '{"pageNo":1, "pageSize":1, "ruleClause":"\"name\" LIKE ?","ruleClauseArgs":["%tes%"]}' "http://localhost:31000/example/api/v1/student/advancedQuery"
+// 复杂查询 curl -X POST -H "Content-Type: application/json" -d '{"rule": "{\"logicalOperator\": \"or\", \"left\": {\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"eq\", \"value\": \"a\"}, \"right\": {\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"contains\", \"value\": \"tes\"}}"}' "http://localhost:31000/example/api/v1/student/queryRule/parse"
+// 复杂查询 curl -X POST -H "Content-Type: application/json" -d '{"pageNo":1, "pageSize":1, "ruleClause":"(\"name\" = ?) OR (\"name\" LIKE ?)","ruleClauseArgs":["a","%tes%"]}' "http://localhost:31000/example/api/v1/student/advancedQuery"
 // curl -X GET "http://localhost:31000/example/api/v1/student/get?id=d9332801b46c4f0c99fdd381954313d6"
 // curl -X DELETE "http://localhost:31000/example/api/v1/student/delete?id=d9332801b46c4f0c99fdd381954313d6