diff --git a/api/openapi/provider/brainx/demo.api b/api/openapi/provider/brainx/demo.api index c7776147..5a0613a9 100644 --- a/api/openapi/provider/brainx/demo.api +++ b/api/openapi/provider/brainx/demo.api @@ -11,6 +11,7 @@ info( @server( group: openapi/provider/brainx prefix: /openapi/v1/provider/brainx + middleware: OpenAPIJWTAuth ) service PowerX { diff --git a/internal/handler/routes.go b/internal/handler/routes.go index 51599573..29118615 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -1415,6 +1415,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { rest.WithPrefix("/api/v1/admin/position"), ) + server.AddRoutes( + rest.WithMiddlewares( + []rest.Middleware{serverCtx.UserJWTAuth}, + []rest.Route{ + { + // App发送图文信息 + Method: http.MethodPost, + Path: "/message/articles", + Handler: adminscrmapp.SendWeWorkAppArticleMessageHandler(serverCtx), + }, + }..., + ), + rest.WithPrefix("/api/v1/admin/scrm/app/wechat"), + ) + server.AddRoutes( rest.WithMiddlewares( []rest.Middleware{serverCtx.UserJWTAuth}, @@ -1463,21 +1478,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { rest.WithPrefix("/api/v1/admin/scrm/app/wechat"), ) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.UserJWTAuth}, - []rest.Route{ - { - // App发送图文信息 - Method: http.MethodPost, - Path: "/message/articles", - Handler: adminscrmapp.SendWeWorkAppArticleMessageHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/api/v1/admin/scrm/app/wechat"), - ) - server.AddRoutes( rest.WithMiddlewares( []rest.Middleware{serverCtx.UserJWTAuth}, @@ -1543,16 +1543,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Middleware{serverCtx.UserJWTAuth}, []rest.Route{ { - // 所有客户列表/page + // 客户群列表/limit Method: http.MethodPost, - Path: "/page", - Handler: adminscrmcustomer.ListWeWorkCustomerPageHandler(serverCtx), + Path: "/group/list", + Handler: adminscrmcustomer.ListWeWorkCustomerGroupLimitHandler(serverCtx), }, { - // 批量同步客户信息(根据员工ID同步/节流) + // 客户群发信息 Method: http.MethodPost, - Path: "/sync", - Handler: adminscrmcustomer.SyncWeWorkCustomerOptionHandler(serverCtx), + Path: "/group/message/template", + Handler: adminscrmcustomer.SendWeWorkCustomerGroupMessageHandler(serverCtx), }, }..., ), @@ -1564,16 +1564,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Middleware{serverCtx.UserJWTAuth}, []rest.Route{ { - // 客户群列表/limit + // 所有客户列表/page Method: http.MethodPost, - Path: "/group/list", - Handler: adminscrmcustomer.ListWeWorkCustomerGroupLimitHandler(serverCtx), + Path: "/page", + Handler: adminscrmcustomer.ListWeWorkCustomerPageHandler(serverCtx), }, { - // 客户群发信息 + // 批量同步客户信息(根据员工ID同步/节流) Method: http.MethodPost, - Path: "/group/message/template", - Handler: adminscrmcustomer.SendWeWorkCustomerGroupMessageHandler(serverCtx), + Path: "/sync", + Handler: adminscrmcustomer.SyncWeWorkCustomerOptionHandler(serverCtx), }, }..., ), @@ -2057,16 +2057,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { server.AddRoutes( []rest.Route{ { - // 查询产品品类列表 + // 查询产品详情 Method: http.MethodGet, - Path: "/product-categories", - Handler: mpcrmproduct.ListProductCategoriesHandler(serverCtx), + Path: "/products/:id", + Handler: mpcrmproduct.GetProductHandler(serverCtx), }, { - // 查询产品品类树形表 + // 产品列表 Method: http.MethodGet, - Path: "/product-category-tree", - Handler: mpcrmproduct.ListProductCategoryTreeHandler(serverCtx), + Path: "/products/page-list", + Handler: mpcrmproduct.ListProductsPageHandler(serverCtx), }, }, rest.WithPrefix("/api/v1/mp/product"), @@ -2075,16 +2075,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { server.AddRoutes( []rest.Route{ { - // 查询产品详情 + // 查询产品品类列表 Method: http.MethodGet, - Path: "/products/:id", - Handler: mpcrmproduct.GetProductHandler(serverCtx), + Path: "/product-categories", + Handler: mpcrmproduct.ListProductCategoriesHandler(serverCtx), }, { - // 产品列表 + // 查询产品品类树形表 Method: http.MethodGet, - Path: "/products/page-list", - Handler: mpcrmproduct.ListProductsPageHandler(serverCtx), + Path: "/product-category-tree", + Handler: mpcrmproduct.ListProductCategoryTreeHandler(serverCtx), }, }, rest.WithPrefix("/api/v1/mp/product"), @@ -2534,20 +2534,23 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { ) server.AddRoutes( - []rest.Route{ - { - // timeout api for provider demo - Method: http.MethodPost, - Path: "/echo-long-time", - Handler: openapiproviderbrainx.EchoLongTimeHandler(serverCtx), - }, - { - // hello world api for provider demo - Method: http.MethodGet, - Path: "/hello-world", - Handler: openapiproviderbrainx.HelloWorldHandler(serverCtx), - }, - }, + rest.WithMiddlewares( + []rest.Middleware{serverCtx.OpenAPIJWTAuth}, + []rest.Route{ + { + // timeout api for provider demo + Method: http.MethodPost, + Path: "/echo-long-time", + Handler: openapiproviderbrainx.EchoLongTimeHandler(serverCtx), + }, + { + // hello world api for provider demo + Method: http.MethodGet, + Path: "/hello-world", + Handler: openapiproviderbrainx.HelloWorldHandler(serverCtx), + }, + }..., + ), rest.WithPrefix("/openapi/v1/provider/brainx"), )