From 075c1215caf1e11e5eb25135a22cd46415c91e47 Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Thu, 28 May 2026 21:46:33 -0700 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F:=20=E6=92=A4=E9=94=80=20fefb?= =?UTF-8?q?d4f5=20=E7=9A=84=20go-zero=20stub=20=E6=96=B9=E6=A1=88=EF=BC=8C?= =?UTF-8?q?=E5=9B=9E=E5=88=B0=20goctl=201.7.2=20+=20gin=20=E5=8E=9F?= =?UTF-8?q?=E7=94=9F=20routes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fefbd4f5 (#104) 用本地 third_party/gozero stub 假冒 go-zero 依赖, 让 goctl 1.9.2 生成的 rest.Server/rest.Route 风格 routes.go 能编译, 但带来非标 vendor、Dockerfile 漏拷、新人误解等维护成本。 本次回到 fefbd4f5 之前的方案: - routes.go 用 gin 原生 publicUserGroupRouter.GET(...) 风格(goctl 1.7.2) - server.go 直接 handler.RegisterHandlers(r, svc),无需 rest.NewGinServer - svc/serviceContext.go 不再持有 AuthMiddleware/DeviceMiddleware/ServerMiddleware 字段 - go.mod 删除 zeromicro/go-zero require + replace 指令 - 删除 third_party/gozero/ stub 模块 - 删除 fefbd4f5 引入的 28 个 goctl 生成的空 stub 文件和 nodeserver/apple 转发器 - Dockerfile 不再需要 COPY third_party/ invite_sales 还原路由保留(gin 老风格写法)。 --- Dockerfile | 3 +- go.mod | 3 - .../handler/common/checkCodeLegacyAlias.go | 52 - .../handler/common/checkcodelegacyhandler.go | 1 - .../common/checkcodelegacyv2handler.go | 1 - .../handler/common/reportlogmessagehandler.go | 1 - .../handler/common/submitcontacthandler.go | 1 - .../node/server/getserverconfighandler.go | 11 - .../node/server/getserveruserlisthandler.go | 11 - .../node/server/pushonlineusershandler.go | 11 - .../queryserverprotocolconfighandler.go | 11 - .../node/server/serverpushstatushandler.go | 11 - .../server/serverpushusertraffichandler.go | 11 - .../attachappletransactionbyidhandler.go | 1 - .../apple/attachappletransactionhandler.go | 1 - .../public/iap/apple/getapplestatushandler.go | 1 - .../apple/restoreappletransactionshandler.go | 1 - internal/handler/routes.go | 3475 ++++++----------- internal/logic/common/checkcodelegacylogic.go | 1 - .../logic/common/checkcodelegacyv2logic.go | 1 - .../logic/common/reportlogmessagelogic.go | 1 - internal/logic/common/submitcontactlogic.go | 1 - .../logic/node/server/getserverconfiglogic.go | 1 - .../node/server/getserveruserlistlogic.go | 1 - .../logic/node/server/pushonlineuserslogic.go | 1 - .../server/queryserverprotocolconfiglogic.go | 1 - .../node/server/serverpushstatuslogic.go | 1 - .../node/server/serverpushusertrafficlogic.go | 1 - .../apple/attachappletransactionbyidlogic.go | 1 - .../iap/apple/attachappletransactionlogic.go | 1 - .../public/iap/apple/getapplestatuslogic.go | 1 - .../apple/restoreappletransactionslogic.go | 1 - internal/server.go | 6 +- internal/svc/serviceContext.go | 4 - third_party/gozero/go.mod | 5 - third_party/gozero/rest/rest.go | 109 - 36 files changed, 1173 insertions(+), 2572 deletions(-) delete mode 100644 internal/handler/common/checkCodeLegacyAlias.go delete mode 100644 internal/handler/common/checkcodelegacyhandler.go delete mode 100644 internal/handler/common/checkcodelegacyv2handler.go delete mode 100644 internal/handler/common/reportlogmessagehandler.go delete mode 100644 internal/handler/common/submitcontacthandler.go delete mode 100644 internal/handler/node/server/getserverconfighandler.go delete mode 100644 internal/handler/node/server/getserveruserlisthandler.go delete mode 100644 internal/handler/node/server/pushonlineusershandler.go delete mode 100644 internal/handler/node/server/queryserverprotocolconfighandler.go delete mode 100644 internal/handler/node/server/serverpushstatushandler.go delete mode 100644 internal/handler/node/server/serverpushusertraffichandler.go delete mode 100644 internal/handler/public/iap/apple/attachappletransactionbyidhandler.go delete mode 100644 internal/handler/public/iap/apple/attachappletransactionhandler.go delete mode 100644 internal/handler/public/iap/apple/getapplestatushandler.go delete mode 100644 internal/handler/public/iap/apple/restoreappletransactionshandler.go delete mode 100644 internal/logic/common/checkcodelegacylogic.go delete mode 100644 internal/logic/common/checkcodelegacyv2logic.go delete mode 100644 internal/logic/common/reportlogmessagelogic.go delete mode 100644 internal/logic/common/submitcontactlogic.go delete mode 100644 internal/logic/node/server/getserverconfiglogic.go delete mode 100644 internal/logic/node/server/getserveruserlistlogic.go delete mode 100644 internal/logic/node/server/pushonlineuserslogic.go delete mode 100644 internal/logic/node/server/queryserverprotocolconfiglogic.go delete mode 100644 internal/logic/node/server/serverpushstatuslogic.go delete mode 100644 internal/logic/node/server/serverpushusertrafficlogic.go delete mode 100644 internal/logic/public/iap/apple/attachappletransactionbyidlogic.go delete mode 100644 internal/logic/public/iap/apple/attachappletransactionlogic.go delete mode 100644 internal/logic/public/iap/apple/getapplestatuslogic.go delete mode 100644 internal/logic/public/iap/apple/restoreappletransactionslogic.go delete mode 100644 third_party/gozero/go.mod delete mode 100644 third_party/gozero/rest/rest.go diff --git a/Dockerfile b/Dockerfile index 51dff90..c040309 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,9 +12,8 @@ RUN apk update --no-cache && apk add --no-cache tzdata ca-certificates WORKDIR /build -# Copy go.mod, go.sum, and replace targets (third_party) before downloading deps +# Copy go.mod and go.sum first to take advantage of Docker caching COPY go.mod go.sum ./ -COPY third_party/ ./third_party/ RUN go mod download # Copy the rest of the application code diff --git a/go.mod b/go.mod index 3138e95..3dda44b 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,6 @@ require ( github.com/spf13/cobra v1.8.1 github.com/stripe/stripe-go/v81 v81.1.0 github.com/twilio/twilio-go v1.23.11 - github.com/zeromicro/go-zero v0.0.0 go.opentelemetry.io/otel v1.29.0 go.opentelemetry.io/otel/exporters/jaeger v1.17.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 @@ -53,8 +52,6 @@ require ( k8s.io/apimachinery v0.31.1 ) -replace github.com/zeromicro/go-zero => ./third_party/gozero - require ( github.com/DATA-DOG/go-sqlmock v1.5.2 github.com/Masterminds/sprig/v3 v3.3.0 diff --git a/internal/handler/common/checkCodeLegacyAlias.go b/internal/handler/common/checkCodeLegacyAlias.go deleted file mode 100644 index 4b6392c..0000000 --- a/internal/handler/common/checkCodeLegacyAlias.go +++ /dev/null @@ -1,52 +0,0 @@ -package common - -import ( - "github.com/gin-gonic/gin" - commonLogic "github.com/perfect-panel/server/internal/logic/common" - "github.com/perfect-panel/server/internal/svc" - "github.com/perfect-panel/server/internal/types" - "github.com/perfect-panel/server/pkg/constant" - "github.com/perfect-panel/server/pkg/result" -) - -func CheckCodeLegacyHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return checkCodeLegacyHandler(svcCtx, false) -} - -func CheckCodeLegacyV2Handler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return checkCodeLegacyHandler(svcCtx, true) -} - -func checkCodeLegacyHandler(svcCtx *svc.ServiceContext, consume bool) func(c *gin.Context) { - return func(c *gin.Context) { - var req types.LegacyCheckVerificationCodeRequest - _ = c.ShouldBind(&req) - validateErr := svcCtx.Validate(&req) - if validateErr != nil { - result.ParamErrorResult(c, validateErr) - return - } - - normalizedReq, legacyType3Mapped, err := commonLogic.NormalizeLegacyCheckVerificationCodeRequest(&req) - if err != nil { - result.ParamErrorResult(c, err) - return - } - - l := commonLogic.NewCheckVerificationCodeLogic(c.Request.Context(), svcCtx) - resp, err := l.CheckVerificationCodeWithBehavior(normalizedReq, commonLogic.VerifyCodeCheckBehavior{ - Source: "legacy", - Consume: consume, - LegacyType3Mapped: legacyType3Mapped, - AllowSceneFallback: constant.ParseVerifyType(normalizedReq.Type) != constant.DeleteAccount, - }) - - legacyResp := &types.LegacyCheckVerificationCodeResponse{} - if resp != nil { - legacyResp.Status = resp.Status - legacyResp.Exist = resp.Status - } - - result.HttpResult(c, legacyResp, err) - } -} diff --git a/internal/handler/common/checkcodelegacyhandler.go b/internal/handler/common/checkcodelegacyhandler.go deleted file mode 100644 index 805d0c7..0000000 --- a/internal/handler/common/checkcodelegacyhandler.go +++ /dev/null @@ -1 +0,0 @@ -package common diff --git a/internal/handler/common/checkcodelegacyv2handler.go b/internal/handler/common/checkcodelegacyv2handler.go deleted file mode 100644 index 805d0c7..0000000 --- a/internal/handler/common/checkcodelegacyv2handler.go +++ /dev/null @@ -1 +0,0 @@ -package common diff --git a/internal/handler/common/reportlogmessagehandler.go b/internal/handler/common/reportlogmessagehandler.go deleted file mode 100644 index 805d0c7..0000000 --- a/internal/handler/common/reportlogmessagehandler.go +++ /dev/null @@ -1 +0,0 @@ -package common diff --git a/internal/handler/common/submitcontacthandler.go b/internal/handler/common/submitcontacthandler.go deleted file mode 100644 index 805d0c7..0000000 --- a/internal/handler/common/submitcontacthandler.go +++ /dev/null @@ -1 +0,0 @@ -package common diff --git a/internal/handler/node/server/getserverconfighandler.go b/internal/handler/node/server/getserverconfighandler.go deleted file mode 100644 index 40cc18e..0000000 --- a/internal/handler/node/server/getserverconfighandler.go +++ /dev/null @@ -1,11 +0,0 @@ -package server - -import ( - "github.com/gin-gonic/gin" - serverhandler "github.com/perfect-panel/server/internal/handler/server" - "github.com/perfect-panel/server/internal/svc" -) - -func GetServerConfigHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return serverhandler.GetServerConfigHandler(svcCtx) -} diff --git a/internal/handler/node/server/getserveruserlisthandler.go b/internal/handler/node/server/getserveruserlisthandler.go deleted file mode 100644 index 08270d0..0000000 --- a/internal/handler/node/server/getserveruserlisthandler.go +++ /dev/null @@ -1,11 +0,0 @@ -package server - -import ( - "github.com/gin-gonic/gin" - serverhandler "github.com/perfect-panel/server/internal/handler/server" - "github.com/perfect-panel/server/internal/svc" -) - -func GetServerUserListHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return serverhandler.GetServerUserListHandler(svcCtx) -} diff --git a/internal/handler/node/server/pushonlineusershandler.go b/internal/handler/node/server/pushonlineusershandler.go deleted file mode 100644 index a88a87c..0000000 --- a/internal/handler/node/server/pushonlineusershandler.go +++ /dev/null @@ -1,11 +0,0 @@ -package server - -import ( - "github.com/gin-gonic/gin" - serverhandler "github.com/perfect-panel/server/internal/handler/server" - "github.com/perfect-panel/server/internal/svc" -) - -func PushOnlineUsersHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return serverhandler.PushOnlineUsersHandler(svcCtx) -} diff --git a/internal/handler/node/server/queryserverprotocolconfighandler.go b/internal/handler/node/server/queryserverprotocolconfighandler.go deleted file mode 100644 index 259544a..0000000 --- a/internal/handler/node/server/queryserverprotocolconfighandler.go +++ /dev/null @@ -1,11 +0,0 @@ -package server - -import ( - "github.com/gin-gonic/gin" - serverhandler "github.com/perfect-panel/server/internal/handler/server" - "github.com/perfect-panel/server/internal/svc" -) - -func QueryServerProtocolConfigHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return serverhandler.QueryServerProtocolConfigHandler(svcCtx) -} diff --git a/internal/handler/node/server/serverpushstatushandler.go b/internal/handler/node/server/serverpushstatushandler.go deleted file mode 100644 index 5c0e5ea..0000000 --- a/internal/handler/node/server/serverpushstatushandler.go +++ /dev/null @@ -1,11 +0,0 @@ -package server - -import ( - "github.com/gin-gonic/gin" - serverhandler "github.com/perfect-panel/server/internal/handler/server" - "github.com/perfect-panel/server/internal/svc" -) - -func ServerPushStatusHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return serverhandler.ServerPushStatusHandler(svcCtx) -} diff --git a/internal/handler/node/server/serverpushusertraffichandler.go b/internal/handler/node/server/serverpushusertraffichandler.go deleted file mode 100644 index bd8dd25..0000000 --- a/internal/handler/node/server/serverpushusertraffichandler.go +++ /dev/null @@ -1,11 +0,0 @@ -package server - -import ( - "github.com/gin-gonic/gin" - serverhandler "github.com/perfect-panel/server/internal/handler/server" - "github.com/perfect-panel/server/internal/svc" -) - -func ServerPushUserTrafficHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return serverhandler.ServerPushUserTrafficHandler(svcCtx) -} diff --git a/internal/handler/public/iap/apple/attachappletransactionbyidhandler.go b/internal/handler/public/iap/apple/attachappletransactionbyidhandler.go deleted file mode 100644 index 964f8f7..0000000 --- a/internal/handler/public/iap/apple/attachappletransactionbyidhandler.go +++ /dev/null @@ -1 +0,0 @@ -package apple diff --git a/internal/handler/public/iap/apple/attachappletransactionhandler.go b/internal/handler/public/iap/apple/attachappletransactionhandler.go deleted file mode 100644 index 964f8f7..0000000 --- a/internal/handler/public/iap/apple/attachappletransactionhandler.go +++ /dev/null @@ -1 +0,0 @@ -package apple diff --git a/internal/handler/public/iap/apple/getapplestatushandler.go b/internal/handler/public/iap/apple/getapplestatushandler.go deleted file mode 100644 index 964f8f7..0000000 --- a/internal/handler/public/iap/apple/getapplestatushandler.go +++ /dev/null @@ -1 +0,0 @@ -package apple diff --git a/internal/handler/public/iap/apple/restoreappletransactionshandler.go b/internal/handler/public/iap/apple/restoreappletransactionshandler.go deleted file mode 100644 index 964f8f7..0000000 --- a/internal/handler/public/iap/apple/restoreappletransactionshandler.go +++ /dev/null @@ -1 +0,0 @@ -package apple diff --git a/internal/handler/routes.go b/internal/handler/routes.go index 01c3a07..58f4462 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -1,2354 +1,1221 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.9.2 +// goctl 1.7.2 package handler import ( - "net/http" - - adminads "github.com/perfect-panel/server/internal/handler/admin/ads" - adminannouncement "github.com/perfect-panel/server/internal/handler/admin/announcement" - adminapplication "github.com/perfect-panel/server/internal/handler/admin/application" - adminauthMethod "github.com/perfect-panel/server/internal/handler/admin/authMethod" - adminconsole "github.com/perfect-panel/server/internal/handler/admin/console" - admincoupon "github.com/perfect-panel/server/internal/handler/admin/coupon" - admindocument "github.com/perfect-panel/server/internal/handler/admin/document" - admingroup "github.com/perfect-panel/server/internal/handler/admin/group" - admininvite "github.com/perfect-panel/server/internal/handler/admin/invite" - adminlog "github.com/perfect-panel/server/internal/handler/admin/log" - adminmarketing "github.com/perfect-panel/server/internal/handler/admin/marketing" - adminorder "github.com/perfect-panel/server/internal/handler/admin/order" - adminpayment "github.com/perfect-panel/server/internal/handler/admin/payment" - adminpromo "github.com/perfect-panel/server/internal/handler/admin/promo" - adminredemption "github.com/perfect-panel/server/internal/handler/admin/redemption" - adminserver "github.com/perfect-panel/server/internal/handler/admin/server" - adminsubscribe "github.com/perfect-panel/server/internal/handler/admin/subscribe" - adminsystem "github.com/perfect-panel/server/internal/handler/admin/system" - adminticket "github.com/perfect-panel/server/internal/handler/admin/ticket" - admintool "github.com/perfect-panel/server/internal/handler/admin/tool" - adminuser "github.com/perfect-panel/server/internal/handler/admin/user" + "github.com/gin-gonic/gin" + adminAds "github.com/perfect-panel/server/internal/handler/admin/ads" + adminAnnouncement "github.com/perfect-panel/server/internal/handler/admin/announcement" + adminApplication "github.com/perfect-panel/server/internal/handler/admin/application" + adminAuthMethod "github.com/perfect-panel/server/internal/handler/admin/authMethod" + adminConsole "github.com/perfect-panel/server/internal/handler/admin/console" + adminCoupon "github.com/perfect-panel/server/internal/handler/admin/coupon" + adminDocument "github.com/perfect-panel/server/internal/handler/admin/document" + adminGroup "github.com/perfect-panel/server/internal/handler/admin/group" + adminInvite "github.com/perfect-panel/server/internal/handler/admin/invite" + adminLog "github.com/perfect-panel/server/internal/handler/admin/log" + adminMarketing "github.com/perfect-panel/server/internal/handler/admin/marketing" + adminOrder "github.com/perfect-panel/server/internal/handler/admin/order" + adminPayment "github.com/perfect-panel/server/internal/handler/admin/payment" + adminPromo "github.com/perfect-panel/server/internal/handler/admin/promo" + adminRedemption "github.com/perfect-panel/server/internal/handler/admin/redemption" + adminServer "github.com/perfect-panel/server/internal/handler/admin/server" + adminSubscribe "github.com/perfect-panel/server/internal/handler/admin/subscribe" + adminSystem "github.com/perfect-panel/server/internal/handler/admin/system" + adminTicket "github.com/perfect-panel/server/internal/handler/admin/ticket" + adminTool "github.com/perfect-panel/server/internal/handler/admin/tool" + adminUser "github.com/perfect-panel/server/internal/handler/admin/user" auth "github.com/perfect-panel/server/internal/handler/auth" - authadmin "github.com/perfect-panel/server/internal/handler/auth/admin" - authoauth "github.com/perfect-panel/server/internal/handler/auth/oauth" + authAdmin "github.com/perfect-panel/server/internal/handler/auth/admin" + authOauth "github.com/perfect-panel/server/internal/handler/auth/oauth" common "github.com/perfect-panel/server/internal/handler/common" - nodeserver "github.com/perfect-panel/server/internal/handler/node/server" - publicannouncement "github.com/perfect-panel/server/internal/handler/public/announcement" - publicdocument "github.com/perfect-panel/server/internal/handler/public/document" - publicfile "github.com/perfect-panel/server/internal/handler/public/file" - publiciapapple "github.com/perfect-panel/server/internal/handler/public/iap/apple" - publicorder "github.com/perfect-panel/server/internal/handler/public/order" - publicpayment "github.com/perfect-panel/server/internal/handler/public/payment" - publicportal "github.com/perfect-panel/server/internal/handler/public/portal" - publicrecovery "github.com/perfect-panel/server/internal/handler/public/recovery" - publicredemption "github.com/perfect-panel/server/internal/handler/public/redemption" - publicsubscribe "github.com/perfect-panel/server/internal/handler/public/subscribe" - publicticket "github.com/perfect-panel/server/internal/handler/public/ticket" - publicuser "github.com/perfect-panel/server/internal/handler/public/user" - publicuserws "github.com/perfect-panel/server/internal/handler/public/user/ws" + publicAnnouncement "github.com/perfect-panel/server/internal/handler/public/announcement" + publicDocument "github.com/perfect-panel/server/internal/handler/public/document" + publicFile "github.com/perfect-panel/server/internal/handler/public/file" + publicIapApple "github.com/perfect-panel/server/internal/handler/public/iap/apple" + publicOrder "github.com/perfect-panel/server/internal/handler/public/order" + publicPayment "github.com/perfect-panel/server/internal/handler/public/payment" + publicPortal "github.com/perfect-panel/server/internal/handler/public/portal" + publicRecovery "github.com/perfect-panel/server/internal/handler/public/recovery" + publicRedemption "github.com/perfect-panel/server/internal/handler/public/redemption" + publicSubscribe "github.com/perfect-panel/server/internal/handler/public/subscribe" + publicTicket "github.com/perfect-panel/server/internal/handler/public/ticket" + publicUser "github.com/perfect-panel/server/internal/handler/public/user" + publicUserWs "github.com/perfect-panel/server/internal/handler/public/user/ws" + server "github.com/perfect-panel/server/internal/handler/server" + "github.com/perfect-panel/server/internal/middleware" "github.com/perfect-panel/server/internal/svc" - - "github.com/zeromicro/go-zero/rest" ) -func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create Ads - Method: http.MethodPost, - Path: "/", - Handler: adminads.CreateAdsHandler(serverCtx), - }, - { - // Update Ads - Method: http.MethodPut, - Path: "/", - Handler: adminads.UpdateAdsHandler(serverCtx), - }, - { - // Delete Ads - Method: http.MethodDelete, - Path: "/", - Handler: adminads.DeleteAdsHandler(serverCtx), - }, - { - // Get Ads Detail - Method: http.MethodGet, - Path: "/detail", - Handler: adminads.GetAdsDetailHandler(serverCtx), - }, - { - // Get Ads List - Method: http.MethodGet, - Path: "/list", - Handler: adminads.GetAdsListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/ads"), - ) +func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) { + adminAdsGroupRouter := router.Group("/v1/admin/ads") + adminAdsGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create announcement - Method: http.MethodPost, - Path: "/", - Handler: adminannouncement.CreateAnnouncementHandler(serverCtx), - }, - { - // Update announcement - Method: http.MethodPut, - Path: "/", - Handler: adminannouncement.UpdateAnnouncementHandler(serverCtx), - }, - { - // Delete announcement - Method: http.MethodDelete, - Path: "/", - Handler: adminannouncement.DeleteAnnouncementHandler(serverCtx), - }, - { - // Get announcement - Method: http.MethodGet, - Path: "/detail", - Handler: adminannouncement.GetAnnouncementHandler(serverCtx), - }, - { - // Get announcement list - Method: http.MethodGet, - Path: "/list", - Handler: adminannouncement.GetAnnouncementListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/announcement"), - ) + { + // Create Ads + adminAdsGroupRouter.POST("/", adminAds.CreateAdsHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create subscribe application - Method: http.MethodPost, - Path: "/", - Handler: adminapplication.CreateSubscribeApplicationHandler(serverCtx), - }, - { - // Preview Template - Method: http.MethodGet, - Path: "/preview", - Handler: adminapplication.PreviewSubscribeTemplateHandler(serverCtx), - }, - { - // Update subscribe application - Method: http.MethodPut, - Path: "/subscribe_application", - Handler: adminapplication.UpdateSubscribeApplicationHandler(serverCtx), - }, - { - // Delete subscribe application - Method: http.MethodDelete, - Path: "/subscribe_application", - Handler: adminapplication.DeleteSubscribeApplicationHandler(serverCtx), - }, - { - // Get subscribe application list - Method: http.MethodGet, - Path: "/subscribe_application_list", - Handler: adminapplication.GetSubscribeApplicationListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/application"), - ) + // Update Ads + adminAdsGroupRouter.PUT("/", adminAds.UpdateAdsHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Get auth method config - Method: http.MethodGet, - Path: "/config", - Handler: adminauthMethod.GetAuthMethodConfigHandler(serverCtx), - }, - { - // Update auth method config - Method: http.MethodPut, - Path: "/config", - Handler: adminauthMethod.UpdateAuthMethodConfigHandler(serverCtx), - }, - { - // Get email support platform - Method: http.MethodGet, - Path: "/email_platform", - Handler: adminauthMethod.GetEmailPlatformHandler(serverCtx), - }, - { - // Get auth method list - Method: http.MethodGet, - Path: "/list", - Handler: adminauthMethod.GetAuthMethodListHandler(serverCtx), - }, - { - // Get sms support platform - Method: http.MethodGet, - Path: "/sms_platform", - Handler: adminauthMethod.GetSmsPlatformHandler(serverCtx), - }, - { - // Test email send - Method: http.MethodPost, - Path: "/test_email_send", - Handler: adminauthMethod.TestEmailSendHandler(serverCtx), - }, - { - // Test sms send - Method: http.MethodPost, - Path: "/test_sms_send", - Handler: adminauthMethod.TestSmsSendHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/auth-method"), - ) + // Delete Ads + adminAdsGroupRouter.DELETE("/", adminAds.DeleteAdsHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Query revenue statistics - Method: http.MethodGet, - Path: "/revenue", - Handler: adminconsole.QueryRevenueStatisticsHandler(serverCtx), - }, - { - // Query server total data - Method: http.MethodGet, - Path: "/server", - Handler: adminconsole.QueryServerTotalDataHandler(serverCtx), - }, - { - // Query ticket wait reply - Method: http.MethodGet, - Path: "/ticket", - Handler: adminconsole.QueryTicketWaitReplyHandler(serverCtx), - }, - { - // Query user statistics - Method: http.MethodGet, - Path: "/user", - Handler: adminconsole.QueryUserStatisticsHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/console"), - ) + // Get Ads Detail + adminAdsGroupRouter.GET("/detail", adminAds.GetAdsDetailHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create coupon - Method: http.MethodPost, - Path: "/", - Handler: admincoupon.CreateCouponHandler(serverCtx), - }, - { - // Update coupon - Method: http.MethodPut, - Path: "/", - Handler: admincoupon.UpdateCouponHandler(serverCtx), - }, - { - // Delete coupon - Method: http.MethodDelete, - Path: "/", - Handler: admincoupon.DeleteCouponHandler(serverCtx), - }, - { - // Batch delete coupon - Method: http.MethodDelete, - Path: "/batch", - Handler: admincoupon.BatchDeleteCouponHandler(serverCtx), - }, - { - // Get coupon list - Method: http.MethodGet, - Path: "/list", - Handler: admincoupon.GetCouponListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/coupon"), - ) + // Get Ads List + adminAdsGroupRouter.GET("/list", adminAds.GetAdsListHandler(serverCtx)) + } - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create document - Method: http.MethodPost, - Path: "/", - Handler: admindocument.CreateDocumentHandler(serverCtx), - }, - { - // Update document - Method: http.MethodPut, - Path: "/", - Handler: admindocument.UpdateDocumentHandler(serverCtx), - }, - { - // Delete document - Method: http.MethodDelete, - Path: "/", - Handler: admindocument.DeleteDocumentHandler(serverCtx), - }, - { - // Batch delete document - Method: http.MethodDelete, - Path: "/batch", - Handler: admindocument.BatchDeleteDocumentHandler(serverCtx), - }, - { - // Get document detail - Method: http.MethodGet, - Path: "/detail", - Handler: admindocument.GetDocumentDetailHandler(serverCtx), - }, - { - // Get document list - Method: http.MethodGet, - Path: "/list", - Handler: admindocument.GetDocumentListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/document"), - ) + adminAnnouncementGroupRouter := router.Group("/v1/admin/announcement") + adminAnnouncementGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Get group config - Method: http.MethodGet, - Path: "/config", - Handler: admingroup.GetGroupConfigHandler(serverCtx), - }, - { - // Update group config - Method: http.MethodPut, - Path: "/config", - Handler: admingroup.UpdateGroupConfigHandler(serverCtx), - }, - { - // Export group result - Method: http.MethodGet, - Path: "/export", - Handler: admingroup.ExportGroupResultHandler(serverCtx), - }, - { - // Get group history - Method: http.MethodGet, - Path: "/history", - Handler: admingroup.GetGroupHistoryHandler(serverCtx), - }, - { - // Get group history detail - Method: http.MethodGet, - Path: "/history/detail", - Handler: admingroup.GetGroupHistoryDetailHandler(serverCtx), - }, - { - // Create node group - Method: http.MethodPost, - Path: "/node", - Handler: admingroup.CreateNodeGroupHandler(serverCtx), - }, - { - // Update node group - Method: http.MethodPut, - Path: "/node", - Handler: admingroup.UpdateNodeGroupHandler(serverCtx), - }, - { - // Delete node group - Method: http.MethodDelete, - Path: "/node", - Handler: admingroup.DeleteNodeGroupHandler(serverCtx), - }, - { - // Get node group list - Method: http.MethodGet, - Path: "/node/list", - Handler: admingroup.GetNodeGroupListHandler(serverCtx), - }, - { - // Preview user nodes - Method: http.MethodGet, - Path: "/preview", - Handler: admingroup.PreviewUserNodesHandler(serverCtx), - }, - { - // Recalculate group - Method: http.MethodPost, - Path: "/recalculate", - Handler: admingroup.RecalculateGroupHandler(serverCtx), - }, - { - // Get recalculation status - Method: http.MethodGet, - Path: "/recalculation/status", - Handler: admingroup.GetRecalculationStatusHandler(serverCtx), - }, - { - // Reset all groups - Method: http.MethodPost, - Path: "/reset", - Handler: admingroup.ResetGroupsHandler(serverCtx), - }, - { - // Get subscribe group mapping - Method: http.MethodGet, - Path: "/subscribe/mapping", - Handler: admingroup.GetSubscribeGroupMappingHandler(serverCtx), - }, - }..., - ), - rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret), - rest.WithPrefix("/v1/admin/group"), - ) + { + // Create announcement + adminAnnouncementGroupRouter.POST("/", adminAnnouncement.CreateAnnouncementHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Get invite manage list - Method: http.MethodGet, - Path: "/list", - Handler: admininvite.GetInviteManageListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/invite"), - ) + // Update announcement + adminAnnouncementGroupRouter.PUT("/", adminAnnouncement.UpdateAnnouncementHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Filter balance log - Method: http.MethodGet, - Path: "/balance/list", - Handler: adminlog.FilterBalanceLogHandler(serverCtx), - }, - { - // Filter commission log - Method: http.MethodGet, - Path: "/commission/list", - Handler: adminlog.FilterCommissionLogHandler(serverCtx), - }, - { - // Filter email log - Method: http.MethodGet, - Path: "/email/list", - Handler: adminlog.FilterEmailLogHandler(serverCtx), - }, - { - // Get error log message detail - Method: http.MethodGet, - Path: "/error_message/detail", - Handler: adminlog.GetErrorLogMessageDetailHandler(serverCtx), - }, - { - // Get error log message list - Method: http.MethodGet, - Path: "/error_message/list", - Handler: adminlog.GetErrorLogMessageListHandler(serverCtx), - }, - { - // Filter gift log - Method: http.MethodGet, - Path: "/gift/list", - Handler: adminlog.FilterGiftLogHandler(serverCtx), - }, - { - // Filter login log - Method: http.MethodGet, - Path: "/login/list", - Handler: adminlog.FilterLoginLogHandler(serverCtx), - }, - { - // Get log message raw detail (temporary) - Method: http.MethodGet, - Path: "/message/detail", - Handler: adminlog.GetLogMessageRawHandler(serverCtx), - }, - { - // Get message log list - Method: http.MethodGet, - Path: "/message/list", - Handler: adminlog.GetMessageLogListHandler(serverCtx), - }, - { - // Filter mobile log - Method: http.MethodGet, - Path: "/mobile/list", - Handler: adminlog.FilterMobileLogHandler(serverCtx), - }, - { - // Filter order refund log - Method: http.MethodGet, - Path: "/order/refund/list", - Handler: adminlog.FilterOrderRefundLogHandler(serverCtx), - }, - { - // Filter register log - Method: http.MethodGet, - Path: "/register/list", - Handler: adminlog.FilterRegisterLogHandler(serverCtx), - }, - { - // Filter server traffic log - Method: http.MethodGet, - Path: "/server/traffic/list", - Handler: adminlog.FilterServerTrafficLogHandler(serverCtx), - }, - { - // Get log setting - Method: http.MethodGet, - Path: "/setting", - Handler: adminlog.GetLogSettingHandler(serverCtx), - }, - { - // Update log setting - Method: http.MethodPost, - Path: "/setting", - Handler: adminlog.UpdateLogSettingHandler(serverCtx), - }, - { - // Filter subscribe log - Method: http.MethodGet, - Path: "/subscribe/list", - Handler: adminlog.FilterSubscribeLogHandler(serverCtx), - }, - { - // Filter reset subscribe log - Method: http.MethodGet, - Path: "/subscribe/reset/list", - Handler: adminlog.FilterResetSubscribeLogHandler(serverCtx), - }, - { - // Filter user subscribe traffic log - Method: http.MethodGet, - Path: "/subscribe/traffic/list", - Handler: adminlog.FilterUserSubscribeTrafficLogHandler(serverCtx), - }, - { - // Filter traffic log details - Method: http.MethodGet, - Path: "/traffic/details", - Handler: adminlog.FilterTrafficLogDetailsHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/log"), - ) + // Delete announcement + adminAnnouncementGroupRouter.DELETE("/", adminAnnouncement.DeleteAnnouncementHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Get batch send email task list - Method: http.MethodGet, - Path: "/email/batch/list", - Handler: adminmarketing.GetBatchSendEmailTaskListHandler(serverCtx), - }, - { - // Get pre-send email count - Method: http.MethodPost, - Path: "/email/batch/pre-send-count", - Handler: adminmarketing.GetPreSendEmailCountHandler(serverCtx), - }, - { - // Create a batch send email task - Method: http.MethodPost, - Path: "/email/batch/send", - Handler: adminmarketing.CreateBatchSendEmailTaskHandler(serverCtx), - }, - { - // Get batch send email task status - Method: http.MethodPost, - Path: "/email/batch/status", - Handler: adminmarketing.GetBatchSendEmailTaskStatusHandler(serverCtx), - }, - { - // Stop a batch send email task - Method: http.MethodPost, - Path: "/email/batch/stop", - Handler: adminmarketing.StopBatchSendEmailTaskHandler(serverCtx), - }, - { - // Create a quota task - Method: http.MethodPost, - Path: "/quota/create", - Handler: adminmarketing.CreateQuotaTaskHandler(serverCtx), - }, - { - // Query quota task list - Method: http.MethodGet, - Path: "/quota/list", - Handler: adminmarketing.QueryQuotaTaskListHandler(serverCtx), - }, - { - // Query quota task pre-count - Method: http.MethodPost, - Path: "/quota/pre-count", - Handler: adminmarketing.QueryQuotaTaskPreCountHandler(serverCtx), - }, - { - // Query quota task status - Method: http.MethodPost, - Path: "/quota/status", - Handler: adminmarketing.QueryQuotaTaskStatusHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/marketing"), - ) + // Get announcement + adminAnnouncementGroupRouter.GET("/detail", adminAnnouncement.GetAnnouncementHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create order - Method: http.MethodPost, - Path: "/", - Handler: adminorder.CreateOrderHandler(serverCtx), - }, - { - // Manually activate order - Method: http.MethodPost, - Path: "/activate", - Handler: adminorder.ActivateOrderHandler(serverCtx), - }, - { - // Get order list - Method: http.MethodGet, - Path: "/list", - Handler: adminorder.GetOrderListHandler(serverCtx), - }, - { - // Refund order - Method: http.MethodPost, - Path: "/refund", - Handler: adminorder.RefundOrderHandler(serverCtx), - }, - { - // Update order status - Method: http.MethodPut, - Path: "/status", - Handler: adminorder.UpdateOrderStatusHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/order"), - ) + // Get announcement list + adminAnnouncementGroupRouter.GET("/list", adminAnnouncement.GetAnnouncementListHandler(serverCtx)) + } - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create Payment Method - Method: http.MethodPost, - Path: "/", - Handler: adminpayment.CreatePaymentMethodHandler(serverCtx), - }, - { - // Update Payment Method - Method: http.MethodPut, - Path: "/", - Handler: adminpayment.UpdatePaymentMethodHandler(serverCtx), - }, - { - // Delete Payment Method - Method: http.MethodDelete, - Path: "/", - Handler: adminpayment.DeletePaymentMethodHandler(serverCtx), - }, - { - // Get Payment Method List - Method: http.MethodGet, - Path: "/list", - Handler: adminpayment.GetPaymentMethodListHandler(serverCtx), - }, - { - // Get supported payment platform - Method: http.MethodGet, - Path: "/platform", - Handler: adminpayment.GetPaymentPlatformHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/payment"), - ) + adminApplicationGroupRouter := router.Group("/v1/admin/application") + adminApplicationGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Set promo prices - Method: http.MethodPost, - Path: "/price", - Handler: adminpromo.SetPriceHandler(serverCtx), - }, - { - // Delete promo price - Method: http.MethodDelete, - Path: "/price/:id", - Handler: adminpromo.DeletePriceHandler(serverCtx), - }, - { - // Get promo price list - Method: http.MethodGet, - Path: "/price/list", - Handler: adminpromo.GetPriceListHandler(serverCtx), - }, - { - // Create promo rule - Method: http.MethodPost, - Path: "/rule", - Handler: adminpromo.CreateRuleHandler(serverCtx), - }, - { - // Get promo rule detail - Method: http.MethodGet, - Path: "/rule/:id", - Handler: adminpromo.GetRuleDetailHandler(serverCtx), - }, - { - // Update promo rule - Method: http.MethodPut, - Path: "/rule/:id", - Handler: adminpromo.UpdateRuleHandler(serverCtx), - }, - { - // Delete promo rule - Method: http.MethodDelete, - Path: "/rule/:id", - Handler: adminpromo.DeleteRuleHandler(serverCtx), - }, - { - // Get promo rule list - Method: http.MethodGet, - Path: "/rule/list", - Handler: adminpromo.GetRuleListHandler(serverCtx), - }, - { - // Get promo usage list - Method: http.MethodGet, - Path: "/usage/list", - Handler: adminpromo.GetUsageListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/promo"), - ) + { + // Create subscribe application + adminApplicationGroupRouter.POST("/", adminApplication.CreateSubscribeApplicationHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create redemption code - Method: http.MethodPost, - Path: "/code", - Handler: adminredemption.CreateRedemptionCodeHandler(serverCtx), - }, - { - // Update redemption code - Method: http.MethodPut, - Path: "/code", - Handler: adminredemption.UpdateRedemptionCodeHandler(serverCtx), - }, - { - // Delete redemption code - Method: http.MethodDelete, - Path: "/code", - Handler: adminredemption.DeleteRedemptionCodeHandler(serverCtx), - }, - { - // Batch delete redemption code - Method: http.MethodDelete, - Path: "/code/batch", - Handler: adminredemption.BatchDeleteRedemptionCodeHandler(serverCtx), - }, - { - // Get redemption code list - Method: http.MethodGet, - Path: "/code/list", - Handler: adminredemption.GetRedemptionCodeListHandler(serverCtx), - }, - { - // Toggle redemption code status - Method: http.MethodPut, - Path: "/code/status", - Handler: adminredemption.ToggleRedemptionCodeStatusHandler(serverCtx), - }, - { - // Get redemption record list - Method: http.MethodGet, - Path: "/record/list", - Handler: adminredemption.GetRedemptionRecordListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/redemption"), - ) + // Preview Template + adminApplicationGroupRouter.GET("/preview", adminApplication.PreviewSubscribeTemplateHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create Server - Method: http.MethodPost, - Path: "/create", - Handler: adminserver.CreateServerHandler(serverCtx), - }, - { - // Delete Server - Method: http.MethodPost, - Path: "/delete", - Handler: adminserver.DeleteServerHandler(serverCtx), - }, - { - // Filter Server List - Method: http.MethodGet, - Path: "/list", - Handler: adminserver.FilterServerListHandler(serverCtx), - }, - { - // Create Node - Method: http.MethodPost, - Path: "/node/create", - Handler: adminserver.CreateNodeHandler(serverCtx), - }, - { - // Delete Node - Method: http.MethodPost, - Path: "/node/delete", - Handler: adminserver.DeleteNodeHandler(serverCtx), - }, - { - // Filter Node List - Method: http.MethodGet, - Path: "/node/list", - Handler: adminserver.FilterNodeListHandler(serverCtx), - }, - { - // Reset node sort - Method: http.MethodPost, - Path: "/node/sort", - Handler: adminserver.ResetSortWithNodeHandler(serverCtx), - }, - { - // Toggle Node Status - Method: http.MethodPost, - Path: "/node/status/toggle", - Handler: adminserver.ToggleNodeStatusHandler(serverCtx), - }, - { - // Query all node tags - Method: http.MethodGet, - Path: "/node/tags", - Handler: adminserver.QueryNodeTagHandler(serverCtx), - }, - { - // Update Node - Method: http.MethodPost, - Path: "/node/update", - Handler: adminserver.UpdateNodeHandler(serverCtx), - }, - { - // Get Server Protocols - Method: http.MethodGet, - Path: "/protocols", - Handler: adminserver.GetServerProtocolsHandler(serverCtx), - }, - { - // Reset server sort - Method: http.MethodPost, - Path: "/server/sort", - Handler: adminserver.ResetSortWithServerHandler(serverCtx), - }, - { - // Update Server - Method: http.MethodPost, - Path: "/update", - Handler: adminserver.UpdateServerHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/server"), - ) + // Update subscribe application + adminApplicationGroupRouter.PUT("/subscribe_application", adminApplication.UpdateSubscribeApplicationHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Create subscribe - Method: http.MethodPost, - Path: "/", - Handler: adminsubscribe.CreateSubscribeHandler(serverCtx), - }, - { - // Update subscribe - Method: http.MethodPut, - Path: "/", - Handler: adminsubscribe.UpdateSubscribeHandler(serverCtx), - }, - { - // Delete subscribe - Method: http.MethodDelete, - Path: "/", - Handler: adminsubscribe.DeleteSubscribeHandler(serverCtx), - }, - { - // Batch delete subscribe - Method: http.MethodDelete, - Path: "/batch", - Handler: adminsubscribe.BatchDeleteSubscribeHandler(serverCtx), - }, - { - // Get subscribe details - Method: http.MethodGet, - Path: "/details", - Handler: adminsubscribe.GetSubscribeDetailsHandler(serverCtx), - }, - { - // Create subscribe group - Method: http.MethodPost, - Path: "/group", - Handler: adminsubscribe.CreateSubscribeGroupHandler(serverCtx), - }, - { - // Update subscribe group - Method: http.MethodPut, - Path: "/group", - Handler: adminsubscribe.UpdateSubscribeGroupHandler(serverCtx), - }, - { - // Delete subscribe group - Method: http.MethodDelete, - Path: "/group", - Handler: adminsubscribe.DeleteSubscribeGroupHandler(serverCtx), - }, - { - // Batch delete subscribe group - Method: http.MethodDelete, - Path: "/group/batch", - Handler: adminsubscribe.BatchDeleteSubscribeGroupHandler(serverCtx), - }, - { - // Get subscribe group list - Method: http.MethodGet, - Path: "/group/list", - Handler: adminsubscribe.GetSubscribeGroupListHandler(serverCtx), - }, - { - // Get subscribe list - Method: http.MethodGet, - Path: "/list", - Handler: adminsubscribe.GetSubscribeListHandler(serverCtx), - }, - { - // Reset all subscribe tokens - Method: http.MethodPost, - Path: "/reset_all_token", - Handler: adminsubscribe.ResetAllSubscribeTokenHandler(serverCtx), - }, - { - // Subscribe sort - Method: http.MethodPost, - Path: "/sort", - Handler: adminsubscribe.SubscribeSortHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/subscribe"), - ) + // Delete subscribe application + adminApplicationGroupRouter.DELETE("/subscribe_application", adminApplication.DeleteSubscribeApplicationHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Get Currency Config - Method: http.MethodGet, - Path: "/currency_config", - Handler: adminsystem.GetCurrencyConfigHandler(serverCtx), - }, - { - // Update Currency Config - Method: http.MethodPut, - Path: "/currency_config", - Handler: adminsystem.UpdateCurrencyConfigHandler(serverCtx), - }, - { - // Get Node Multiplier - Method: http.MethodGet, - Path: "/get_node_multiplier", - Handler: adminsystem.GetNodeMultiplierHandler(serverCtx), - }, - { - // Get invite config - Method: http.MethodGet, - Path: "/invite_config", - Handler: adminsystem.GetInviteConfigHandler(serverCtx), - }, - { - // Update invite config - Method: http.MethodPut, - Path: "/invite_config", - Handler: adminsystem.UpdateInviteConfigHandler(serverCtx), - }, - { - // Get Module Config - Method: http.MethodGet, - Path: "/module", - Handler: adminsystem.GetModuleConfigHandler(serverCtx), - }, - { - // Get node config - Method: http.MethodGet, - Path: "/node_config", - Handler: adminsystem.GetNodeConfigHandler(serverCtx), - }, - { - // Update node config - Method: http.MethodPut, - Path: "/node_config", - Handler: adminsystem.UpdateNodeConfigHandler(serverCtx), - }, - { - // PreView Node Multiplier - Method: http.MethodGet, - Path: "/node_multiplier/preview", - Handler: adminsystem.PreViewNodeMultiplierHandler(serverCtx), - }, - { - // get Privacy Policy Config - Method: http.MethodGet, - Path: "/privacy", - Handler: adminsystem.GetPrivacyPolicyConfigHandler(serverCtx), - }, - { - // Update Privacy Policy Config - Method: http.MethodPut, - Path: "/privacy", - Handler: adminsystem.UpdatePrivacyPolicyConfigHandler(serverCtx), - }, - { - // Get register config - Method: http.MethodGet, - Path: "/register_config", - Handler: adminsystem.GetRegisterConfigHandler(serverCtx), - }, - { - // Update register config - Method: http.MethodPut, - Path: "/register_config", - Handler: adminsystem.UpdateRegisterConfigHandler(serverCtx), - }, - { - // Set Node Multiplier - Method: http.MethodPost, - Path: "/set_node_multiplier", - Handler: adminsystem.SetNodeMultiplierHandler(serverCtx), - }, - { - // setting telegram bot - Method: http.MethodPost, - Path: "/setting_telegram_bot", - Handler: adminsystem.SettingTelegramBotHandler(serverCtx), - }, - { - // Get Signature Config - Method: http.MethodGet, - Path: "/signature_config", - Handler: adminsystem.GetSignatureConfigHandler(serverCtx), - }, - { - // Update Signature Config - Method: http.MethodPut, - Path: "/signature_config", - Handler: adminsystem.UpdateSignatureConfigHandler(serverCtx), - }, - { - // Get site config - Method: http.MethodGet, - Path: "/site_config", - Handler: adminsystem.GetSiteConfigHandler(serverCtx), - }, - { - // Update site config - Method: http.MethodPut, - Path: "/site_config", - Handler: adminsystem.UpdateSiteConfigHandler(serverCtx), - }, - { - // Get subscribe config - Method: http.MethodGet, - Path: "/subscribe_config", - Handler: adminsystem.GetSubscribeConfigHandler(serverCtx), - }, - { - // Update subscribe config - Method: http.MethodPut, - Path: "/subscribe_config", - Handler: adminsystem.UpdateSubscribeConfigHandler(serverCtx), - }, - { - // Get Team of Service Config - Method: http.MethodGet, - Path: "/tos_config", - Handler: adminsystem.GetTosConfigHandler(serverCtx), - }, - { - // Update Team of Service Config - Method: http.MethodPut, - Path: "/tos_config", - Handler: adminsystem.UpdateTosConfigHandler(serverCtx), - }, - { - // Get Verify Code Config - Method: http.MethodGet, - Path: "/verify_code_config", - Handler: adminsystem.GetVerifyCodeConfigHandler(serverCtx), - }, - { - // Update Verify Code Config - Method: http.MethodPut, - Path: "/verify_code_config", - Handler: adminsystem.UpdateVerifyCodeConfigHandler(serverCtx), - }, - { - // Get verify config - Method: http.MethodGet, - Path: "/verify_config", - Handler: adminsystem.GetVerifyConfigHandler(serverCtx), - }, - { - // Update verify config - Method: http.MethodPut, - Path: "/verify_config", - Handler: adminsystem.UpdateVerifyConfigHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/system"), - ) + // Get subscribe application list + adminApplicationGroupRouter.GET("/subscribe_application_list", adminApplication.GetSubscribeApplicationListHandler(serverCtx)) + } - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Update ticket status - Method: http.MethodPut, - Path: "/", - Handler: adminticket.UpdateTicketStatusHandler(serverCtx), - }, - { - // Get ticket detail - Method: http.MethodGet, - Path: "/detail", - Handler: adminticket.GetTicketHandler(serverCtx), - }, - { - // Create ticket follow - Method: http.MethodPost, - Path: "/follow", - Handler: adminticket.CreateTicketFollowHandler(serverCtx), - }, - { - // Get ticket list - Method: http.MethodGet, - Path: "/list", - Handler: adminticket.GetTicketListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/ticket"), - ) + adminAuthMethodGroupRouter := router.Group("/v1/admin/auth-method") + adminAuthMethodGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Query IP Location - Method: http.MethodGet, - Path: "/ip/location", - Handler: admintool.QueryIPLocationHandler(serverCtx), - }, - { - // Get System Log - Method: http.MethodGet, - Path: "/log", - Handler: admintool.GetSystemLogHandler(serverCtx), - }, - { - // Restart System - Method: http.MethodGet, - Path: "/restart", - Handler: admintool.RestartSystemHandler(serverCtx), - }, - { - // Get Version - Method: http.MethodGet, - Path: "/version", - Handler: admintool.GetVersionHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/admin/tool"), - ) + { + // Get auth method config + adminAuthMethodGroupRouter.GET("/config", adminAuthMethod.GetAuthMethodConfigHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Delete user - Method: http.MethodDelete, - Path: "/", - Handler: adminuser.DeleteUserHandler(serverCtx), - }, - { - // Create user - Method: http.MethodPost, - Path: "/", - Handler: adminuser.CreateUserHandler(serverCtx), - }, - { - // Create user auth method - Method: http.MethodPost, - Path: "/auth_method", - Handler: adminuser.CreateUserAuthMethodHandler(serverCtx), - }, - { - // Delete user auth method - Method: http.MethodDelete, - Path: "/auth_method", - Handler: adminuser.DeleteUserAuthMethodHandler(serverCtx), - }, - { - // Update user auth method - Method: http.MethodPut, - Path: "/auth_method", - Handler: adminuser.UpdateUserAuthMethodHandler(serverCtx), - }, - { - // Get user auth method - Method: http.MethodGet, - Path: "/auth_method", - Handler: adminuser.GetUserAuthMethodHandler(serverCtx), - }, - { - // Update user basic info - Method: http.MethodPut, - Path: "/basic", - Handler: adminuser.UpdateUserBasicInfoHandler(serverCtx), - }, - { - // Batch delete user - Method: http.MethodDelete, - Path: "/batch", - Handler: adminuser.BatchDeleteUserHandler(serverCtx), - }, - { - // Current user - Method: http.MethodGet, - Path: "/current", - Handler: adminuser.CurrentUserHandler(serverCtx), - }, - { - // Get user detail - Method: http.MethodGet, - Path: "/detail", - Handler: adminuser.GetUserDetailHandler(serverCtx), - }, - { - // User device - Method: http.MethodPut, - Path: "/device", - Handler: adminuser.UpdateUserDeviceHandler(serverCtx), - }, - { - // Delete user device - Method: http.MethodDelete, - Path: "/device", - Handler: adminuser.DeleteUserDeviceHandler(serverCtx), - }, - { - // kick offline user device - Method: http.MethodPut, - Path: "/device/kick_offline", - Handler: adminuser.KickOfflineByUserDeviceHandler(serverCtx), - }, - { - // Get family detail - Method: http.MethodGet, - Path: "/family/detail", - Handler: adminuser.GetFamilyDetailHandler(serverCtx), - }, - { - // Dissolve family - Method: http.MethodPut, - Path: "/family/dissolve", - Handler: adminuser.DissolveFamilyHandler(serverCtx), - }, - { - // Get family list - Method: http.MethodGet, - Path: "/family/list", - Handler: adminuser.GetFamilyListHandler(serverCtx), - }, - { - // Update family max members - Method: http.MethodPut, - Path: "/family/max_members", - Handler: adminuser.UpdateFamilyMaxMembersHandler(serverCtx), - }, - { - // Remove family member - Method: http.MethodPut, - Path: "/family/member/remove", - Handler: adminuser.RemoveFamilyMemberHandler(serverCtx), - }, - { - // Get admin user invite list - Method: http.MethodGet, - Path: "/invite/list", - Handler: adminuser.GetAdminUserInviteListHandler(serverCtx), - }, - { - // Get admin user invite stats - Method: http.MethodGet, - Path: "/invite/stats", - Handler: adminuser.GetAdminUserInviteStatsHandler(serverCtx), - }, - { - // Get user list - Method: http.MethodGet, - Path: "/list", - Handler: adminuser.GetUserListHandler(serverCtx), - }, - { - // Get user login logs - Method: http.MethodGet, - Path: "/login/logs", - Handler: adminuser.GetUserLoginLogsHandler(serverCtx), - }, - { - // Update user notify setting - Method: http.MethodPut, - Path: "/notify", - Handler: adminuser.UpdateUserNotifySettingHandler(serverCtx), - }, - { - // Get user subcribe - Method: http.MethodGet, - Path: "/subscribe", - Handler: adminuser.GetUserSubscribeHandler(serverCtx), - }, - { - // Create user subcribe - Method: http.MethodPost, - Path: "/subscribe", - Handler: adminuser.CreateUserSubscribeHandler(serverCtx), - }, - { - // Update user subcribe - Method: http.MethodPut, - Path: "/subscribe", - Handler: adminuser.UpdateUserSubscribeHandler(serverCtx), - }, - { - // Delete user subcribe - Method: http.MethodDelete, - Path: "/subscribe", - Handler: adminuser.DeleteUserSubscribeHandler(serverCtx), - }, - { - // Get user subcribe by id - Method: http.MethodGet, - Path: "/subscribe/detail", - Handler: adminuser.GetUserSubscribeByIdHandler(serverCtx), - }, - { - // Get user subcribe devices - Method: http.MethodGet, - Path: "/subscribe/device", - Handler: adminuser.GetUserSubscribeDevicesHandler(serverCtx), - }, - { - // Get user subcribe logs - Method: http.MethodGet, - Path: "/subscribe/logs", - Handler: adminuser.GetUserSubscribeLogsHandler(serverCtx), - }, - { - // Get user subcribe reset traffic logs - Method: http.MethodGet, - Path: "/subscribe/reset/logs", - Handler: adminuser.GetUserSubscribeResetTrafficLogsHandler(serverCtx), - }, - { - // Reset user subscribe token - Method: http.MethodPost, - Path: "/subscribe/reset/token", - Handler: adminuser.ResetUserSubscribeTokenHandler(serverCtx), - }, - { - // Reset user subscribe traffic - Method: http.MethodPost, - Path: "/subscribe/reset/traffic", - Handler: adminuser.ResetUserSubscribeTrafficHandler(serverCtx), - }, - { - // Stop user subscribe - Method: http.MethodPost, - Path: "/subscribe/toggle", - Handler: adminuser.ToggleUserSubscribeStatusHandler(serverCtx), - }, - { - // Get user subcribe traffic logs - Method: http.MethodGet, - Path: "/subscribe/traffic_logs", - Handler: adminuser.GetUserSubscribeTrafficLogsHandler(serverCtx), - }, - { - // Approve withdrawal - Method: http.MethodPost, - Path: "/withdrawal/approve", - Handler: adminuser.ApproveWithdrawalHandler(serverCtx), - }, - { - // Get withdrawal list - Method: http.MethodGet, - Path: "/withdrawal/list", - Handler: adminuser.GetWithdrawalListHandler(serverCtx), - }, - { - // Reject withdrawal - Method: http.MethodPost, - Path: "/withdrawal/reject", - Handler: adminuser.RejectWithdrawalHandler(serverCtx), - }, - }..., - ), - rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret), - rest.WithPrefix("/v1/admin/user"), - ) + // Update auth method config + adminAuthMethodGroupRouter.PUT("/config", adminAuthMethod.UpdateAuthMethodConfigHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Generate captcha - Method: http.MethodPost, - Path: "/captcha/generate", - Handler: auth.GenerateCaptchaHandler(serverCtx), - }, - { - // Verify slider captcha - Method: http.MethodPost, - Path: "/captcha/slider/verify", - Handler: auth.SliderVerifyCaptchaHandler(serverCtx), - }, - { - // Check user is exist - Method: http.MethodGet, - Path: "/check", - Handler: auth.CheckUserHandler(serverCtx), - }, - { - // Check user telephone is exist - Method: http.MethodGet, - Path: "/check/telephone", - Handler: auth.CheckUserTelephoneHandler(serverCtx), - }, - { - // User login - Method: http.MethodPost, - Path: "/login", - Handler: auth.UserLoginHandler(serverCtx), - }, - { - // Device Login - Method: http.MethodPost, - Path: "/login/device", - Handler: auth.DeviceLoginHandler(serverCtx), - }, - { - // Email Login - Method: http.MethodPost, - Path: "/login/email", - Handler: auth.EmailLoginHandler(serverCtx), - }, - { - // User Telephone login - Method: http.MethodPost, - Path: "/login/telephone", - Handler: auth.TelephoneLoginHandler(serverCtx), - }, - { - // User register - Method: http.MethodPost, - Path: "/register", - Handler: auth.UserRegisterHandler(serverCtx), - }, - { - // User Telephone register - Method: http.MethodPost, - Path: "/register/telephone", - Handler: auth.TelephoneRegisterHandler(serverCtx), - }, - { - // Reset password - Method: http.MethodPost, - Path: "/reset", - Handler: auth.ResetPasswordHandler(serverCtx), - }, - { - // Reset password by telephone - Method: http.MethodPost, - Path: "/reset/telephone", - Handler: auth.TelephoneResetPasswordHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/auth"), - ) + // Get email support platform + adminAuthMethodGroupRouter.GET("/email_platform", adminAuthMethod.GetEmailPlatformHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Generate captcha - Method: http.MethodPost, - Path: "/captcha/generate", - Handler: authadmin.AdminGenerateCaptchaHandler(serverCtx), - }, - { - // Verify slider captcha - Method: http.MethodPost, - Path: "/captcha/slider/verify", - Handler: authadmin.AdminSliderVerifyCaptchaHandler(serverCtx), - }, - { - // Admin login - Method: http.MethodPost, - Path: "/login", - Handler: authadmin.AdminLoginHandler(serverCtx), - }, - { - // Admin reset password - Method: http.MethodPost, - Path: "/reset", - Handler: authadmin.AdminResetPasswordHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/auth/admin"), - ) + // Get auth method list + adminAuthMethodGroupRouter.GET("/list", adminAuthMethod.GetAuthMethodListHandler(serverCtx)) - server.AddRoutes( - []rest.Route{ - { - // Apple Login Callback - Method: http.MethodPost, - Path: "/callback/apple", - Handler: authoauth.AppleLoginCallbackHandler(serverCtx), - }, - { - // OAuth login - Method: http.MethodPost, - Path: "/login", - Handler: authoauth.OAuthLoginHandler(serverCtx), - }, - { - // OAuth login get token - Method: http.MethodPost, - Path: "/login/token", - Handler: authoauth.OAuthLoginGetTokenHandler(serverCtx), - }, - }, - rest.WithPrefix("/v1/auth/oauth"), - ) + // Get sms support platform + adminAuthMethodGroupRouter.GET("/sms_platform", adminAuthMethod.GetSmsPlatformHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Get Ads - Method: http.MethodGet, - Path: "/ads", - Handler: common.GetAdsHandler(serverCtx), - }, - { - // Check verification code (legacy v1) - Method: http.MethodPost, - Path: "/check_code", - Handler: common.CheckCodeLegacyHandler(serverCtx), - }, - { - // Check verification code (legacy v2, consume code) - Method: http.MethodPost, - Path: "/check_code/v2", - Handler: common.CheckCodeLegacyV2Handler(serverCtx), - }, - { - // Check verification code - Method: http.MethodPost, - Path: "/check_verification_code", - Handler: common.CheckVerificationCodeHandler(serverCtx), - }, - { - // Get Client - Method: http.MethodGet, - Path: "/client", - Handler: common.GetClientHandler(serverCtx), - }, - { - // Get Download Link - Method: http.MethodGet, - Path: "/client/download", - Handler: common.GetDownloadLinkHandler(serverCtx), - }, - { - // Submit Contact - Method: http.MethodPost, - Path: "/contact", - Handler: common.SubmitContactHandler(serverCtx), - }, - { - // Heartbeat - Method: http.MethodGet, - Path: "/heartbeat", - Handler: common.HeartbeatHandler(serverCtx), - }, - { - // Report log message - Method: http.MethodPost, - Path: "/log/report", - Handler: common.ReportLogMessageHandler(serverCtx), - }, - { - // Get verification code - Method: http.MethodPost, - Path: "/send_code", - Handler: common.SendEmailCodeHandler(serverCtx), - }, - { - // Get sms verification code - Method: http.MethodPost, - Path: "/send_sms_code", - Handler: common.SendSmsCodeHandler(serverCtx), - }, - { - // Get global config - Method: http.MethodGet, - Path: "/site/config", - Handler: common.GetGlobalConfigHandler(serverCtx), - }, - { - // Get Privacy Policy - Method: http.MethodGet, - Path: "/site/privacy", - Handler: common.GetPrivacyPolicyHandler(serverCtx), - }, - { - // Get stat - Method: http.MethodGet, - Path: "/site/stat", - Handler: common.GetStatHandler(serverCtx), - }, - { - // Get Tos Content - Method: http.MethodGet, - Path: "/site/tos", - Handler: common.GetTosHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/common"), - ) + // Test email send + adminAuthMethodGroupRouter.POST("/test_email_send", adminAuthMethod.TestEmailSendHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.ServerMiddleware}, - []rest.Route{ - { - // Get server config - Method: http.MethodGet, - Path: "/config", - Handler: nodeserver.GetServerConfigHandler(serverCtx), - }, - { - // Push online users - Method: http.MethodPost, - Path: "/online", - Handler: nodeserver.PushOnlineUsersHandler(serverCtx), - }, - { - // Push user Traffic - Method: http.MethodPost, - Path: "/push", - Handler: nodeserver.ServerPushUserTrafficHandler(serverCtx), - }, - { - // Push server status - Method: http.MethodPost, - Path: "/status", - Handler: nodeserver.ServerPushStatusHandler(serverCtx), - }, - { - // Get user list - Method: http.MethodGet, - Path: "/user", - Handler: nodeserver.GetServerUserListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/server"), - ) + // Test sms send + adminAuthMethodGroupRouter.POST("/test_sms_send", adminAuthMethod.TestSmsSendHandler(serverCtx)) + } - server.AddRoutes( - []rest.Route{ - { - // Get Server Protocol Config - Method: http.MethodGet, - Path: "/:server_id", - Handler: nodeserver.QueryServerProtocolConfigHandler(serverCtx), - }, - }, - rest.WithPrefix("/v2/server"), - ) + adminConsoleGroupRouter := router.Group("/v1/admin/console") + adminConsoleGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Query announcement - Method: http.MethodGet, - Path: "/list", - Handler: publicannouncement.QueryAnnouncementHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/announcement"), - ) + { + // Query revenue statistics + adminConsoleGroupRouter.GET("/revenue", adminConsole.QueryRevenueStatisticsHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Get document detail - Method: http.MethodGet, - Path: "/detail", - Handler: publicdocument.QueryDocumentDetailHandler(serverCtx), - }, - { - // Get document list - Method: http.MethodGet, - Path: "/list", - Handler: publicdocument.QueryDocumentListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/document"), - ) + // Query server total data + adminConsoleGroupRouter.GET("/server", adminConsole.QueryServerTotalDataHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Upload file to RustFS - Method: http.MethodPost, - Path: "/upload", - Handler: publicfile.FileUploadHandler(serverCtx), - }, - { - // Complete file upload - Method: http.MethodPost, - Path: "/upload/complete", - Handler: publicfile.FileUploadCompleteHandler(serverCtx), - }, - { - // Init file upload - Method: http.MethodPost, - Path: "/upload/init", - Handler: publicfile.FileUploadInitHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/file"), - ) + // Query ticket wait reply + adminConsoleGroupRouter.GET("/ticket", adminConsole.QueryTicketWaitReplyHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Get Apple IAP Status - Method: http.MethodGet, - Path: "/status", - Handler: publiciapapple.GetAppleStatusHandler(serverCtx), - }, - { - // Attach Apple Transaction - Method: http.MethodPost, - Path: "/transactions/attach", - Handler: publiciapapple.AttachAppleTransactionHandler(serverCtx), - }, - { - // Attach Apple Transaction By Id - Method: http.MethodPost, - Path: "/transactions/attach/id", - Handler: publiciapapple.AttachAppleTransactionByIdHandler(serverCtx), - }, - { - // Restore Apple Transactions - Method: http.MethodPost, - Path: "/transactions/restore", - Handler: publiciapapple.RestoreAppleTransactionsHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/iap/apple"), - ) + // Query user statistics + adminConsoleGroupRouter.GET("/user", adminConsole.QueryUserStatisticsHandler(serverCtx)) + } - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Close order - Method: http.MethodPost, - Path: "/close", - Handler: publicorder.CloseOrderHandler(serverCtx), - }, - { - // Get order - Method: http.MethodGet, - Path: "/detail", - Handler: publicorder.QueryOrderDetailHandler(serverCtx), - }, - { - // Get order list - Method: http.MethodGet, - Path: "/list", - Handler: publicorder.QueryOrderListHandler(serverCtx), - }, - { - // Pre create order - Method: http.MethodPost, - Path: "/pre", - Handler: publicorder.PreCreateOrderHandler(serverCtx), - }, - { - // purchase Subscription - Method: http.MethodPost, - Path: "/purchase", - Handler: publicorder.PurchaseHandler(serverCtx), - }, - { - // Recharge - Method: http.MethodPost, - Path: "/recharge", - Handler: publicorder.RechargeHandler(serverCtx), - }, - { - // Renewal Subscription - Method: http.MethodPost, - Path: "/renewal", - Handler: publicorder.RenewalHandler(serverCtx), - }, - { - // Reset traffic - Method: http.MethodPost, - Path: "/reset", - Handler: publicorder.ResetTrafficHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/order"), - ) + adminCouponGroupRouter := router.Group("/v1/admin/coupon") + adminCouponGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Get available payment methods - Method: http.MethodGet, - Path: "/methods", - Handler: publicpayment.GetAvailablePaymentMethodsHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/payment"), - ) + { + // Create coupon + adminCouponGroupRouter.POST("/", adminCoupon.CreateCouponHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Purchase Checkout - Method: http.MethodPost, - Path: "/order/checkout", - Handler: publicportal.PurchaseCheckoutHandler(serverCtx), - }, - { - // Query Purchase Order - Method: http.MethodGet, - Path: "/order/status", - Handler: publicportal.QueryPurchaseOrderHandler(serverCtx), - }, - { - // Get available payment methods - Method: http.MethodGet, - Path: "/payment-method", - Handler: publicportal.GetAvailablePaymentMethodsHandler(serverCtx), - }, - { - // Pre Purchase Order - Method: http.MethodPost, - Path: "/pre", - Handler: publicportal.PrePurchaseOrderHandler(serverCtx), - }, - { - // Purchase subscription - Method: http.MethodPost, - Path: "/purchase", - Handler: publicportal.PurchaseHandler(serverCtx), - }, - { - // Get Subscription - Method: http.MethodGet, - Path: "/subscribe", - Handler: publicportal.GetSubscriptionHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/portal"), - ) + // Update coupon + adminCouponGroupRouter.PUT("/", adminCoupon.UpdateCouponHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Recover order subscription - Method: http.MethodPost, - Path: "/order", - Handler: publicrecovery.RecoverOrderHandler(serverCtx), - }, - { - // Send recovery verification code - Method: http.MethodPost, - Path: "/send_code", - Handler: publicrecovery.SendCodeHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/recovery"), - ) + // Delete coupon + adminCouponGroupRouter.DELETE("/", adminCoupon.DeleteCouponHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Redeem code - Method: http.MethodPost, - Path: "/", - Handler: publicredemption.RedeemCodeHandler(serverCtx), - }, - }..., - ), - rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret), - rest.WithPrefix("/v1/public/redemption"), - ) + // Batch delete coupon + adminCouponGroupRouter.DELETE("/batch", adminCoupon.BatchDeleteCouponHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Get subscribe group list - Method: http.MethodGet, - Path: "/group/list", - Handler: publicsubscribe.QuerySubscribeGroupListHandler(serverCtx), - }, - { - // Get subscribe list - Method: http.MethodGet, - Path: "/list", - Handler: publicsubscribe.QuerySubscribeListHandler(serverCtx), - }, - { - // Get user subscribe node info - Method: http.MethodGet, - Path: "/node/list", - Handler: publicsubscribe.QueryUserSubscribeNodeListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/subscribe"), - ) + // Get coupon list + adminCouponGroupRouter.GET("/list", adminCoupon.GetCouponListHandler(serverCtx)) + } - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Update ticket status - Method: http.MethodPut, - Path: "/", - Handler: publicticket.UpdateUserTicketStatusHandler(serverCtx), - }, - { - // Create ticket - Method: http.MethodPost, - Path: "/", - Handler: publicticket.CreateUserTicketHandler(serverCtx), - }, - { - // Get ticket detail - Method: http.MethodGet, - Path: "/detail", - Handler: publicticket.GetUserTicketDetailsHandler(serverCtx), - }, - { - // Create ticket follow - Method: http.MethodPost, - Path: "/follow", - Handler: publicticket.CreateUserTicketFollowHandler(serverCtx), - }, - { - // Get ticket list - Method: http.MethodGet, - Path: "/list", - Handler: publicticket.GetUserTicketListHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/ticket"), - ) + adminDocumentGroupRouter := router.Group("/v1/admin/document") + adminDocumentGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware, serverCtx.DeviceMiddleware}, - []rest.Route{ - { - // Query User Affiliate Count - Method: http.MethodGet, - Path: "/affiliate/count", - Handler: publicuser.QueryUserAffiliateHandler(serverCtx), - }, - { - // Query User Affiliate List - Method: http.MethodGet, - Path: "/affiliate/list", - Handler: publicuser.QueryUserAffiliateListHandler(serverCtx), - }, - { - // Get Agent Downloads - Method: http.MethodGet, - Path: "/agent_downloads", - Handler: publicuser.GetAgentDownloadsHandler(serverCtx), - }, - { - // Get Agent Realtime - Method: http.MethodGet, - Path: "/agent_realtime", - Handler: publicuser.GetAgentRealtimeHandler(serverCtx), - }, - { - // Query User Balance Log - Method: http.MethodGet, - Path: "/balance_log", - Handler: publicuser.QueryUserBalanceLogHandler(serverCtx), - }, - { - // Update Bind Email - Method: http.MethodPut, - Path: "/bind_email", - Handler: publicuser.UpdateBindEmailHandler(serverCtx), - }, - { - // Bind Email With Verification - Method: http.MethodPost, - Path: "/bind_email_with_verification", - Handler: publicuser.BindEmailWithVerificationHandler(serverCtx), - }, - { - // Bind Invite Code - Method: http.MethodPost, - Path: "/bind_invite_code", - Handler: publicuser.BindInviteCodeHandler(serverCtx), - }, - { - // Update Bind Mobile - Method: http.MethodPut, - Path: "/bind_mobile", - Handler: publicuser.UpdateBindMobileHandler(serverCtx), - }, - { - // Bind OAuth - Method: http.MethodPost, - Path: "/bind_oauth", - Handler: publicuser.BindOAuthHandler(serverCtx), - }, - { - // Bind OAuth Callback - Method: http.MethodPost, - Path: "/bind_oauth/callback", - Handler: publicuser.BindOAuthCallbackHandler(serverCtx), - }, - { - // Bind Telegram - Method: http.MethodGet, - Path: "/bind_telegram", - Handler: publicuser.BindTelegramHandler(serverCtx), - }, - { - // Query User Commission Log - Method: http.MethodGet, - Path: "/commission_log", - Handler: publicuser.QueryUserCommissionLogHandler(serverCtx), - }, - { - // Commission Withdraw - Method: http.MethodPost, - Path: "/commission_withdraw", - Handler: publicuser.CommissionWithdrawHandler(serverCtx), - }, - { - // Delete Current User Account - Method: http.MethodDelete, - Path: "/current_user_account", - Handler: publicuser.DeleteCurrentUserAccountHandler(serverCtx), - }, - { - // Delete Account - Method: http.MethodPost, - Path: "/delete_account", - Handler: publicuser.DeleteAccountHandler(serverCtx), - }, - { - // Device Online Statistics - Method: http.MethodGet, - Path: "/device_online_statistics", - Handler: publicuser.DeviceOnlineStatisticsHandler(serverCtx), - }, - { - // Get Device List - Method: http.MethodGet, - Path: "/devices", - Handler: publicuser.GetDeviceListHandler(serverCtx), - }, - { - // Query User Info - Method: http.MethodGet, - Path: "/info", - Handler: publicuser.QueryUserInfoHandler(serverCtx), - }, - { - // Get Invite Records - Method: http.MethodGet, - Path: "/invite_records", - Handler: publicuser.GetInviteRecordsHandler(serverCtx), - }, - { - // Get Invite Sales - Method: http.MethodGet, - Path: "/invite_sales", - Handler: publicuser.GetInviteSalesHandler(serverCtx), - }, - { - // Get Invite Sales (backward-compat alias) - Method: http.MethodGet, - Path: "/invite/sales", - Handler: publicuser.GetInviteSalesHandler(serverCtx), - }, - { - // Get User Invite Stats - Method: http.MethodGet, - Path: "/invite_stats", - Handler: publicuser.GetUserInviteStatsHandler(serverCtx), - }, - { - // Get Login Log - Method: http.MethodGet, - Path: "/login_log", - Handler: publicuser.GetLoginLogHandler(serverCtx), - }, - { - // Update User Notify - Method: http.MethodPut, - Path: "/notify", - Handler: publicuser.UpdateUserNotifyHandler(serverCtx), - }, - { - // Get OAuth Methods - Method: http.MethodGet, - Path: "/oauth_methods", - Handler: publicuser.GetOAuthMethodsHandler(serverCtx), - }, - { - // Update User Password - Method: http.MethodPut, - Path: "/password", - Handler: publicuser.UpdateUserPasswordHandler(serverCtx), - }, - { - // Update User Rules - Method: http.MethodPut, - Path: "/rules", - Handler: publicuser.UpdateUserRulesHandler(serverCtx), - }, - { - // Query User Subscribe - Method: http.MethodGet, - Path: "/subscribe", - Handler: publicuser.QueryUserSubscribeHandler(serverCtx), - }, - { - // Get Subscribe Log - Method: http.MethodGet, - Path: "/subscribe_log", - Handler: publicuser.GetSubscribeLogHandler(serverCtx), - }, - { - // Update User Subscribe Note - Method: http.MethodPut, - Path: "/subscribe_note", - Handler: publicuser.UpdateUserSubscribeNoteHandler(serverCtx), - }, - { - // Get Subscribe Status - Method: http.MethodPost, - Path: "/subscribe_status", - Handler: publicuser.GetSubscribeStatusHandler(serverCtx), - }, - { - // Reset User Subscribe Token - Method: http.MethodPut, - Path: "/subscribe_token", - Handler: publicuser.ResetUserSubscribeTokenHandler(serverCtx), - }, - { - // Get User Traffic Statistics - Method: http.MethodGet, - Path: "/traffic_stats", - Handler: publicuser.GetUserTrafficStatsHandler(serverCtx), - }, - { - // Unbind Device - Method: http.MethodPut, - Path: "/unbind_device", - Handler: publicuser.UnbindDeviceHandler(serverCtx), - }, - { - // Unbind OAuth - Method: http.MethodPost, - Path: "/unbind_oauth", - Handler: publicuser.UnbindOAuthHandler(serverCtx), - }, - { - // Unbind Telegram - Method: http.MethodPost, - Path: "/unbind_telegram", - Handler: publicuser.UnbindTelegramHandler(serverCtx), - }, - { - // Unsubscribe - Method: http.MethodPost, - Path: "/unsubscribe", - Handler: publicuser.UnsubscribeHandler(serverCtx), - }, - { - // Pre Unsubscribe - Method: http.MethodPost, - Path: "/unsubscribe/pre", - Handler: publicuser.PreUnsubscribeHandler(serverCtx), - }, - { - // Verify Email - Method: http.MethodPost, - Path: "/verify_email", - Handler: publicuser.VerifyEmailHandler(serverCtx), - }, - { - // Cancel pending withdrawal - Method: http.MethodPost, - Path: "/withdrawal_cancel", - Handler: publicuser.CancelWithdrawalHandler(serverCtx), - }, - { - // Query Withdrawal Log - Method: http.MethodGet, - Path: "/withdrawal_log", - Handler: publicuser.QueryWithdrawalLogHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/user"), - ) + { + // Create document + adminDocumentGroupRouter.POST("/", adminDocument.CreateDocumentHandler(serverCtx)) - server.AddRoutes( - rest.WithMiddlewares( - []rest.Middleware{serverCtx.AuthMiddleware}, - []rest.Route{ - { - // Webosocket Device Connect - Method: http.MethodGet, - Path: "/device_ws_connect", - Handler: publicuserws.DeviceWsConnectHandler(serverCtx), - }, - }..., - ), - rest.WithPrefix("/v1/public/user"), - ) + // Update document + adminDocumentGroupRouter.PUT("/", adminDocument.UpdateDocumentHandler(serverCtx)) + + // Delete document + adminDocumentGroupRouter.DELETE("/", adminDocument.DeleteDocumentHandler(serverCtx)) + + // Batch delete document + adminDocumentGroupRouter.DELETE("/batch", adminDocument.BatchDeleteDocumentHandler(serverCtx)) + + // Get document detail + adminDocumentGroupRouter.GET("/detail", adminDocument.GetDocumentDetailHandler(serverCtx)) + + // Get document list + adminDocumentGroupRouter.GET("/list", adminDocument.GetDocumentListHandler(serverCtx)) + } + + adminInviteGroupRouter := router.Group("/v1/admin/invite") + adminInviteGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Get invite manage list + adminInviteGroupRouter.GET("/list", adminInvite.GetInviteManageListHandler(serverCtx)) + } + + adminGroupGroupRouter := router.Group("/v1/admin/group") + adminGroupGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Get group config + adminGroupGroupRouter.GET("/config", adminGroup.GetGroupConfigHandler(serverCtx)) + + // Update group config + adminGroupGroupRouter.PUT("/config", adminGroup.UpdateGroupConfigHandler(serverCtx)) + + // Export group result + adminGroupGroupRouter.GET("/export", adminGroup.ExportGroupResultHandler(serverCtx)) + + // Get group history + adminGroupGroupRouter.GET("/history", adminGroup.GetGroupHistoryHandler(serverCtx)) + + // Get group history detail + adminGroupGroupRouter.GET("/history/detail", adminGroup.GetGroupHistoryDetailHandler(serverCtx)) + + // Create node group + adminGroupGroupRouter.POST("/node", adminGroup.CreateNodeGroupHandler(serverCtx)) + + // Update node group + adminGroupGroupRouter.PUT("/node", adminGroup.UpdateNodeGroupHandler(serverCtx)) + + // Delete node group + adminGroupGroupRouter.DELETE("/node", adminGroup.DeleteNodeGroupHandler(serverCtx)) + + // Get node group list + adminGroupGroupRouter.GET("/node/list", adminGroup.GetNodeGroupListHandler(serverCtx)) + + // Preview user nodes + adminGroupGroupRouter.GET("/preview", adminGroup.PreviewUserNodesHandler(serverCtx)) + + // Recalculate group + adminGroupGroupRouter.POST("/recalculate", adminGroup.RecalculateGroupHandler(serverCtx)) + + // Get recalculation status + adminGroupGroupRouter.GET("/recalculation/status", adminGroup.GetRecalculationStatusHandler(serverCtx)) + + // Reset all groups + adminGroupGroupRouter.POST("/reset", adminGroup.ResetGroupsHandler(serverCtx)) + + // Get subscribe group mapping + adminGroupGroupRouter.GET("/subscribe/mapping", adminGroup.GetSubscribeGroupMappingHandler(serverCtx)) + } + + adminLogGroupRouter := router.Group("/v1/admin/log") + adminLogGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Filter balance log + adminLogGroupRouter.GET("/balance/list", adminLog.FilterBalanceLogHandler(serverCtx)) + + // Filter commission log + adminLogGroupRouter.GET("/commission/list", adminLog.FilterCommissionLogHandler(serverCtx)) + + // Filter order refund log + adminLogGroupRouter.GET("/order/refund/list", adminLog.FilterOrderRefundLogHandler(serverCtx)) + + // Filter email log + adminLogGroupRouter.GET("/email/list", adminLog.FilterEmailLogHandler(serverCtx)) + + // Get error log message detail + adminLogGroupRouter.GET("/error_message/detail", adminLog.GetErrorLogMessageDetailHandler(serverCtx)) + + // Get log message raw detail (temporary) + adminLogGroupRouter.GET("/message/detail", adminLog.GetLogMessageRawHandler(serverCtx)) + + // Get error log message list + adminLogGroupRouter.GET("/error_message/list", adminLog.GetErrorLogMessageListHandler(serverCtx)) + + // Filter gift log + adminLogGroupRouter.GET("/gift/list", adminLog.FilterGiftLogHandler(serverCtx)) + + // Filter login log + adminLogGroupRouter.GET("/login/list", adminLog.FilterLoginLogHandler(serverCtx)) + + // Get message log list + adminLogGroupRouter.GET("/message/list", adminLog.GetMessageLogListHandler(serverCtx)) + + // Filter mobile log + adminLogGroupRouter.GET("/mobile/list", adminLog.FilterMobileLogHandler(serverCtx)) + + // Filter register log + adminLogGroupRouter.GET("/register/list", adminLog.FilterRegisterLogHandler(serverCtx)) + + // Filter server traffic log + adminLogGroupRouter.GET("/server/traffic/list", adminLog.FilterServerTrafficLogHandler(serverCtx)) + + // Get log setting + adminLogGroupRouter.GET("/setting", adminLog.GetLogSettingHandler(serverCtx)) + + // Update log setting + adminLogGroupRouter.POST("/setting", adminLog.UpdateLogSettingHandler(serverCtx)) + + // Filter subscribe log + adminLogGroupRouter.GET("/subscribe/list", adminLog.FilterSubscribeLogHandler(serverCtx)) + + // Filter reset subscribe log + adminLogGroupRouter.GET("/subscribe/reset/list", adminLog.FilterResetSubscribeLogHandler(serverCtx)) + + // Filter user subscribe traffic log + adminLogGroupRouter.GET("/subscribe/traffic/list", adminLog.FilterUserSubscribeTrafficLogHandler(serverCtx)) + + // Filter traffic log details + adminLogGroupRouter.GET("/traffic/details", adminLog.FilterTrafficLogDetailsHandler(serverCtx)) + } + + adminMarketingGroupRouter := router.Group("/v1/admin/marketing") + adminMarketingGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Get batch send email task list + adminMarketingGroupRouter.GET("/email/batch/list", adminMarketing.GetBatchSendEmailTaskListHandler(serverCtx)) + + // Get pre-send email count + adminMarketingGroupRouter.POST("/email/batch/pre-send-count", adminMarketing.GetPreSendEmailCountHandler(serverCtx)) + + // Create a batch send email task + adminMarketingGroupRouter.POST("/email/batch/send", adminMarketing.CreateBatchSendEmailTaskHandler(serverCtx)) + + // Get batch send email task status + adminMarketingGroupRouter.POST("/email/batch/status", adminMarketing.GetBatchSendEmailTaskStatusHandler(serverCtx)) + + // Stop a batch send email task + adminMarketingGroupRouter.POST("/email/batch/stop", adminMarketing.StopBatchSendEmailTaskHandler(serverCtx)) + + // Create a quota task + adminMarketingGroupRouter.POST("/quota/create", adminMarketing.CreateQuotaTaskHandler(serverCtx)) + + // Query quota task list + adminMarketingGroupRouter.GET("/quota/list", adminMarketing.QueryQuotaTaskListHandler(serverCtx)) + + // Query quota task pre-count + adminMarketingGroupRouter.POST("/quota/pre-count", adminMarketing.QueryQuotaTaskPreCountHandler(serverCtx)) + + // Query quota task status + adminMarketingGroupRouter.POST("/quota/status", adminMarketing.QueryQuotaTaskStatusHandler(serverCtx)) + } + + adminOrderGroupRouter := router.Group("/v1/admin/order") + adminOrderGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Create order + adminOrderGroupRouter.POST("/", adminOrder.CreateOrderHandler(serverCtx)) + + // Get order list + adminOrderGroupRouter.GET("/list", adminOrder.GetOrderListHandler(serverCtx)) + + // Update order status + adminOrderGroupRouter.PUT("/status", adminOrder.UpdateOrderStatusHandler(serverCtx)) + + // Refund order + adminOrderGroupRouter.POST("/refund", adminOrder.RefundOrderHandler(serverCtx)) + + // Manually activate order + adminOrderGroupRouter.POST("/activate", adminOrder.ActivateOrderHandler(serverCtx)) + } + + adminPaymentGroupRouter := router.Group("/v1/admin/payment") + adminPaymentGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Create Payment Method + adminPaymentGroupRouter.POST("/", adminPayment.CreatePaymentMethodHandler(serverCtx)) + + // Update Payment Method + adminPaymentGroupRouter.PUT("/", adminPayment.UpdatePaymentMethodHandler(serverCtx)) + + // Delete Payment Method + adminPaymentGroupRouter.DELETE("/", adminPayment.DeletePaymentMethodHandler(serverCtx)) + + // Get Payment Method List + adminPaymentGroupRouter.GET("/list", adminPayment.GetPaymentMethodListHandler(serverCtx)) + + // Get supported payment platform + adminPaymentGroupRouter.GET("/platform", adminPayment.GetPaymentPlatformHandler(serverCtx)) + } + + adminPromoGroupRouter := router.Group("/v1/admin/promo") + adminPromoGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Create promo rule + adminPromoGroupRouter.POST("/rule", adminPromo.CreateRuleHandler(serverCtx)) + + // Get promo rule list + adminPromoGroupRouter.GET("/rule/list", adminPromo.GetRuleListHandler(serverCtx)) + + // Get promo rule detail + adminPromoGroupRouter.GET("/rule/:id", adminPromo.GetRuleDetailHandler(serverCtx)) + + // Update promo rule + adminPromoGroupRouter.PUT("/rule/:id", adminPromo.UpdateRuleHandler(serverCtx)) + + // Delete promo rule + adminPromoGroupRouter.DELETE("/rule/:id", adminPromo.DeleteRuleHandler(serverCtx)) + + // Set promo prices + adminPromoGroupRouter.POST("/price", adminPromo.SetPriceHandler(serverCtx)) + + // Get promo price list + adminPromoGroupRouter.GET("/price/list", adminPromo.GetPriceListHandler(serverCtx)) + + // Delete promo price + adminPromoGroupRouter.DELETE("/price/:id", adminPromo.DeletePriceHandler(serverCtx)) + + // Get promo usage list + adminPromoGroupRouter.GET("/usage/list", adminPromo.GetUsageListHandler(serverCtx)) + } + + adminRedemptionGroupRouter := router.Group("/v1/admin/redemption") + adminRedemptionGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Create redemption code + adminRedemptionGroupRouter.POST("/code", adminRedemption.CreateRedemptionCodeHandler(serverCtx)) + + // Update redemption code + adminRedemptionGroupRouter.PUT("/code", adminRedemption.UpdateRedemptionCodeHandler(serverCtx)) + + // Delete redemption code + adminRedemptionGroupRouter.DELETE("/code", adminRedemption.DeleteRedemptionCodeHandler(serverCtx)) + + // Batch delete redemption code + adminRedemptionGroupRouter.DELETE("/code/batch", adminRedemption.BatchDeleteRedemptionCodeHandler(serverCtx)) + + // Get redemption code list + adminRedemptionGroupRouter.GET("/code/list", adminRedemption.GetRedemptionCodeListHandler(serverCtx)) + + // Toggle redemption code status + adminRedemptionGroupRouter.PUT("/code/status", adminRedemption.ToggleRedemptionCodeStatusHandler(serverCtx)) + + // Get redemption record list + adminRedemptionGroupRouter.GET("/record/list", adminRedemption.GetRedemptionRecordListHandler(serverCtx)) + } + + adminServerGroupRouter := router.Group("/v1/admin/server") + adminServerGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Create Server + adminServerGroupRouter.POST("/create", adminServer.CreateServerHandler(serverCtx)) + + // Delete Server + adminServerGroupRouter.POST("/delete", adminServer.DeleteServerHandler(serverCtx)) + + // Filter Server List + adminServerGroupRouter.GET("/list", adminServer.FilterServerListHandler(serverCtx)) + + // Create Node + adminServerGroupRouter.POST("/node/create", adminServer.CreateNodeHandler(serverCtx)) + + // Delete Node + adminServerGroupRouter.POST("/node/delete", adminServer.DeleteNodeHandler(serverCtx)) + + // Filter Node List + adminServerGroupRouter.GET("/node/list", adminServer.FilterNodeListHandler(serverCtx)) + + // Reset node sort + adminServerGroupRouter.POST("/node/sort", adminServer.ResetSortWithNodeHandler(serverCtx)) + + // Toggle Node Status + adminServerGroupRouter.POST("/node/status/toggle", adminServer.ToggleNodeStatusHandler(serverCtx)) + + // Query all node tags + adminServerGroupRouter.GET("/node/tags", adminServer.QueryNodeTagHandler(serverCtx)) + + // Update Node + adminServerGroupRouter.POST("/node/update", adminServer.UpdateNodeHandler(serverCtx)) + + // Get Server Protocols + adminServerGroupRouter.GET("/protocols", adminServer.GetServerProtocolsHandler(serverCtx)) + + // Reset server sort + adminServerGroupRouter.POST("/server/sort", adminServer.ResetSortWithServerHandler(serverCtx)) + + // Update Server + adminServerGroupRouter.POST("/update", adminServer.UpdateServerHandler(serverCtx)) + } + + adminSubscribeGroupRouter := router.Group("/v1/admin/subscribe") + adminSubscribeGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Create subscribe + adminSubscribeGroupRouter.POST("/", adminSubscribe.CreateSubscribeHandler(serverCtx)) + + // Update subscribe + adminSubscribeGroupRouter.PUT("/", adminSubscribe.UpdateSubscribeHandler(serverCtx)) + + // Delete subscribe + adminSubscribeGroupRouter.DELETE("/", adminSubscribe.DeleteSubscribeHandler(serverCtx)) + + // Batch delete subscribe + adminSubscribeGroupRouter.DELETE("/batch", adminSubscribe.BatchDeleteSubscribeHandler(serverCtx)) + + // Get subscribe details + adminSubscribeGroupRouter.GET("/details", adminSubscribe.GetSubscribeDetailsHandler(serverCtx)) + + // Create subscribe group + adminSubscribeGroupRouter.POST("/group", adminSubscribe.CreateSubscribeGroupHandler(serverCtx)) + + // Update subscribe group + adminSubscribeGroupRouter.PUT("/group", adminSubscribe.UpdateSubscribeGroupHandler(serverCtx)) + + // Delete subscribe group + adminSubscribeGroupRouter.DELETE("/group", adminSubscribe.DeleteSubscribeGroupHandler(serverCtx)) + + // Batch delete subscribe group + adminSubscribeGroupRouter.DELETE("/group/batch", adminSubscribe.BatchDeleteSubscribeGroupHandler(serverCtx)) + + // Get subscribe group list + adminSubscribeGroupRouter.GET("/group/list", adminSubscribe.GetSubscribeGroupListHandler(serverCtx)) + + // Get subscribe list + adminSubscribeGroupRouter.GET("/list", adminSubscribe.GetSubscribeListHandler(serverCtx)) + + // Reset all subscribe tokens + adminSubscribeGroupRouter.POST("/reset_all_token", adminSubscribe.ResetAllSubscribeTokenHandler(serverCtx)) + + // Subscribe sort + adminSubscribeGroupRouter.POST("/sort", adminSubscribe.SubscribeSortHandler(serverCtx)) + } + + adminSystemGroupRouter := router.Group("/v1/admin/system") + adminSystemGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Get Currency Config + adminSystemGroupRouter.GET("/currency_config", adminSystem.GetCurrencyConfigHandler(serverCtx)) + + // Update Currency Config + adminSystemGroupRouter.PUT("/currency_config", adminSystem.UpdateCurrencyConfigHandler(serverCtx)) + + // Get Node Multiplier + adminSystemGroupRouter.GET("/get_node_multiplier", adminSystem.GetNodeMultiplierHandler(serverCtx)) + + // Get invite config + adminSystemGroupRouter.GET("/invite_config", adminSystem.GetInviteConfigHandler(serverCtx)) + + // Update invite config + adminSystemGroupRouter.PUT("/invite_config", adminSystem.UpdateInviteConfigHandler(serverCtx)) + + // Get Module Config + adminSystemGroupRouter.GET("/module", adminSystem.GetModuleConfigHandler(serverCtx)) + + // Get node config + adminSystemGroupRouter.GET("/node_config", adminSystem.GetNodeConfigHandler(serverCtx)) + + // Update node config + adminSystemGroupRouter.PUT("/node_config", adminSystem.UpdateNodeConfigHandler(serverCtx)) + + // PreView Node Multiplier + adminSystemGroupRouter.GET("/node_multiplier/preview", adminSystem.PreViewNodeMultiplierHandler(serverCtx)) + + // get Privacy Policy Config + adminSystemGroupRouter.GET("/privacy", adminSystem.GetPrivacyPolicyConfigHandler(serverCtx)) + + // Update Privacy Policy Config + adminSystemGroupRouter.PUT("/privacy", adminSystem.UpdatePrivacyPolicyConfigHandler(serverCtx)) + + // Get register config + adminSystemGroupRouter.GET("/register_config", adminSystem.GetRegisterConfigHandler(serverCtx)) + + // Update register config + adminSystemGroupRouter.PUT("/register_config", adminSystem.UpdateRegisterConfigHandler(serverCtx)) + + // Set Node Multiplier + adminSystemGroupRouter.POST("/set_node_multiplier", adminSystem.SetNodeMultiplierHandler(serverCtx)) + + // setting telegram bot + adminSystemGroupRouter.POST("/setting_telegram_bot", adminSystem.SettingTelegramBotHandler(serverCtx)) + + // Get Signature Config + adminSystemGroupRouter.GET("/signature_config", adminSystem.GetSignatureConfigHandler(serverCtx)) + + // Update Signature Config + adminSystemGroupRouter.PUT("/signature_config", adminSystem.UpdateSignatureConfigHandler(serverCtx)) + + // Get site config + adminSystemGroupRouter.GET("/site_config", adminSystem.GetSiteConfigHandler(serverCtx)) + + // Update site config + adminSystemGroupRouter.PUT("/site_config", adminSystem.UpdateSiteConfigHandler(serverCtx)) + + // Get subscribe config + adminSystemGroupRouter.GET("/subscribe_config", adminSystem.GetSubscribeConfigHandler(serverCtx)) + + // Update subscribe config + adminSystemGroupRouter.PUT("/subscribe_config", adminSystem.UpdateSubscribeConfigHandler(serverCtx)) + + // Get Team of Service Config + adminSystemGroupRouter.GET("/tos_config", adminSystem.GetTosConfigHandler(serverCtx)) + + // Update Team of Service Config + adminSystemGroupRouter.PUT("/tos_config", adminSystem.UpdateTosConfigHandler(serverCtx)) + + // Get Verify Code Config + adminSystemGroupRouter.GET("/verify_code_config", adminSystem.GetVerifyCodeConfigHandler(serverCtx)) + + // Update Verify Code Config + adminSystemGroupRouter.PUT("/verify_code_config", adminSystem.UpdateVerifyCodeConfigHandler(serverCtx)) + + // Get verify config + adminSystemGroupRouter.GET("/verify_config", adminSystem.GetVerifyConfigHandler(serverCtx)) + + // Update verify config + adminSystemGroupRouter.PUT("/verify_config", adminSystem.UpdateVerifyConfigHandler(serverCtx)) + } + + adminTicketGroupRouter := router.Group("/v1/admin/ticket") + adminTicketGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Update ticket status + adminTicketGroupRouter.PUT("/", adminTicket.UpdateTicketStatusHandler(serverCtx)) + + // Get ticket detail + adminTicketGroupRouter.GET("/detail", adminTicket.GetTicketHandler(serverCtx)) + + // Create ticket follow + adminTicketGroupRouter.POST("/follow", adminTicket.CreateTicketFollowHandler(serverCtx)) + + // Get ticket list + adminTicketGroupRouter.GET("/list", adminTicket.GetTicketListHandler(serverCtx)) + } + + adminToolGroupRouter := router.Group("/v1/admin/tool") + adminToolGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Query IP Location + adminToolGroupRouter.GET("/ip/location", adminTool.QueryIPLocationHandler(serverCtx)) + + // Get System Log + adminToolGroupRouter.GET("/log", adminTool.GetSystemLogHandler(serverCtx)) + + // Restart System + adminToolGroupRouter.GET("/restart", adminTool.RestartSystemHandler(serverCtx)) + + // Get Version + adminToolGroupRouter.GET("/version", adminTool.GetVersionHandler(serverCtx)) + } + + adminUserGroupRouter := router.Group("/v1/admin/user") + adminUserGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Delete user + adminUserGroupRouter.DELETE("/", adminUser.DeleteUserHandler(serverCtx)) + + // Create user + adminUserGroupRouter.POST("/", adminUser.CreateUserHandler(serverCtx)) + + // Create user auth method + adminUserGroupRouter.POST("/auth_method", adminUser.CreateUserAuthMethodHandler(serverCtx)) + + // Delete user auth method + adminUserGroupRouter.DELETE("/auth_method", adminUser.DeleteUserAuthMethodHandler(serverCtx)) + + // Update user auth method + adminUserGroupRouter.PUT("/auth_method", adminUser.UpdateUserAuthMethodHandler(serverCtx)) + + // Get user auth method + adminUserGroupRouter.GET("/auth_method", adminUser.GetUserAuthMethodHandler(serverCtx)) + + // Update user basic info + adminUserGroupRouter.PUT("/basic", adminUser.UpdateUserBasicInfoHandler(serverCtx)) + + // Batch delete user + adminUserGroupRouter.DELETE("/batch", adminUser.BatchDeleteUserHandler(serverCtx)) + + // Current user + adminUserGroupRouter.GET("/current", adminUser.CurrentUserHandler(serverCtx)) + + // Get user detail + adminUserGroupRouter.GET("/detail", adminUser.GetUserDetailHandler(serverCtx)) + + // User device + adminUserGroupRouter.PUT("/device", adminUser.UpdateUserDeviceHandler(serverCtx)) + + // Delete user device + adminUserGroupRouter.DELETE("/device", adminUser.DeleteUserDeviceHandler(serverCtx)) + + // kick offline user device + adminUserGroupRouter.PUT("/device/kick_offline", adminUser.KickOfflineByUserDeviceHandler(serverCtx)) + + // Get family detail + adminUserGroupRouter.GET("/family/detail", adminUser.GetFamilyDetailHandler(serverCtx)) + + // Dissolve family + adminUserGroupRouter.PUT("/family/dissolve", adminUser.DissolveFamilyHandler(serverCtx)) + + // Get family list + adminUserGroupRouter.GET("/family/list", adminUser.GetFamilyListHandler(serverCtx)) + + // Update family max members + adminUserGroupRouter.PUT("/family/max_members", adminUser.UpdateFamilyMaxMembersHandler(serverCtx)) + + // Remove family member + adminUserGroupRouter.PUT("/family/member/remove", adminUser.RemoveFamilyMemberHandler(serverCtx)) + + // Get user list + adminUserGroupRouter.GET("/list", adminUser.GetUserListHandler(serverCtx)) + + // Get user login logs + adminUserGroupRouter.GET("/login/logs", adminUser.GetUserLoginLogsHandler(serverCtx)) + + // Update user notify setting + adminUserGroupRouter.PUT("/notify", adminUser.UpdateUserNotifySettingHandler(serverCtx)) + + // Get user subcribe + adminUserGroupRouter.GET("/subscribe", adminUser.GetUserSubscribeHandler(serverCtx)) + + // Create user subcribe + adminUserGroupRouter.POST("/subscribe", adminUser.CreateUserSubscribeHandler(serverCtx)) + + // Update user subcribe + adminUserGroupRouter.PUT("/subscribe", adminUser.UpdateUserSubscribeHandler(serverCtx)) + + // Delete user subcribe + adminUserGroupRouter.DELETE("/subscribe", adminUser.DeleteUserSubscribeHandler(serverCtx)) + + // Get user subcribe by id + adminUserGroupRouter.GET("/subscribe/detail", adminUser.GetUserSubscribeByIdHandler(serverCtx)) + + // Get user subcribe devices + adminUserGroupRouter.GET("/subscribe/device", adminUser.GetUserSubscribeDevicesHandler(serverCtx)) + + // Get user subcribe logs + adminUserGroupRouter.GET("/subscribe/logs", adminUser.GetUserSubscribeLogsHandler(serverCtx)) + + // Get user subcribe reset traffic logs + adminUserGroupRouter.GET("/subscribe/reset/logs", adminUser.GetUserSubscribeResetTrafficLogsHandler(serverCtx)) + + // Reset user subscribe token + adminUserGroupRouter.POST("/subscribe/reset/token", adminUser.ResetUserSubscribeTokenHandler(serverCtx)) + + // Reset user subscribe traffic + adminUserGroupRouter.POST("/subscribe/reset/traffic", adminUser.ResetUserSubscribeTrafficHandler(serverCtx)) + + // Stop user subscribe + adminUserGroupRouter.POST("/subscribe/toggle", adminUser.ToggleUserSubscribeStatusHandler(serverCtx)) + + // Get user subcribe traffic logs + adminUserGroupRouter.GET("/subscribe/traffic_logs", adminUser.GetUserSubscribeTrafficLogsHandler(serverCtx)) + + // Get admin user invite stats + adminUserGroupRouter.GET("/invite/stats", adminUser.GetAdminUserInviteStatsHandler(serverCtx)) + + // Get admin user invite list + adminUserGroupRouter.GET("/invite/list", adminUser.GetAdminUserInviteListHandler(serverCtx)) + + // Get withdrawal list + adminUserGroupRouter.GET("/withdrawal/list", adminUser.GetWithdrawalListHandler(serverCtx)) + + // Approve withdrawal + adminUserGroupRouter.POST("/withdrawal/approve", adminUser.ApproveWithdrawalHandler(serverCtx)) + + // Reject withdrawal + adminUserGroupRouter.POST("/withdrawal/reject", adminUser.RejectWithdrawalHandler(serverCtx)) + } + + authGroupRouter := router.Group("/v1/auth") + authGroupRouter.Use(middleware.DeviceMiddleware(serverCtx)) + + { + // Generate captcha + authGroupRouter.POST("/captcha/generate", auth.GenerateCaptchaHandler(serverCtx)) + + // Verify slider captcha + authGroupRouter.POST("/captcha/slider/verify", auth.SliderVerifyCaptchaHandler(serverCtx)) + + // Check user is exist + authGroupRouter.GET("/check", auth.CheckUserHandler(serverCtx)) + + // Check user telephone is exist + authGroupRouter.GET("/check/telephone", auth.CheckUserTelephoneHandler(serverCtx)) + + // User login + authGroupRouter.POST("/login", auth.UserLoginHandler(serverCtx)) + + // Device Login + authGroupRouter.POST("/login/device", auth.DeviceLoginHandler(serverCtx)) + + // Email Login + authGroupRouter.POST("/login/email", auth.EmailLoginHandler(serverCtx)) + + // User Telephone login + authGroupRouter.POST("/login/telephone", auth.TelephoneLoginHandler(serverCtx)) + + // User register + authGroupRouter.POST("/register", auth.UserRegisterHandler(serverCtx)) + + // User Telephone register + authGroupRouter.POST("/register/telephone", auth.TelephoneRegisterHandler(serverCtx)) + + // Reset password + authGroupRouter.POST("/reset", auth.ResetPasswordHandler(serverCtx)) + + // Reset password by telephone + authGroupRouter.POST("/reset/telephone", auth.TelephoneResetPasswordHandler(serverCtx)) + } + + authAdminGroupRouter := router.Group("/v1/auth/admin") + authAdminGroupRouter.Use(middleware.DeviceMiddleware(serverCtx)) + + { + // Generate captcha + authAdminGroupRouter.POST("/captcha/generate", authAdmin.AdminGenerateCaptchaHandler(serverCtx)) + + // Verify slider captcha + authAdminGroupRouter.POST("/captcha/slider/verify", authAdmin.AdminSliderVerifyCaptchaHandler(serverCtx)) + + // Admin login + authAdminGroupRouter.POST("/login", authAdmin.AdminLoginHandler(serverCtx)) + + // Admin reset password + authAdminGroupRouter.POST("/reset", authAdmin.AdminResetPasswordHandler(serverCtx)) + } + + authOauthGroupRouter := router.Group("/v1/auth/oauth") + + { + // Apple Login Callback + authOauthGroupRouter.POST("/callback/apple", authOauth.AppleLoginCallbackHandler(serverCtx)) + + // OAuth login + authOauthGroupRouter.POST("/login", authOauth.OAuthLoginHandler(serverCtx)) + + // OAuth login get token + authOauthGroupRouter.POST("/login/token", authOauth.OAuthLoginGetTokenHandler(serverCtx)) + } + + commonGroupRouter := router.Group("/v1/common") + commonGroupRouter.Use(middleware.DeviceMiddleware(serverCtx)) + + { + // Get Ads + commonGroupRouter.GET("/ads", common.GetAdsHandler(serverCtx)) + + // Check verification code + commonGroupRouter.POST("/check_verification_code", common.CheckVerificationCodeHandler(serverCtx)) + + // Get Client + commonGroupRouter.GET("/client", common.GetClientHandler(serverCtx)) + + // Get Download Link + commonGroupRouter.GET("/client/download", common.GetDownloadLinkHandler(serverCtx)) + + // Heartbeat + commonGroupRouter.GET("/heartbeat", common.HeartbeatHandler(serverCtx)) + + // Get verification code + commonGroupRouter.POST("/send_code", common.SendEmailCodeHandler(serverCtx)) + + // Get sms verification code + commonGroupRouter.POST("/send_sms_code", common.SendSmsCodeHandler(serverCtx)) + + // Get global config + commonGroupRouter.GET("/site/config", common.GetGlobalConfigHandler(serverCtx)) + + // Get Privacy Policy + commonGroupRouter.GET("/site/privacy", common.GetPrivacyPolicyHandler(serverCtx)) + + // Get stat + commonGroupRouter.GET("/site/stat", common.GetStatHandler(serverCtx)) + + // Get Tos Content + commonGroupRouter.GET("/site/tos", common.GetTosHandler(serverCtx)) + + // Submit contact info + commonGroupRouter.POST("/contact", common.SubmitContactHandler(serverCtx)) + + // Report log message + commonGroupRouter.POST("/log/report", common.ReportLogMessageHandler(serverCtx)) + + // Check verification code (legacy v1) + commonGroupRouter.POST("/check_code", auth.CheckCodeLegacyV1Handler(serverCtx)) + + // Check verification code (legacy v2, consume code) + commonGroupRouter.POST("/check_code/v2", auth.CheckCodeLegacyV2Handler(serverCtx)) + } + + publicAnnouncementGroupRouter := router.Group("/v1/public/announcement") + publicAnnouncementGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Query announcement + publicAnnouncementGroupRouter.GET("/list", publicAnnouncement.QueryAnnouncementHandler(serverCtx)) + } + + publicIapAppleGroupRouter := router.Group("/v1/public/iap/apple") + publicIapAppleGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Attach Apple Transaction + publicIapAppleGroupRouter.POST("/transactions/attach", publicIapApple.AttachAppleTransactionHandler(serverCtx)) + + // Attach Apple Transaction By Id + publicIapAppleGroupRouter.POST("/transactions/attach/id", publicIapApple.AttachAppleTransactionByIdHandler(serverCtx)) + + // Restore Apple Transactions + publicIapAppleGroupRouter.POST("/transactions/restore", publicIapApple.RestoreAppleTransactionsHandler(serverCtx)) + + // Get Apple IAP Status + publicIapAppleGroupRouter.GET("/status", publicIapApple.GetAppleStatusHandler(serverCtx)) + } + + publicDocumentGroupRouter := router.Group("/v1/public/document") + publicDocumentGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Get document detail + publicDocumentGroupRouter.GET("/detail", publicDocument.QueryDocumentDetailHandler(serverCtx)) + + // Get document list + publicDocumentGroupRouter.GET("/list", publicDocument.QueryDocumentListHandler(serverCtx)) + } + + publicFileGroupRouter := router.Group("/v1/public/file") + publicFileGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Upload file to RustFS + publicFileGroupRouter.POST("/upload", publicFile.FileUploadHandler(serverCtx)) + + // Init file upload + publicFileGroupRouter.POST("/upload/init", publicFile.FileUploadInitHandler(serverCtx)) + + // Complete file upload + publicFileGroupRouter.POST("/upload/complete", publicFile.FileUploadCompleteHandler(serverCtx)) + } + + publicOrderGroupRouter := router.Group("/v1/public/order") + publicOrderGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Close order + publicOrderGroupRouter.POST("/close", publicOrder.CloseOrderHandler(serverCtx)) + + // Get order + publicOrderGroupRouter.GET("/detail", publicOrder.QueryOrderDetailHandler(serverCtx)) + + // Get order list + publicOrderGroupRouter.GET("/list", publicOrder.QueryOrderListHandler(serverCtx)) + + // Pre create order + publicOrderGroupRouter.POST("/pre", publicOrder.PreCreateOrderHandler(serverCtx)) + + // purchase Subscription + publicOrderGroupRouter.POST("/purchase", publicOrder.PurchaseHandler(serverCtx)) + + // Recharge + publicOrderGroupRouter.POST("/recharge", publicOrder.RechargeHandler(serverCtx)) + + // Renewal Subscription + publicOrderGroupRouter.POST("/renewal", publicOrder.RenewalHandler(serverCtx)) + + // Reset traffic + publicOrderGroupRouter.POST("/reset", publicOrder.ResetTrafficHandler(serverCtx)) + } + + publicPaymentGroupRouter := router.Group("/v1/public/payment") + publicPaymentGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Get available payment methods + publicPaymentGroupRouter.GET("/methods", publicPayment.GetAvailablePaymentMethodsHandler(serverCtx)) + } + + publicPortalGroupRouter := router.Group("/v1/public/portal") + publicPortalGroupRouter.Use(middleware.DeviceMiddleware(serverCtx)) + + { + // Purchase Checkout + publicPortalGroupRouter.POST("/order/checkout", publicPortal.PurchaseCheckoutHandler(serverCtx)) + + // Query Purchase Order + publicPortalGroupRouter.GET("/order/status", publicPortal.QueryPurchaseOrderHandler(serverCtx)) + + // Get available payment methods + publicPortalGroupRouter.GET("/payment-method", publicPortal.GetAvailablePaymentMethodsHandler(serverCtx)) + + // Pre Purchase Order + publicPortalGroupRouter.POST("/pre", publicPortal.PrePurchaseOrderHandler(serverCtx)) + + // Purchase subscription + publicPortalGroupRouter.POST("/purchase", publicPortal.PurchaseHandler(serverCtx)) + + // Get Subscription + publicPortalGroupRouter.GET("/subscribe", publicPortal.GetSubscriptionHandler(serverCtx)) + } + + publicRedemptionGroupRouter := router.Group("/v1/public/redemption") + publicRedemptionGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Redeem code + publicRedemptionGroupRouter.POST("/", publicRedemption.RedeemCodeHandler(serverCtx)) + } + + publicRecoveryGroupRouter := router.Group("/v1/public/recovery") + publicRecoveryGroupRouter.Use(middleware.DeviceMiddleware(serverCtx)) + + { + // Send recovery verification code + publicRecoveryGroupRouter.POST("/send_code", publicRecovery.SendCodeHandler(serverCtx)) + + // Recover order subscription + publicRecoveryGroupRouter.POST("/order", publicRecovery.RecoverOrderHandler(serverCtx)) + } + + publicSubscribeGroupRouter := router.Group("/v1/public/subscribe") + + { + // Get subscribe list + publicSubscribeGroupRouter.GET("/list", middleware.OptionalAuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx), publicSubscribe.QuerySubscribeListHandler(serverCtx)) + + // Get user subscribe node info + publicSubscribeGroupRouter.GET("/node/list", middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx), publicSubscribe.QueryUserSubscribeNodeListHandler(serverCtx)) + + // Get subscribe group list + publicSubscribeGroupRouter.GET("/group/list", middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx), publicSubscribe.QuerySubscribeGroupListHandler(serverCtx)) + } + + publicTicketGroupRouter := router.Group("/v1/public/ticket") + publicTicketGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Update ticket status + publicTicketGroupRouter.PUT("/", publicTicket.UpdateUserTicketStatusHandler(serverCtx)) + + // Create ticket + publicTicketGroupRouter.POST("/", publicTicket.CreateUserTicketHandler(serverCtx)) + + // Get ticket detail + publicTicketGroupRouter.GET("/detail", publicTicket.GetUserTicketDetailsHandler(serverCtx)) + + // Create ticket follow + publicTicketGroupRouter.POST("/follow", publicTicket.CreateUserTicketFollowHandler(serverCtx)) + + // Get ticket list + publicTicketGroupRouter.GET("/list", publicTicket.GetUserTicketListHandler(serverCtx)) + } + + publicUserGroupRouter := router.Group("/v1/public/user") + publicUserGroupRouter.Use(middleware.AuthMiddleware(serverCtx), middleware.DeviceMiddleware(serverCtx)) + + { + // Query User Affiliate Count + publicUserGroupRouter.GET("/affiliate/count", publicUser.QueryUserAffiliateHandler(serverCtx)) + + // Query User Affiliate List + publicUserGroupRouter.GET("/affiliate/list", publicUser.QueryUserAffiliateListHandler(serverCtx)) + + // Get Agent Downloads + publicUserGroupRouter.GET("/agent_downloads", publicUser.GetAgentDownloadsHandler(serverCtx)) + publicUserGroupRouter.GET("/agent/downloads", publicUser.GetAgentDownloadsHandler(serverCtx)) // alias: backward-compat + + // Get Agent Realtime + publicUserGroupRouter.GET("/agent_realtime", publicUser.GetAgentRealtimeHandler(serverCtx)) + publicUserGroupRouter.GET("/agent/realtime", publicUser.GetAgentRealtimeHandler(serverCtx)) // alias: backward-compat + + // Query User Balance Log + publicUserGroupRouter.GET("/balance_log", publicUser.QueryUserBalanceLogHandler(serverCtx)) + + // Update Bind Email + publicUserGroupRouter.PUT("/bind_email", publicUser.UpdateBindEmailHandler(serverCtx)) + + // Bind Email With Verification + publicUserGroupRouter.POST("/bind_email_with_verification", publicUser.BindEmailWithVerificationHandler(serverCtx)) + + // Bind Invite Code + publicUserGroupRouter.POST("/bind_invite_code", publicUser.BindInviteCodeHandler(serverCtx)) + + // Update Bind Mobile + publicUserGroupRouter.PUT("/bind_mobile", publicUser.UpdateBindMobileHandler(serverCtx)) + + // Bind OAuth + publicUserGroupRouter.POST("/bind_oauth", publicUser.BindOAuthHandler(serverCtx)) + + // Bind OAuth Callback + publicUserGroupRouter.POST("/bind_oauth/callback", publicUser.BindOAuthCallbackHandler(serverCtx)) + + // Bind Telegram + publicUserGroupRouter.GET("/bind_telegram", publicUser.BindTelegramHandler(serverCtx)) + + // Query User Commission Log + publicUserGroupRouter.GET("/commission_log", publicUser.QueryUserCommissionLogHandler(serverCtx)) + + // Commission Withdraw + publicUserGroupRouter.POST("/commission_withdraw", publicUser.CommissionWithdrawHandler(serverCtx)) + + // Cancel Withdrawal + publicUserGroupRouter.POST("/withdrawal_cancel", publicUser.CancelWithdrawalHandler(serverCtx)) + + // Delete Current User Account + publicUserGroupRouter.DELETE("/current_user_account", publicUser.DeleteCurrentUserAccountHandler(serverCtx)) + + // Delete Account + publicUserGroupRouter.POST("/delete_account", publicUser.DeleteAccountHandler(serverCtx)) + + // Device Online Statistics + publicUserGroupRouter.GET("/device_online_statistics", publicUser.DeviceOnlineStatisticsHandler(serverCtx)) + + // Get Device List + publicUserGroupRouter.GET("/devices", publicUser.GetDeviceListHandler(serverCtx)) + + // Query User Info + publicUserGroupRouter.GET("/info", publicUser.QueryUserInfoHandler(serverCtx)) + + // Get Invite Records + publicUserGroupRouter.GET("/invite_records", publicUser.GetInviteRecordsHandler(serverCtx)) + + // Get Invite Sales + publicUserGroupRouter.GET("/invite_sales", publicUser.GetInviteSalesHandler(serverCtx)) + publicUserGroupRouter.GET("/invite/sales", publicUser.GetInviteSalesHandler(serverCtx)) // alias: backward-compat + + // Get User Invite Stats + publicUserGroupRouter.GET("/invite_stats", publicUser.GetUserInviteStatsHandler(serverCtx)) + publicUserGroupRouter.GET("/invite/stats", publicUser.GetUserInviteStatsHandler(serverCtx)) // alias: backward-compat + + // Get Login Log + publicUserGroupRouter.GET("/login_log", publicUser.GetLoginLogHandler(serverCtx)) + + // Update User Notify + publicUserGroupRouter.PUT("/notify", publicUser.UpdateUserNotifyHandler(serverCtx)) + + // Get OAuth Methods + publicUserGroupRouter.GET("/oauth_methods", publicUser.GetOAuthMethodsHandler(serverCtx)) + + // Update User Password + publicUserGroupRouter.PUT("/password", publicUser.UpdateUserPasswordHandler(serverCtx)) + + // Update User Rules + publicUserGroupRouter.PUT("/rules", publicUser.UpdateUserRulesHandler(serverCtx)) + + // Query User Subscribe + publicUserGroupRouter.GET("/subscribe", publicUser.QueryUserSubscribeHandler(serverCtx)) + + // Get Subscribe Log + publicUserGroupRouter.GET("/subscribe_log", publicUser.GetSubscribeLogHandler(serverCtx)) + + // Update User Subscribe Note + publicUserGroupRouter.PUT("/subscribe_note", publicUser.UpdateUserSubscribeNoteHandler(serverCtx)) + + // Get Subscribe Status + publicUserGroupRouter.POST("/subscribe_status", publicUser.GetSubscribeStatusHandler(serverCtx)) + + // Reset User Subscribe Token + publicUserGroupRouter.PUT("/subscribe_token", publicUser.ResetUserSubscribeTokenHandler(serverCtx)) + + // Get User Traffic Statistics + publicUserGroupRouter.GET("/traffic_stats", publicUser.GetUserTrafficStatsHandler(serverCtx)) + + // Unbind Device + publicUserGroupRouter.PUT("/unbind_device", publicUser.UnbindDeviceHandler(serverCtx)) + + // Unbind OAuth + publicUserGroupRouter.POST("/unbind_oauth", publicUser.UnbindOAuthHandler(serverCtx)) + + // Unbind Telegram + publicUserGroupRouter.POST("/unbind_telegram", publicUser.UnbindTelegramHandler(serverCtx)) + + // Unsubscribe + publicUserGroupRouter.POST("/unsubscribe", publicUser.UnsubscribeHandler(serverCtx)) + + // Pre Unsubscribe + publicUserGroupRouter.POST("/unsubscribe/pre", publicUser.PreUnsubscribeHandler(serverCtx)) + + // Verify Email + publicUserGroupRouter.POST("/verify_email", publicUser.VerifyEmailHandler(serverCtx)) + + // Query Withdrawal Log + publicUserGroupRouter.GET("/withdrawal_log", publicUser.QueryWithdrawalLogHandler(serverCtx)) + } + + publicUserWsGroupRouter := router.Group("/v1/public/user") + publicUserWsGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) + + { + // Webosocket Device Connect + publicUserWsGroupRouter.GET("/device_ws_connect", publicUserWs.DeviceWsConnectHandler(serverCtx)) + } + + serverGroupRouter := router.Group("/v1/server") + serverGroupRouter.Use(middleware.ServerMiddleware(serverCtx)) + + { + // Get server config + serverGroupRouter.GET("/config", server.GetServerConfigHandler(serverCtx)) + + // Push online users + serverGroupRouter.POST("/online", server.PushOnlineUsersHandler(serverCtx)) + + // Push user Traffic + serverGroupRouter.POST("/push", server.ServerPushUserTrafficHandler(serverCtx)) + + // Push server status + serverGroupRouter.POST("/status", server.ServerPushStatusHandler(serverCtx)) + + // Get user list + serverGroupRouter.GET("/user", server.GetServerUserListHandler(serverCtx)) + } + + serverGroupRouterV2 := router.Group("/v2/server") + + { + // Get Server Protocol Config + serverGroupRouterV2.GET("/:server_id", server.QueryServerProtocolConfigHandler(serverCtx)) + } } diff --git a/internal/logic/common/checkcodelegacylogic.go b/internal/logic/common/checkcodelegacylogic.go deleted file mode 100644 index 805d0c7..0000000 --- a/internal/logic/common/checkcodelegacylogic.go +++ /dev/null @@ -1 +0,0 @@ -package common diff --git a/internal/logic/common/checkcodelegacyv2logic.go b/internal/logic/common/checkcodelegacyv2logic.go deleted file mode 100644 index 805d0c7..0000000 --- a/internal/logic/common/checkcodelegacyv2logic.go +++ /dev/null @@ -1 +0,0 @@ -package common diff --git a/internal/logic/common/reportlogmessagelogic.go b/internal/logic/common/reportlogmessagelogic.go deleted file mode 100644 index 805d0c7..0000000 --- a/internal/logic/common/reportlogmessagelogic.go +++ /dev/null @@ -1 +0,0 @@ -package common diff --git a/internal/logic/common/submitcontactlogic.go b/internal/logic/common/submitcontactlogic.go deleted file mode 100644 index 805d0c7..0000000 --- a/internal/logic/common/submitcontactlogic.go +++ /dev/null @@ -1 +0,0 @@ -package common diff --git a/internal/logic/node/server/getserverconfiglogic.go b/internal/logic/node/server/getserverconfiglogic.go deleted file mode 100644 index abb4e43..0000000 --- a/internal/logic/node/server/getserverconfiglogic.go +++ /dev/null @@ -1 +0,0 @@ -package server diff --git a/internal/logic/node/server/getserveruserlistlogic.go b/internal/logic/node/server/getserveruserlistlogic.go deleted file mode 100644 index abb4e43..0000000 --- a/internal/logic/node/server/getserveruserlistlogic.go +++ /dev/null @@ -1 +0,0 @@ -package server diff --git a/internal/logic/node/server/pushonlineuserslogic.go b/internal/logic/node/server/pushonlineuserslogic.go deleted file mode 100644 index abb4e43..0000000 --- a/internal/logic/node/server/pushonlineuserslogic.go +++ /dev/null @@ -1 +0,0 @@ -package server diff --git a/internal/logic/node/server/queryserverprotocolconfiglogic.go b/internal/logic/node/server/queryserverprotocolconfiglogic.go deleted file mode 100644 index abb4e43..0000000 --- a/internal/logic/node/server/queryserverprotocolconfiglogic.go +++ /dev/null @@ -1 +0,0 @@ -package server diff --git a/internal/logic/node/server/serverpushstatuslogic.go b/internal/logic/node/server/serverpushstatuslogic.go deleted file mode 100644 index abb4e43..0000000 --- a/internal/logic/node/server/serverpushstatuslogic.go +++ /dev/null @@ -1 +0,0 @@ -package server diff --git a/internal/logic/node/server/serverpushusertrafficlogic.go b/internal/logic/node/server/serverpushusertrafficlogic.go deleted file mode 100644 index abb4e43..0000000 --- a/internal/logic/node/server/serverpushusertrafficlogic.go +++ /dev/null @@ -1 +0,0 @@ -package server diff --git a/internal/logic/public/iap/apple/attachappletransactionbyidlogic.go b/internal/logic/public/iap/apple/attachappletransactionbyidlogic.go deleted file mode 100644 index 964f8f7..0000000 --- a/internal/logic/public/iap/apple/attachappletransactionbyidlogic.go +++ /dev/null @@ -1 +0,0 @@ -package apple diff --git a/internal/logic/public/iap/apple/attachappletransactionlogic.go b/internal/logic/public/iap/apple/attachappletransactionlogic.go deleted file mode 100644 index 964f8f7..0000000 --- a/internal/logic/public/iap/apple/attachappletransactionlogic.go +++ /dev/null @@ -1 +0,0 @@ -package apple diff --git a/internal/logic/public/iap/apple/getapplestatuslogic.go b/internal/logic/public/iap/apple/getapplestatuslogic.go deleted file mode 100644 index 964f8f7..0000000 --- a/internal/logic/public/iap/apple/getapplestatuslogic.go +++ /dev/null @@ -1 +0,0 @@ -package apple diff --git a/internal/logic/public/iap/apple/restoreappletransactionslogic.go b/internal/logic/public/iap/apple/restoreappletransactionslogic.go deleted file mode 100644 index 964f8f7..0000000 --- a/internal/logic/public/iap/apple/restoreappletransactionslogic.go +++ /dev/null @@ -1 +0,0 @@ -package apple diff --git a/internal/server.go b/internal/server.go index 0fa000c..41594d1 100644 --- a/internal/server.go +++ b/internal/server.go @@ -22,7 +22,6 @@ import ( "github.com/perfect-panel/server/internal/handler" "github.com/perfect-panel/server/internal/middleware" "github.com/perfect-panel/server/internal/svc" - "github.com/zeromicro/go-zero/rest" ) type Service struct { @@ -65,10 +64,7 @@ func initServer(svc *svc.ServiceContext) *gin.Engine { ) // register handlers - svc.AuthMiddleware = middleware.AuthMiddleware(svc) - svc.DeviceMiddleware = middleware.DeviceMiddleware(svc) - svc.ServerMiddleware = middleware.ServerMiddleware(svc) - handler.RegisterHandlers(rest.NewGinServer(r), svc) + handler.RegisterHandlers(r, svc) r.StaticFile("/order-recovery.html", "./public/order-recovery.html") // register subscribe handler handler.RegisterSubscribeHandlers(r, svc) diff --git a/internal/svc/serviceContext.go b/internal/svc/serviceContext.go index c0de74f..168b626 100644 --- a/internal/svc/serviceContext.go +++ b/internal/svc/serviceContext.go @@ -4,7 +4,6 @@ import ( "context" "time" - "github.com/gin-gonic/gin" "github.com/perfect-panel/server/internal/model/client" "github.com/perfect-panel/server/internal/model/node" "github.com/perfect-panel/server/internal/model/redemption" @@ -77,9 +76,6 @@ type ServiceContext struct { NodeMultiplierManager *nodeMultiplier.Manager AuthLimiter *limit.PeriodLimit DeviceManager *device.DeviceManager - AuthMiddleware func(c *gin.Context) - DeviceMiddleware func(c *gin.Context) - ServerMiddleware func(c *gin.Context) } func NewServiceContext(c config.Config) *ServiceContext { diff --git a/third_party/gozero/go.mod b/third_party/gozero/go.mod deleted file mode 100644 index 4bdaa27..0000000 --- a/third_party/gozero/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/zeromicro/go-zero - -go 1.24 - -require github.com/gin-gonic/gin v1.10.0 diff --git a/third_party/gozero/rest/rest.go b/third_party/gozero/rest/rest.go deleted file mode 100644 index ca3b5d0..0000000 --- a/third_party/gozero/rest/rest.go +++ /dev/null @@ -1,109 +0,0 @@ -package rest - -import ( - "net/http" - "path" - "strings" - - "github.com/gin-gonic/gin" -) - -type Middleware = gin.HandlerFunc - -type Route struct { - Method string - Path string - Handler gin.HandlerFunc -} - -type Server struct { - router *gin.Engine -} - -type routeOptions struct { - prefix string - middleware []Middleware -} - -type RouteOption func(*routeOptions) - -func NewGinServer(router *gin.Engine) *Server { - return &Server{router: router} -} - -func WithMiddlewares(middlewares []Middleware, routes ...Route) []Route { - for i := range routes { - routes[i].Handler = chain(middlewares, routes[i].Handler) - } - return routes -} - -func WithPrefix(prefix string) RouteOption { - return func(options *routeOptions) { - options.prefix = prefix - } -} - -func WithJwt(_ string) RouteOption { - return func(*routeOptions) {} -} - -func WithJwtTransition(_, _ string) RouteOption { - return func(*routeOptions) {} -} - -func WithSignature(_ any) RouteOption { - return func(*routeOptions) {} -} - -func WithSSE() RouteOption { - return func(*routeOptions) {} -} - -func WithMaxBytes(_ int64) RouteOption { - return func(*routeOptions) {} -} - -func WithTimeout(_ any) RouteOption { - return func(*routeOptions) {} -} - -func (s *Server) AddRoutes(routes []Route, opts ...RouteOption) { - options := routeOptions{} - for _, opt := range opts { - opt(&options) - } - for _, route := range routes { - s.router.Handle(route.Method, joinPath(options.prefix, route.Path), chain(options.middleware, route.Handler)) - } -} - -func chain(middlewares []Middleware, handler gin.HandlerFunc) gin.HandlerFunc { - if len(middlewares) == 0 { - return handler - } - return func(c *gin.Context) { - for _, middleware := range middlewares { - middleware(c) - if c.IsAborted() { - return - } - } - handler(c) - } -} - -func joinPath(prefix, routePath string) string { - if prefix == "" { - return routePath - } - joined := path.Join("/", prefix, routePath) - if strings.HasSuffix(routePath, "/") && !strings.HasSuffix(joined, "/") { - joined += "/" - } - return joined -} - -var ( - _ http.Handler -)