yjp 1 жил өмнө
parent
commit
b10fb85496

+ 1 - 1
go.mod

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

+ 2 - 2
go.sum

@@ -1,5 +1,5 @@
-git.sxidc.com/go-framework/baize v1.0.7-alpha1 h1:EtkrBeYbKODU+3vWFiNzMX4Nd355KiALuS9PsgpoOGc=
-git.sxidc.com/go-framework/baize v1.0.7-alpha1/go.mod h1:dgP7AeYY5PRS3jZHMby7ofPiCfDMBxuNeLRLP7B0iqs=
+git.sxidc.com/go-framework/baize v1.0.7-alpha9 h1:Q3Pfl8h2R6FtaXtTcgoO5YnxebDbqTybvGGIP5bEQcI=
+git.sxidc.com/go-framework/baize v1.0.7-alpha9/go.mod h1:dgP7AeYY5PRS3jZHMby7ofPiCfDMBxuNeLRLP7B0iqs=
 git.sxidc.com/go-tools/utils v1.5.23 h1:Kbcj+EafFVssRa6i1jnILi+LddLWMDtyvRzuV26C6fU=
 git.sxidc.com/go-tools/utils v1.5.23/go.mod h1:uTDb6QK5JZzK5+Fzsfeng7TwmnRDZiTY6JLYxIX94Qw=
 git.sxidc.com/service-supports/ds-sdk v0.10.9 h1:KxoGUM+rP30rP81fARPwRMwDSJFaGsk8TjdINGTDIto=

+ 10 - 0
project/server/application/domain/student/entity.go

@@ -103,3 +103,13 @@ func (e *Entity) checkUpdateFields(checkResult check.Result) error {
 
 	return nil
 }
+
+func (e *Entity) FormQueryRuleParams() map[string]any {
+	ruleParams := make(map[string]any)
+
+	if strutils.IsStringNotEmpty(e.Name) {
+		ruleParams[ColumnName] = e.Name
+	}
+
+	return ruleParams
+}

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

@@ -76,9 +76,7 @@ func (svc *StudentService) v1(appInstance *application.App) {
 				return queryFunc(c, params, objects, i)
 			}
 
-			ruleParams := make(map[string]any, 0)
-
-			conditionClause, err := query_rule.GetRulesAndFormConditionClause(dbSchema, "global", e.DomainCamelName(), i)
+			conditionClause, err := query_rule.GetRulesAndFormConditionClause(dbSchema, "global", e.DomainCamelName(), i, e.FormQueryRuleParams())
 			if err != nil {
 				return errResponse, err
 			}

+ 8 - 2
project/server/deployment/data_service/data_containers/query_rule.yaml

@@ -6,18 +6,24 @@ spec:
   spec:
     table_name: test.query_rules
     columns:
+      - name: id
+        type: "varchar(32)"
+        comment: id
+        primary_key: true
       - name: scope
         type: varchar(256)
         comment: 范围
         not_null: true
-        primary_key: true
       - name: domain_name
         type: varchar(256)
         comment: 领域名
         not_null: true
-        primary_key: true
       - name: rule
         type: text
         comment: 规则
         not_null: true
+      - name: enabled
+        type: boolean
+        comment: 是否启用
+        not_null: true
 

+ 8 - 2
project/server/main.go

@@ -84,8 +84,14 @@ import (
 
 // Query Rule
 // curl -X GET "http://localhost:31000/example/api/queryRuleDefinition/get?domainName=Student"
-// curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student", "rule": "[{\"fieldName\": \"Name\", \"fieldType\": \"string\", \"columnName\": \"name\", \"operator\": \"eq\", \"value\": \"test\"}]"}' "http://localhost:31000/example/api/queryRule/create"
-// curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student"}' "http://localhost:31000/example/api/queryRule/get"
+// curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student", "rule": "{\"fieldName\": \"Name\", \"fieldType\": \"string\", \"columnName\": \"name\", \"operator\": \"eq\", \"value\": \"test\"}"}' "http://localhost:31000/example/api/queryRule/create"
+// curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student", "rule": "{\"fieldName\": \"Name\", \"fieldType\": \"string\", \"columnName\": \"name\", \"operator\": \"contains\"}"}' "http://localhost:31000/example/api/queryRule/create"
+// curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student"}' "http://localhost:31000/example/api/queryRule/query"
+// curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student"}' "http://localhost:31000/example/api/queryRule/enabled/get"
+// curl -X POST -H 'Content-Type: application/json' -d '{"id": "7011cde771a045a885872529ab77e79b"}' "http://localhost:31000/example/api/queryRule/enable"
+// curl -X POST -H 'Content-Type: application/json' -d '{"id": "7011cde771a045a885872529ab77e79b"}' "http://localhost:31000/example/api/queryRule/disable"
+// curl -X DELETE "http://localhost:31000/example/api/queryRule/delete?id=7011cde771a045a885872529ab77e79b"
+// curl -X DELETE "http://localhost:31000/example/api/queryRule/delete?id=597ad3bbb97d4b7aa5196cd9366f07f2"
 
 func main() {
 	application.NewApp()