Эх сурвалжийг харах

添加使用内存查询规则的接口

yjp 9 сар өмнө
parent
commit
fc0de91e9f

+ 13 - 0
project/server/application/service/student.go

@@ -2,6 +2,8 @@ package service
 
 import (
 	"baize-demo/project/server/application/domain/student"
+	"fmt"
+	"git.sxidc.com/go-framework/baize/convenient/domain/query_rule"
 	"git.sxidc.com/go-framework/baize/convenient/domain/query_rule/rule"
 	"git.sxidc.com/go-framework/baize/convenient/entity_crud"
 	"git.sxidc.com/go-framework/baize/framework/binding"
@@ -125,4 +127,15 @@ func (svc *StudentService) v1(appInstance *application.App) {
 			}, nil
 		},
 	})
+
+	query_rule.AddUseQueryRuleQueryRoute[student.Info](v1Binder, &query_rule.AddUseQueryRuleQueryRouteParams{
+		DBSchema:   dbSchema,
+		DomainPath: "/student",
+		Object:     &student.Entity{},
+		QueryMiddlewares: []binding.Middleware{
+			func(c *api.Context, i *infrastructure.Infrastructure) {
+				fmt.Println("In Advanced Query")
+			},
+		},
+	})
 }

+ 2 - 1
project/server/main.go

@@ -26,8 +26,9 @@ 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 GET "http://localhost:31000/example/api/v1/student/get?id=d9332801b46c4f0c99fdd381954313d6"
-// curl -X DELETE "http://localhost:31000/example/api/v1/student/delete?id=d9332801b46c4f0c99fdd381954313d6"
+// curl -X DELETE "http://localhost:31000/example/api/v1/student/delete?id=d9332801b46c4f0c99fdd381954313d6
 
 // Family
 // curl -X POST -H "Content-Type: application/json" -d '{"father":"father", "mother": "mother"}' "http://localhost:31000/example/api/v1/family/create"