yjp пре 1 година
родитељ
комит
8989c6615b

+ 12 - 0
project/gateway/api/root/configuration.go

@@ -0,0 +1,12 @@
+package root
+
+import (
+	"baize-demo/project/gateway/config"
+	"git.sxidc.com/go-framework/baize/convenient/domain_gateway/configuration"
+	"git.sxidc.com/go-framework/baize/framework/gateway"
+)
+
+func configurationGateway(gw *gateway.Gateway) {
+	configuration.RegisterService("example", config.GetConfig().ServicesConfig.ExampleBaseUrl)
+	configuration.BuildGateway(gw)
+}

+ 0 - 10
project/gateway/api/root/example/configuration.go

@@ -1,10 +0,0 @@
-package example
-
-import (
-	"git.sxidc.com/go-framework/baize/convenient/domain_gateway"
-	"git.sxidc.com/go-framework/baize/framework/gateway"
-)
-
-func configurationGateway(builder *gateway.Builder) {
-	domain_gateway.ConfigurationGateway(serviceVersionedUrl, builder)
-}

+ 0 - 15
project/gateway/api/root/example/example.go

@@ -1,15 +0,0 @@
-package example
-
-import (
-	"baize-demo/project/gateway/config"
-	"git.sxidc.com/go-framework/baize/framework/gateway"
-)
-
-var (
-	serviceVersionedUrl = config.GetConfig().ServicesConfig.ExampleBaseUrl + "/example/api"
-)
-
-func InitGateway(builder *gateway.Builder) {
-	configurationGateway(builder)
-	sqlExecutorGateway(builder)
-}

+ 0 - 11
project/gateway/api/root/example/sql_executor.go

@@ -1,11 +0,0 @@
-package example
-
-import (
-	"baize-demo/project/gateway/config"
-	"git.sxidc.com/go-framework/baize/convenient/domain_gateway"
-	"git.sxidc.com/go-framework/baize/framework/gateway"
-)
-
-func sqlExecutorGateway(builder *gateway.Builder) {
-	domain_gateway.SqlExecutorGateway(config.GetConfig().ServicesConfig.ExampleBaseUrl, builder)
-}

+ 2 - 4
project/gateway/api/root/root.go

@@ -1,14 +1,12 @@
 package root
 package root
 
 
 import (
 import (
-	"baize-demo/project/gateway/api/root/example"
-	"git.sxidc.com/go-framework/baize/framework/core/api"
 	"git.sxidc.com/go-framework/baize/framework/gateway"
 	"git.sxidc.com/go-framework/baize/framework/gateway"
 )
 )
 
 
 type Router struct{}
 type Router struct{}
 
 
 func (router *Router) Init(gw *gateway.Gateway) {
 func (router *Router) Init(gw *gateway.Gateway) {
-	builder := gw.NewBuilder(api.RouterPrefix, "")
-	example.InitGateway(builder)
+	configurationGateway(gw)
+	sqlExecutorGateway(gw)
 }
 }

+ 12 - 0
project/gateway/api/root/sql_executor.go

@@ -0,0 +1,12 @@
+package root
+
+import (
+	"baize-demo/project/gateway/config"
+	"git.sxidc.com/go-framework/baize/convenient/domain_gateway/sql_executor"
+	"git.sxidc.com/go-framework/baize/framework/gateway"
+)
+
+func sqlExecutorGateway(gw *gateway.Gateway) {
+	sql_executor.RegisterService("example", config.GetConfig().ServicesConfig.ExampleBaseUrl)
+	sql_executor.BuildGateway(gw)
+}

+ 10 - 8
project/gateway/main.go

