| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package handler
-
- import (
- "encoding/json"
- "log"
-
- "git.x2erp.com/qdy/go-base/ctx"
- "git.x2erp.com/qdy/go-base/middleware"
- "git.x2erp.com/qdy/go-base/model/response"
- "git.x2erp.com/qdy/go-base/webx/router"
- "git.x2erp.com/qdy/go-db/factory/database"
- )
-
- func RegisterRouter(ws *router.RouterService, dbFactory *database.DBFactory) {
-
- // POST示例:Body参数绑定
- ws.POST("/api/tenant/config",
- func(req ctx.RequestContext, reqCtx *ctx.RequestContext) (*response.QueryResult[interface{}], error) {
- log.Print("ctx TenantID:", reqCtx.TenantID)
- //log.Print("mongoDBFactory:", mongoDBFactory.GetConfig().URI)
- //log.Print("dbFactory:", dbFactory.GetDBName())
- jsonBytes, _ := json.Marshal(req)
- log.Printf("TenantConfig :%s", string(jsonBytes))
-
- //queryResult, err := dbFactory.InsertOne("tenant_configs", req)
- //log.Print("TenantConfig InsertOne:", queryResult)
- // req 自动从JSON Body绑定
- return nil, nil
- },
- ).Use(middleware.JWTAuthMiddleware).Register()
-
- // // 您的业务路由
- // ws.POST("/api/query/yaml",
- // func() (interface{}, error) {
- // return queryYaml(nil) // 需要修改queryYaml函数以获取dbFactory
- // },
- // ).Use(middleware.JWTAuthMiddleware).Register()
-
- // ws.POST("/api/init/config/template",
- // func() (interface{}, error) {
- // return initConfigTemplate(nil) // 需要修改initConfigTemplate函数以获取dbFactory
- // },
- // ).Use(middleware.JWTAuthMiddleware).Register()
-
- }
|