@@ -10,16 +10,17 @@ import (
 // curl -X GET "http://localhost:32000/gateway/api/version"
 // curl -X GET "http://localhost:32000/gateway/api/version"
 
 
 // Configuration
 // Configuration
-// curl -X POST -H "Content-Type: application/json" -d '{"scope": "global", "group":"test", "value":"test-value"}' "http://localhost:32000/gateway/api/configuration/create"
-// curl -X GET "http://localhost:32000/gateway/api/configuration/values?scope=global&group=test&pageNo=1&pageSize=1"
-// curl -X POST -H "Content-Type: application/json" -d '{"scope": "global", "group":"test"}' "http://localhost:32000/gateway/api/configuration/delete"
+// curl -X POST -H "Content-Type: application/json" -d '{"serviceShortName": "example", "scope": "global", "group":"test", "value":"test-value"}' "http://localhost:32000/gateway/api/configuration/create"
+// curl -X GET "http://localhost:32000/gateway/api/configuration/values?serviceShortName=example&scope=global&group=test&pageNo=1&pageSize=1"
+// curl -X POST -H "Content-Type: application/json" -d '{"serviceShortName": "example", "scope": "global", "group":"test"}' "http://localhost:32000/gateway/api/configuration/delete"
+// curl -X GET "http://localhost:32000/gateway/api/configuration/registered/services"
 
 
 // Class
 // Class
 // curl -X POST -H "Content-Type: application/json" -d '{"name":"test", "studentNum": 10}' "http://localhost:32000/gateway/api/v1/class/create"
 // curl -X POST -H "Content-Type: application/json" -d '{"name":"test", "studentNum": 10}' "http://localhost:32000/gateway/api/v1/class/create"
-// curl -X PUT -H "Content-Type: application/json" -d '{"id":"3d94607a0df14cebae4f4aa70ef4d0c1", "name":"test-new"}' "http://localhost:32000/gateway/api/v1/class/update"
+// curl -X PUT -H "Content-Type: application/json" -d '{"id":"5a1645efeff64852a41b28268b232209", "name":"test-new"}' "http://localhost:32000/gateway/api/v1/class/update"
 // curl -X GET "http://localhost:32000/gateway/api/v1/class/query?name=test-new&pageNo=1&pageSize=1"
 // curl -X GET "http://localhost:32000/gateway/api/v1/class/query?name=test-new&pageNo=1&pageSize=1"
-// curl -X GET "http://localhost:32000/gateway/api/v1/class/get?id=3d94607a0df14cebae4f4aa70ef4d0c1"
-// curl -X DELETE "http://localhost:32000/gateway/api/v1/class/delete?id=3d94607a0df14cebae4f4aa70ef4d0c1"
+// curl -X GET "http://localhost:32000/gateway/api/v1/class/get?id=5a1645efeff64852a41b28268b232209"
+// curl -X DELETE "http://localhost:32000/gateway/api/v1/class/delete?id=5a1645efeff64852a41b28268b232209"
 
 
 // Student
 // Student
 // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:32000/gateway/api/v1/student/create"
 // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:32000/gateway/api/v1/student/create"
@@ -78,8 +79,9 @@ import (
 // curl -X GET "http://localhost:31000/example/api/v1/hobby/student/query?id=42b305bb292c4082a3e91a2967f11111"
 // curl -X GET "http://localhost:31000/example/api/v1/hobby/student/query?id=42b305bb292c4082a3e91a2967f11111"
 
 
 // Sql Executor
 // Sql Executor
-// curl -X POST -H 'Content-Type: application/json' -d '{"urlPrefix": "example", "sql": "SELECT * FROM test.sql_execute_logs", "executorId": "guest-00254b4a7102429db35e6edc8e", "executorName": "test"}' "http://localhost:32000/gateway/api/sql/execute"
-// curl -X GET "http://localhost:32000/gateway/api/sql/execute/log?urlPrefix=example&sql=SELECT&executorId=guest-00254b4a7102429db35e6edc8e&executorName=te&startExecuteTime=2024-05-30%2012:03:45"
+// curl -X POST -H 'Content-Type: application/json' -d '{"serviceShortName": "example", "sql": "SELECT * FROM test.sql_execute_logs", "executorId": "guest-00254b4a7102429db35e6edc8e"}' "http://localhost:32000/gateway/api/sql/execute"
+// curl -X GET "http://localhost:32000/gateway/api/sql/execute/log?serviceShortName=example&sql=SELECT&executorId=guest-00254b4a7102429db35e6edc8e&executorName=gue"
+// curl -X GET "http://localhost:32000/gateway/api/sql/execute/registered/services"
 
 
 func main() {
 func main() {
 	api.NewGateway()
 	api.NewGateway()

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

@@ -2,8 +2,6 @@ package service
 
 
 import (
 import (
 	"git.sxidc.com/go-framework/baize/convenient/domain/configuration"
 	"git.sxidc.com/go-framework/baize/convenient/domain/configuration"
-	"git.sxidc.com/go-framework/baize/framework/binding"
-	"git.sxidc.com/go-framework/baize/framework/core/api"
 	"git.sxidc.com/go-framework/baize/framework/core/application"
 	"git.sxidc.com/go-framework/baize/framework/core/application"
 )
 )
 
 
@@ -21,8 +19,7 @@ func (svc *ConfigurationService) Destroy() error {
 }
 }
 
 
 func (svc *ConfigurationService) prefixRoot(appInstance *application.App) {
 func (svc *ConfigurationService) prefixRoot(appInstance *application.App) {
-	prefixRootBinder := binding.NewBinder(appInstance.ChooseRouter(api.RouterPrefix, ""), appInstance.Infrastructure())
-	configuration.BindConfiguration(prefixRootBinder, &configuration.Simple{
+	configuration.BindConfiguration(appInstance, &configuration.Simple{
 		Schema: dbSchema,
 		Schema: dbSchema,
 	})
 	})
 }
 }

+ 1 - 5
project/server/application/service/sql_executor.go

@@ -2,8 +2,6 @@ package service
 
 
 import (
 import (
 	"git.sxidc.com/go-framework/baize/convenient/domain/sql_executor"
 	"git.sxidc.com/go-framework/baize/convenient/domain/sql_executor"
-	"git.sxidc.com/go-framework/baize/framework/binding"
-	"git.sxidc.com/go-framework/baize/framework/core/api"
 	"git.sxidc.com/go-framework/baize/framework/core/application"
 	"git.sxidc.com/go-framework/baize/framework/core/application"
 )
 )
 
 
@@ -21,7 +19,5 @@ func (svc *SqlExecutorService) Destroy() error {
 }
 }
 
 
 func (svc *SqlExecutorService) prefixRoot(appInstance *application.App) {
 func (svc *SqlExecutorService) prefixRoot(appInstance *application.App) {
-	prefixRootBinder := binding.NewBinder(appInstance.ChooseRouter(api.RouterPrefix, ""), appInstance.Infrastructure())
-
-	sql_executor.BindSqlExecutor(prefixRootBinder, &sql_executor.Simple{Schema: dbSchema})
+	sql_executor.BindSqlExecutor(appInstance, &sql_executor.Simple{Schema: dbSchema})
 }
 }

+ 4 - 4
quick_start/main.go

@@ -38,8 +38,8 @@ func main() {
 	rootBinder := binding.NewBinder(app.ChooseRouter(api.RouterRoot, ""), app.Infrastructure())
 	rootBinder := binding.NewBinder(app.ChooseRouter(api.RouterRoot, ""), app.Infrastructure())
 
 
 	binding.GetBind(rootBinder, &binding.SimpleBindItem[any]{
 	binding.GetBind(rootBinder, &binding.SimpleBindItem[any]{
-		Path:         "/ping",
-		ResponseFunc: response.NoResponse,
+		Path:             "/ping",
+		SendResponseFunc: response.NoResponse,
 		ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (any, error) {
 		ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (any, error) {
 			c.String(http.StatusOK, "pong")
 			c.String(http.StatusOK, "pong")
 			return nil, nil
 			return nil, nil
@@ -69,8 +69,8 @@ func main() {
 	prefixRootBinder := binding.NewBinder(app.ChooseRouter(api.RouterPrefix, "v1"), app.Infrastructure())
 	prefixRootBinder := binding.NewBinder(app.ChooseRouter(api.RouterPrefix, "v1"), app.Infrastructure())
 
 
 	binding.GetBind(prefixRootBinder, &binding.SimpleBindItem[any]{
 	binding.GetBind(prefixRootBinder, &binding.SimpleBindItem[any]{
-		Path:         "/ping",
-		ResponseFunc: response.NoResponse,
+		Path:             "/ping",
+		SendResponseFunc: response.NoResponse,
 		ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (any, error) {
 		ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (any, error) {
 			c.String(http.StatusOK, "pong")
 			c.String(http.StatusOK, "pong")
 			return nil, nil
 			return nil, nil