From fefbd4f56a10b374e6401adc3b1ed773c101b41e Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Wed, 27 May 2026 23:54:26 -0700 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D(#104):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20goctl=20=E9=87=8D=E6=96=B0=E7=94=9F=E6=88=90=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=BC=82=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: multica-agent --- apis/admin/invite.api | 50 + apis/admin/subscribe.api | 3 +- apis/admin/user.api | 44 + apis/node/node.api | 5 +- apis/types.api | 38 +- go.mod | 3 + .../handler/common/checkCodeLegacyAlias.go | 52 + .../handler/common/checkcodelegacyhandler.go | 1 + .../common/checkcodelegacyv2handler.go | 1 + .../handler/common/logMessageReportHandler.go | 34 +- .../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 | 3537 +++++++++++------ 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 + internal/types/types.go | 534 ++- ppanel.api | 2 + third_party/gozero/go.mod | 5 + third_party/gozero/rest/rest.go | 109 + 43 files changed, 3001 insertions(+), 1513 deletions(-) create mode 100644 apis/admin/invite.api create mode 100644 internal/handler/common/checkCodeLegacyAlias.go create mode 100644 internal/handler/common/checkcodelegacyhandler.go create mode 100644 internal/handler/common/checkcodelegacyv2handler.go create mode 100644 internal/handler/common/reportlogmessagehandler.go create mode 100644 internal/handler/common/submitcontacthandler.go create mode 100644 internal/handler/node/server/getserverconfighandler.go create mode 100644 internal/handler/node/server/getserveruserlisthandler.go create mode 100644 internal/handler/node/server/pushonlineusershandler.go create mode 100644 internal/handler/node/server/queryserverprotocolconfighandler.go create mode 100644 internal/handler/node/server/serverpushstatushandler.go create mode 100644 internal/handler/node/server/serverpushusertraffichandler.go create mode 100644 internal/handler/public/iap/apple/attachappletransactionbyidhandler.go create mode 100644 internal/handler/public/iap/apple/attachappletransactionhandler.go create mode 100644 internal/handler/public/iap/apple/getapplestatushandler.go create mode 100644 internal/handler/public/iap/apple/restoreappletransactionshandler.go create mode 100644 internal/logic/common/checkcodelegacylogic.go create mode 100644 internal/logic/common/checkcodelegacyv2logic.go create mode 100644 internal/logic/common/reportlogmessagelogic.go create mode 100644 internal/logic/common/submitcontactlogic.go create mode 100644 internal/logic/node/server/getserverconfiglogic.go create mode 100644 internal/logic/node/server/getserveruserlistlogic.go create mode 100644 internal/logic/node/server/pushonlineuserslogic.go create mode 100644 internal/logic/node/server/queryserverprotocolconfiglogic.go create mode 100644 internal/logic/node/server/serverpushstatuslogic.go create mode 100644 internal/logic/node/server/serverpushusertrafficlogic.go create mode 100644 internal/logic/public/iap/apple/attachappletransactionbyidlogic.go create mode 100644 internal/logic/public/iap/apple/attachappletransactionlogic.go create mode 100644 internal/logic/public/iap/apple/getapplestatuslogic.go create mode 100644 internal/logic/public/iap/apple/restoreappletransactionslogic.go create mode 100644 third_party/gozero/go.mod create mode 100644 third_party/gozero/rest/rest.go diff --git a/apis/admin/invite.api b/apis/admin/invite.api new file mode 100644 index 0000000..3fda0ad --- /dev/null +++ b/apis/admin/invite.api @@ -0,0 +1,50 @@ +syntax = "v1" + +info ( + title: "Invite API" + desc: "API for ppanel" + author: "Tension" + email: "tension@ppanel.com" + version: "0.0.1" +) + +import "../types.api" + +type ( + GetInviteManageListRequest { + Page int `form:"page"` + Size int `form:"size"` + Search string `form:"search"` + InviterId int64 `form:"inviter_id"` + InviteeId int64 `form:"invitee_id"` + } + InviteManageRecord { + InviterId int64 `json:"inviter_id"` + InviterIdentifier string `json:"inviter_identifier"` + InviteeId int64 `json:"invitee_id"` + InviteeIdentifier string `json:"invitee_identifier"` + InviteeAvatar string `json:"invitee_avatar"` + InviteeEnable bool `json:"invitee_enable"` + InvitedAt int64 `json:"invited_at"` + OrderCount int64 `json:"order_count"` + HasPurchased bool `json:"has_purchased"` + InviterCommission int64 `json:"inviter_commission"` + InviterGiftDays int64 `json:"inviter_gift_days"` + InviteeGiftDays int64 `json:"invitee_gift_days"` + } + GetInviteManageListResponse { + Total int64 `json:"total"` + List []InviteManageRecord `json:"list"` + } +) + +@server ( + prefix: v1/admin/invite + group: admin/invite + middleware: AuthMiddleware +) +service ppanel { + @doc "Get invite manage list" + @handler GetInviteManageList + get /list (GetInviteManageListRequest) returns (GetInviteManageListResponse) +} diff --git a/apis/admin/subscribe.api b/apis/admin/subscribe.api index 8a662b8..19c9dc3 100644 --- a/apis/admin/subscribe.api +++ b/apis/admin/subscribe.api @@ -46,6 +46,7 @@ type ( SpeedLimit int64 `json:"speed_limit"` DeviceLimit int64 `json:"device_limit"` Quota int64 `json:"quota"` + NewUserOnly *bool `json:"new_user_only"` Nodes []int64 `json:"nodes"` NodeTags []string `json:"node_tags"` NodeGroupIds []int64 `json:"node_group_ids,omitempty"` @@ -74,6 +75,7 @@ type ( SpeedLimit int64 `json:"speed_limit"` DeviceLimit int64 `json:"device_limit"` Quota int64 `json:"quota"` + NewUserOnly *bool `json:"new_user_only"` Nodes []int64 `json:"nodes"` NodeTags []string `json:"node_tags"` NodeGroupIds []int64 `json:"node_group_ids,omitempty"` @@ -175,4 +177,3 @@ service ppanel { @handler ResetAllSubscribeToken post /reset_all_token returns (ResetAllSubscribeTokenResponse) } - diff --git a/apis/admin/user.api b/apis/admin/user.api index 7bf6e87..d95d791 100644 --- a/apis/admin/user.api +++ b/apis/admin/user.api @@ -23,10 +23,12 @@ type ( SubscribeId *int64 `form:"subscribe_id,omitempty"` UserSubscribeId *int64 `form:"user_subscribe_id,omitempty"` ShortCode string `form:"short_code,omitempty"` + DeviceId *int64 `form:"device_id,omitempty"` FamilyJoined *bool `form:"family_joined,omitempty"` FamilyStatus string `form:"family_status,omitempty"` FamilyOwnerUserId *int64 `form:"family_owner_user_id,omitempty"` FamilyId *int64 `form:"family_id,omitempty"` + SortOrder string `form:"sort_order,omitempty"` } // GetUserListResponse GetUserListResponse { @@ -229,6 +231,40 @@ type ( WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"` Reason string `json:"reason" validate:"required,max=500"` } + GetAdminUserInviteStatsRequest { + UserId int64 `form:"user_id" validate:"required"` + } + GetAdminUserInviteStatsResponse { + InviteCount int64 `json:"invite_count"` + TotalCommission int64 `json:"total_commission"` + CurrentCommission int64 `json:"current_commission"` + ReferralPercentage uint8 `json:"referral_percentage"` + OnlyFirstPurchase bool `json:"only_first_purchase"` + } + GetAdminUserInviteListRequest { + UserId int64 `form:"user_id" validate:"required"` + Page int `form:"page"` + Size int `form:"size"` + Search string `form:"search"` + Enable *int `form:"enable"` + UserIdSearch int64 `form:"user_id_search"` + } + AdminInvitedUser { + Id int64 `json:"id"` + Avatar string `json:"avatar"` + Identifier string `json:"identifier"` + Enable bool `json:"enable"` + CreatedAt int64 `json:"created_at"` + OrderCount int64 `json:"order_count"` + HasPurchased bool `json:"has_purchased"` + InviterCommission int64 `json:"inviter_commission"` + InviterGiftDays int64 `json:"inviter_gift_days"` + InviteeGiftDays int64 `json:"invitee_gift_days"` + } + GetAdminUserInviteListResponse { + Total int64 `json:"total"` + List []AdminInvitedUser `json:"list"` + } ) @server ( @@ -381,4 +417,12 @@ service ppanel { @doc "Reject withdrawal" @handler RejectWithdrawal post /withdrawal/reject (RejectWithdrawalRequest) + + @doc "Get admin user invite stats" + @handler GetAdminUserInviteStats + get /invite/stats (GetAdminUserInviteStatsRequest) returns (GetAdminUserInviteStatsResponse) + + @doc "Get admin user invite list" + @handler GetAdminUserInviteList + get /invite/list (GetAdminUserInviteListRequest) returns (GetAdminUserInviteListResponse) } diff --git a/apis/node/node.api b/apis/node/node.api index 8dee713..9313aca 100644 --- a/apis/node/node.api +++ b/apis/node/node.api @@ -111,7 +111,7 @@ type ( @server ( prefix: v1/server - group: server + group: node/server middleware: ServerMiddleware ) service ppanel { @@ -138,11 +138,10 @@ service ppanel { @server ( prefix: v2/server - group: server + group: node/server ) service ppanel { @doc "Get Server Protocol Config" @handler QueryServerProtocolConfig get /:server_id (QueryServerConfigRequest) returns (QueryServerConfigResponse) } - diff --git a/apis/types.api b/apis/types.api index 1c9638a..c80fb52 100644 --- a/apis/types.api +++ b/apis/types.api @@ -160,15 +160,17 @@ type ( OnlyRealDevice bool `json:"only_real_device"` } RegisterConfig { - StopRegister bool `json:"stop_register"` - EnableTrial bool `json:"enable_trial"` - TrialSubscribe int64 `json:"trial_subscribe"` - TrialTime int64 `json:"trial_time"` - TrialTimeUnit string `json:"trial_time_unit"` - EnableIpRegisterLimit bool `json:"enable_ip_register_limit"` - IpRegisterLimit int64 `json:"ip_register_limit"` - IpRegisterLimitDuration int64 `json:"ip_register_limit_duration"` - DeviceLimit int64 `json:"device_limit"` + StopRegister bool `json:"stop_register"` + EnableTrial bool `json:"enable_trial"` + EnableTrialEmailWhitelist bool `json:"enable_trial_email_whitelist"` + TrialSubscribe int64 `json:"trial_subscribe"` + TrialTime int64 `json:"trial_time"` + TrialTimeUnit string `json:"trial_time_unit"` + TrialEmailDomainWhitelist string `json:"trial_email_domain_whitelist"` + EnableIpRegisterLimit bool `json:"enable_ip_register_limit"` + IpRegisterLimit int64 `json:"ip_register_limit"` + IpRegisterLimitDuration int64 `json:"ip_register_limit_duration"` + DeviceLimit int64 `json:"device_limit"` } VerifyConfig { CaptchaType string `json:"captcha_type"` // local or turnstile @@ -226,10 +228,11 @@ type ( CurrencySymbol string `json:"currency_symbol"` } SubscribeDiscount { - Quantity int64 `json:"quantity"` - Discount float64 `json:"discount"` - MapApple string `json:"map_apple"` - Promo *SubscribePromo `json:"promo"` + Quantity int64 `json:"quantity"` + Discount float64 `json:"discount"` + NewUserOnly bool `json:"new_user_only"` + MapApple string `json:"map_apple"` + Promo *SubscribePromo `json:"promo"` } PromoPrice { Id int64 `json:"id"` @@ -293,6 +296,7 @@ type ( SpeedLimit int64 `json:"speed_limit"` DeviceLimit int64 `json:"device_limit"` Quota int64 `json:"quota"` + NewUserOnly bool `json:"new_user_only"` Nodes []int64 `json:"nodes"` NodeTags []string `json:"node_tags"` NodeGroupIds []int64 `json:"node_group_ids,omitempty"` @@ -557,10 +561,13 @@ type ( } UserSubscribe { Id int64 `json:"id"` + IdStr string `json:"id_str"` UserId int64 `json:"user_id"` OrderId int64 `json:"order_id"` SubscribeId int64 `json:"subscribe_id"` Subscribe Subscribe `json:"subscribe"` + NodeGroupId int64 `json:"node_group_id"` + NodeGroupName string `json:"node_group_name"` StartTime int64 `json:"start_time"` ExpireTime int64 `json:"expire_time"` FinishedAt int64 `json:"finished_at"` @@ -906,8 +913,9 @@ type ( Sandbox *bool `json:"sandbox,omitempty"` } AttachAppleTransactionResponse { - ExpiresAt int64 `json:"expires_at"` - Tier string `json:"tier"` + ExpiresAt int64 `json:"expires_at"` + Tier string `json:"tier"` + ExistingOrderNo string `json:"existing_order_no,omitempty"` } RestoreAppleTransactionsRequest { Transactions []string `json:"transactions" validate:"required"` diff --git a/go.mod b/go.mod index 3dda44b..3138e95 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ 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 @@ -52,6 +53,8 @@ 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 new file mode 100644 index 0000000..4b6392c --- /dev/null +++ b/internal/handler/common/checkCodeLegacyAlias.go @@ -0,0 +1,52 @@ +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 new file mode 100644 index 0000000..805d0c7 --- /dev/null +++ b/internal/handler/common/checkcodelegacyhandler.go @@ -0,0 +1 @@ +package common diff --git a/internal/handler/common/checkcodelegacyv2handler.go b/internal/handler/common/checkcodelegacyv2handler.go new file mode 100644 index 0000000..805d0c7 --- /dev/null +++ b/internal/handler/common/checkcodelegacyv2handler.go @@ -0,0 +1 @@ +package common diff --git a/internal/handler/common/logMessageReportHandler.go b/internal/handler/common/logMessageReportHandler.go index c514676..942c1b1 100644 --- a/internal/handler/common/logMessageReportHandler.go +++ b/internal/handler/common/logMessageReportHandler.go @@ -1,24 +1,24 @@ package common import ( - "github.com/gin-gonic/gin" - "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/result" + "github.com/gin-gonic/gin" + "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/result" ) func ReportLogMessageHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) { - return func(c *gin.Context) { - var req types.ReportLogMessageRequest - _ = c.ShouldBind(&req) - validateErr := svcCtx.Validate(&req) - if validateErr != nil { - result.ParamErrorResult(c, validateErr) - return - } - l := common.NewReportLogMessageLogic(c.Request.Context(), svcCtx) - resp, err := l.ReportLogMessage(&req, c) - result.HttpResult(c, resp, err) - } + return func(c *gin.Context) { + var req types.ReportLogMessageRequest + _ = c.ShouldBind(&req) + validateErr := svcCtx.Validate(&req) + if validateErr != nil { + result.ParamErrorResult(c, validateErr) + return + } + l := common.NewReportLogMessageLogic(c.Request.Context(), svcCtx) + resp, err := l.ReportLogMessage(&req, c) + result.HttpResult(c, resp, err) + } } diff --git a/internal/handler/common/reportlogmessagehandler.go b/internal/handler/common/reportlogmessagehandler.go new file mode 100644 index 0000000..805d0c7 --- /dev/null +++ b/internal/handler/common/reportlogmessagehandler.go @@ -0,0 +1 @@ +package common diff --git a/internal/handler/common/submitcontacthandler.go b/internal/handler/common/submitcontacthandler.go new file mode 100644 index 0000000..805d0c7 --- /dev/null +++ b/internal/handler/common/submitcontacthandler.go @@ -0,0 +1 @@ +package common diff --git a/internal/handler/node/server/getserverconfighandler.go b/internal/handler/node/server/getserverconfighandler.go new file mode 100644 index 0000000..40cc18e --- /dev/null +++ b/internal/handler/node/server/getserverconfighandler.go @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..08270d0 --- /dev/null +++ b/internal/handler/node/server/getserveruserlisthandler.go @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..a88a87c --- /dev/null +++ b/internal/handler/node/server/pushonlineusershandler.go @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..259544a --- /dev/null +++ b/internal/handler/node/server/queryserverprotocolconfighandler.go @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..5c0e5ea --- /dev/null +++ b/internal/handler/node/server/serverpushstatushandler.go @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..bd8dd25 --- /dev/null +++ b/internal/handler/node/server/serverpushusertraffichandler.go @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..964f8f7 --- /dev/null +++ b/internal/handler/public/iap/apple/attachappletransactionbyidhandler.go @@ -0,0 +1 @@ +package apple diff --git a/internal/handler/public/iap/apple/attachappletransactionhandler.go b/internal/handler/public/iap/apple/attachappletransactionhandler.go new file mode 100644 index 0000000..964f8f7 --- /dev/null +++ b/internal/handler/public/iap/apple/attachappletransactionhandler.go @@ -0,0 +1 @@ +package apple diff --git a/internal/handler/public/iap/apple/getapplestatushandler.go b/internal/handler/public/iap/apple/getapplestatushandler.go new file mode 100644 index 0000000..964f8f7 --- /dev/null +++ b/internal/handler/public/iap/apple/getapplestatushandler.go @@ -0,0 +1 @@ +package apple diff --git a/internal/handler/public/iap/apple/restoreappletransactionshandler.go b/internal/handler/public/iap/apple/restoreappletransactionshandler.go new file mode 100644 index 0000000..964f8f7 --- /dev/null +++ b/internal/handler/public/iap/apple/restoreappletransactionshandler.go @@ -0,0 +1 @@ +package apple diff --git a/internal/handler/routes.go b/internal/handler/routes.go index 85225d0..148dc56 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -1,1217 +1,2342 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.7.2 +// goctl 1.9.2 package handler import ( - "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" + "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" 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" - 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" + 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" "github.com/perfect-panel/server/internal/svc" + + "github.com/zeromicro/go-zero/rest" ) -func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) { - adminAdsGroupRouter := router.Group("/v1/admin/ads") - adminAdsGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - - { - // Create Ads - adminAdsGroupRouter.POST("/", adminAds.CreateAdsHandler(serverCtx)) - - // Update Ads - adminAdsGroupRouter.PUT("/", adminAds.UpdateAdsHandler(serverCtx)) - - // Delete Ads - adminAdsGroupRouter.DELETE("/", adminAds.DeleteAdsHandler(serverCtx)) - - // Get Ads Detail - adminAdsGroupRouter.GET("/detail", adminAds.GetAdsDetailHandler(serverCtx)) - - // Get Ads List - adminAdsGroupRouter.GET("/list", adminAds.GetAdsListHandler(serverCtx)) - } - - adminAnnouncementGroupRouter := router.Group("/v1/admin/announcement") - adminAnnouncementGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - - { - // Create announcement - adminAnnouncementGroupRouter.POST("/", adminAnnouncement.CreateAnnouncementHandler(serverCtx)) - - // Update announcement - adminAnnouncementGroupRouter.PUT("/", adminAnnouncement.UpdateAnnouncementHandler(serverCtx)) - - // Delete announcement - adminAnnouncementGroupRouter.DELETE("/", adminAnnouncement.DeleteAnnouncementHandler(serverCtx)) - - // Get announcement - adminAnnouncementGroupRouter.GET("/detail", adminAnnouncement.GetAnnouncementHandler(serverCtx)) - - // Get announcement list - adminAnnouncementGroupRouter.GET("/list", adminAnnouncement.GetAnnouncementListHandler(serverCtx)) - } - - adminApplicationGroupRouter := router.Group("/v1/admin/application") - adminApplicationGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - - { - // Create subscribe application - adminApplicationGroupRouter.POST("/", adminApplication.CreateSubscribeApplicationHandler(serverCtx)) - - // Preview Template - adminApplicationGroupRouter.GET("/preview", adminApplication.PreviewSubscribeTemplateHandler(serverCtx)) - - // Update subscribe application - adminApplicationGroupRouter.PUT("/subscribe_application", adminApplication.UpdateSubscribeApplicationHandler(serverCtx)) - - // Delete subscribe application - adminApplicationGroupRouter.DELETE("/subscribe_application", adminApplication.DeleteSubscribeApplicationHandler(serverCtx)) - - // Get subscribe application list - adminApplicationGroupRouter.GET("/subscribe_application_list", adminApplication.GetSubscribeApplicationListHandler(serverCtx)) - } - - adminAuthMethodGroupRouter := router.Group("/v1/admin/auth-method") - adminAuthMethodGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - - { - // Get auth method config - adminAuthMethodGroupRouter.GET("/config", adminAuthMethod.GetAuthMethodConfigHandler(serverCtx)) - - // Update auth method config - adminAuthMethodGroupRouter.PUT("/config", adminAuthMethod.UpdateAuthMethodConfigHandler(serverCtx)) - - // Get email support platform - adminAuthMethodGroupRouter.GET("/email_platform", adminAuthMethod.GetEmailPlatformHandler(serverCtx)) - - // Get auth method list - adminAuthMethodGroupRouter.GET("/list", adminAuthMethod.GetAuthMethodListHandler(serverCtx)) - - // Get sms support platform - adminAuthMethodGroupRouter.GET("/sms_platform", adminAuthMethod.GetSmsPlatformHandler(serverCtx)) - - // Test email send - adminAuthMethodGroupRouter.POST("/test_email_send", adminAuthMethod.TestEmailSendHandler(serverCtx)) - - // Test sms send - adminAuthMethodGroupRouter.POST("/test_sms_send", adminAuthMethod.TestSmsSendHandler(serverCtx)) - } - - adminConsoleGroupRouter := router.Group("/v1/admin/console") - adminConsoleGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - - { - // Query revenue statistics - adminConsoleGroupRouter.GET("/revenue", adminConsole.QueryRevenueStatisticsHandler(serverCtx)) - - // Query server total data - adminConsoleGroupRouter.GET("/server", adminConsole.QueryServerTotalDataHandler(serverCtx)) - - // Query ticket wait reply - adminConsoleGroupRouter.GET("/ticket", adminConsole.QueryTicketWaitReplyHandler(serverCtx)) - - // Query user statistics - adminConsoleGroupRouter.GET("/user", adminConsole.QueryUserStatisticsHandler(serverCtx)) - } - - adminCouponGroupRouter := router.Group("/v1/admin/coupon") - adminCouponGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - - { - // Create coupon - adminCouponGroupRouter.POST("/", adminCoupon.CreateCouponHandler(serverCtx)) - - // Update coupon - adminCouponGroupRouter.PUT("/", adminCoupon.UpdateCouponHandler(serverCtx)) - - // Delete coupon - adminCouponGroupRouter.DELETE("/", adminCoupon.DeleteCouponHandler(serverCtx)) - - // Batch delete coupon - adminCouponGroupRouter.DELETE("/batch", adminCoupon.BatchDeleteCouponHandler(serverCtx)) - - // Get coupon list - adminCouponGroupRouter.GET("/list", adminCoupon.GetCouponListHandler(serverCtx)) - } - - adminDocumentGroupRouter := router.Group("/v1/admin/document") - adminDocumentGroupRouter.Use(middleware.AuthMiddleware(serverCtx)) - - { - // Create document - adminDocumentGroupRouter.POST("/", adminDocument.CreateDocumentHandler(serverCtx)) - - // 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 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)) - } +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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + server.AddRoutes( + []rest.Route{ + { + // Get Server Protocol Config + Method: http.MethodGet, + Path: "/:server_id", + Handler: nodeserver.QueryServerProtocolConfigHandler(serverCtx), + }, + }, + rest.WithPrefix("/v2/server"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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"), + ) + + 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 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"), + ) + + 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"), + ) } diff --git a/internal/logic/common/checkcodelegacylogic.go b/internal/logic/common/checkcodelegacylogic.go new file mode 100644 index 0000000..805d0c7 --- /dev/null +++ b/internal/logic/common/checkcodelegacylogic.go @@ -0,0 +1 @@ +package common diff --git a/internal/logic/common/checkcodelegacyv2logic.go b/internal/logic/common/checkcodelegacyv2logic.go new file mode 100644 index 0000000..805d0c7 --- /dev/null +++ b/internal/logic/common/checkcodelegacyv2logic.go @@ -0,0 +1 @@ +package common diff --git a/internal/logic/common/reportlogmessagelogic.go b/internal/logic/common/reportlogmessagelogic.go new file mode 100644 index 0000000..805d0c7 --- /dev/null +++ b/internal/logic/common/reportlogmessagelogic.go @@ -0,0 +1 @@ +package common diff --git a/internal/logic/common/submitcontactlogic.go b/internal/logic/common/submitcontactlogic.go new file mode 100644 index 0000000..805d0c7 --- /dev/null +++ b/internal/logic/common/submitcontactlogic.go @@ -0,0 +1 @@ +package common diff --git a/internal/logic/node/server/getserverconfiglogic.go b/internal/logic/node/server/getserverconfiglogic.go new file mode 100644 index 0000000..abb4e43 --- /dev/null +++ b/internal/logic/node/server/getserverconfiglogic.go @@ -0,0 +1 @@ +package server diff --git a/internal/logic/node/server/getserveruserlistlogic.go b/internal/logic/node/server/getserveruserlistlogic.go new file mode 100644 index 0000000..abb4e43 --- /dev/null +++ b/internal/logic/node/server/getserveruserlistlogic.go @@ -0,0 +1 @@ +package server diff --git a/internal/logic/node/server/pushonlineuserslogic.go b/internal/logic/node/server/pushonlineuserslogic.go new file mode 100644 index 0000000..abb4e43 --- /dev/null +++ b/internal/logic/node/server/pushonlineuserslogic.go @@ -0,0 +1 @@ +package server diff --git a/internal/logic/node/server/queryserverprotocolconfiglogic.go b/internal/logic/node/server/queryserverprotocolconfiglogic.go new file mode 100644 index 0000000..abb4e43 --- /dev/null +++ b/internal/logic/node/server/queryserverprotocolconfiglogic.go @@ -0,0 +1 @@ +package server diff --git a/internal/logic/node/server/serverpushstatuslogic.go b/internal/logic/node/server/serverpushstatuslogic.go new file mode 100644 index 0000000..abb4e43 --- /dev/null +++ b/internal/logic/node/server/serverpushstatuslogic.go @@ -0,0 +1 @@ +package server diff --git a/internal/logic/node/server/serverpushusertrafficlogic.go b/internal/logic/node/server/serverpushusertrafficlogic.go new file mode 100644 index 0000000..abb4e43 --- /dev/null +++ b/internal/logic/node/server/serverpushusertrafficlogic.go @@ -0,0 +1 @@ +package server diff --git a/internal/logic/public/iap/apple/attachappletransactionbyidlogic.go b/internal/logic/public/iap/apple/attachappletransactionbyidlogic.go new file mode 100644 index 0000000..964f8f7 --- /dev/null +++ b/internal/logic/public/iap/apple/attachappletransactionbyidlogic.go @@ -0,0 +1 @@ +package apple diff --git a/internal/logic/public/iap/apple/attachappletransactionlogic.go b/internal/logic/public/iap/apple/attachappletransactionlogic.go new file mode 100644 index 0000000..964f8f7 --- /dev/null +++ b/internal/logic/public/iap/apple/attachappletransactionlogic.go @@ -0,0 +1 @@ +package apple diff --git a/internal/logic/public/iap/apple/getapplestatuslogic.go b/internal/logic/public/iap/apple/getapplestatuslogic.go new file mode 100644 index 0000000..964f8f7 --- /dev/null +++ b/internal/logic/public/iap/apple/getapplestatuslogic.go @@ -0,0 +1 @@ +package apple diff --git a/internal/logic/public/iap/apple/restoreappletransactionslogic.go b/internal/logic/public/iap/apple/restoreappletransactionslogic.go new file mode 100644 index 0000000..964f8f7 --- /dev/null +++ b/internal/logic/public/iap/apple/restoreappletransactionslogic.go @@ -0,0 +1 @@ +package apple diff --git a/internal/server.go b/internal/server.go index 41594d1..0fa000c 100644 --- a/internal/server.go +++ b/internal/server.go @@ -22,6 +22,7 @@ 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 { @@ -64,7 +65,10 @@ func initServer(svc *svc.ServiceContext) *gin.Engine { ) // register handlers - handler.RegisterHandlers(r, svc) + svc.AuthMiddleware = middleware.AuthMiddleware(svc) + svc.DeviceMiddleware = middleware.DeviceMiddleware(svc) + svc.ServerMiddleware = middleware.ServerMiddleware(svc) + handler.RegisterHandlers(rest.NewGinServer(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 168b626..c0de74f 100644 --- a/internal/svc/serviceContext.go +++ b/internal/svc/serviceContext.go @@ -4,6 +4,7 @@ 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" @@ -76,6 +77,9 @@ 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/internal/types/types.go b/internal/types/types.go index e2e65df..5e399a7 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -3,15 +3,21 @@ package types -import "encoding/json" - type ActivateOrderRequest struct { OrderNo string `json:"order_no" validate:"required"` } -type RefundOrderRequest struct { - Id int64 `json:"id" validate:"required"` - Reason string `json:"reason,omitempty" validate:"omitempty,max=500"` +type AdminInvitedUser struct { + Id int64 `json:"id"` + Avatar string `json:"avatar"` + Identifier string `json:"identifier"` + Enable bool `json:"enable"` + CreatedAt int64 `json:"created_at"` + OrderCount int64 `json:"order_count"` + HasPurchased bool `json:"has_purchased"` + InviterCommission int64 `json:"inviter_commission"` + InviterGiftDays int64 `json:"inviter_gift_days"` + InviteeGiftDays int64 `json:"invitee_gift_days"` } type Ads struct { @@ -126,6 +132,10 @@ type ApplicationVersion struct { IsDefault bool `json:"is_default"` } +type ApproveWithdrawalRequest struct { + WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"` +} + type AttachAppleTransactionByIdRequest struct { OrderNo string `json:"order_no" validate:"required"` TransactionId string `json:"transaction_id" validate:"required"` @@ -251,6 +261,10 @@ type BindTelegramResponse struct { ExpiredAt int64 `json:"expired_at"` } +type CancelWithdrawalRequest struct { + WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"` +} + type CheckUserRequest struct { Email string `form:"email" validate:"required"` } @@ -316,45 +330,6 @@ type ContactRequest struct { Notes string `json:"notes" validate:"max=2000"` } -type PromoPrice struct { - Id int64 `json:"id"` - SubscribeId int64 `json:"subscribe_id"` - PromoRuleId int64 `json:"promo_rule_id"` - Quantity int64 `json:"quantity"` - PromoPrice int64 `json:"promo_price"` - CreatedAt int64 `json:"created_at"` - UpdatedAt int64 `json:"updated_at"` -} - -type PromoPriceItem struct { - SubscribeId int64 `json:"subscribe_id" validate:"required,gt=0"` - Quantity int64 `json:"quantity" validate:"required,gt=0,lte=1000"` - PromoPrice int64 `json:"promo_price" validate:"required,gt=0"` -} - -type PromoRule struct { - Id int64 `json:"id"` - Name string `json:"name"` - Type string `json:"type"` - Params map[string]interface{} `json:"params"` - Priority int64 `json:"priority"` - Enabled bool `json:"enabled"` - StartTime *int64 `json:"start_time"` - EndTime *int64 `json:"end_time"` - CreatedAt int64 `json:"created_at"` - UpdatedAt int64 `json:"updated_at"` -} - -type PromoUsage struct { - Id int64 `json:"id"` - UserId int64 `json:"user_id"` - PromoRuleId int64 `json:"promo_rule_id"` - SubscribeId int64 `json:"subscribe_id"` - OrderNo string `json:"order_no"` - PromoPrice int64 `json:"promo_price"` - CreatedAt int64 `json:"created_at"` -} - type Coupon struct { Id int64 `json:"id"` Name string `json:"name"` @@ -414,16 +389,6 @@ type CreateCouponRequest struct { Enable *bool `json:"enable,omitempty"` } -type CreatePromoRuleRequest struct { - Name string `json:"name" validate:"required,max=100"` - Type string `json:"type" validate:"required,oneof=new_user inactive_user campaign"` - Params map[string]interface{} `json:"params"` - Priority int64 `json:"priority" validate:"gte=0"` - Enabled *bool `json:"enabled"` - StartTime *int64 `json:"start_time"` - EndTime *int64 `json:"end_time"` -} - type CreateDocumentRequest struct { Title string `json:"title" validate:"required"` Content string `json:"content" validate:"required"` @@ -485,6 +450,16 @@ type CreatePaymentMethodRequest struct { Enable *bool `json:"enable" validate:"required"` } +type CreatePromoRuleRequest struct { + Name string `json:"name" validate:"required,max=100"` + Type string `json:"type" validate:"required,oneof=new_user inactive_user campaign"` + Params map[string]interface{} `json:"params"` + Priority int64 `json:"priority" validate:"gte=0"` + Enabled *bool `json:"enabled"` + StartTime *int64 `json:"start_time"` + EndTime *int64 `json:"end_time"` +} + type CreateQuotaTaskRequest struct { Subscribers []int64 `json:"subscribers"` IsActive *bool `json:"is_active"` @@ -668,6 +643,14 @@ type DeletePaymentMethodRequest struct { Id int64 `json:"id" validate:"required"` } +type DeletePromoPriceRequest struct { + Id int64 `uri:"id" validate:"required,gt=0"` +} + +type DeletePromoRuleRequest struct { + Id int64 `uri:"id" validate:"required,gt=0"` +} + type DeleteRedemptionCodeRequest struct { Id int64 `json:"id" validate:"required"` } @@ -823,14 +806,6 @@ type FamilySummary struct { UpdatedAt int64 `json:"updated_at"` } -type FileUploadRequest struct { - BizType string `form:"biz_type" validate:"required"` -} - -type FileUploadResponse struct { - Url string `json:"url"` -} - type FileUploadCompleteRequest struct { FileId string `json:"file_id" validate:"required"` } @@ -856,6 +831,14 @@ type FileUploadInitResponse struct { ExpiredAt int64 `json:"expired_at"` } +type FileUploadRequest struct { + BizType string `form:"biz_type" validate:"required"` +} + +type FileUploadResponse struct { + Url string `json:"url"` +} + type FilterBalanceLogRequest struct { FilterLogParams UserId int64 `form:"user_id,optional"` @@ -876,17 +859,6 @@ type FilterCommissionLogResponse struct { List []CommissionLog `json:"list"` } -type FilterOrderRefundLogRequest struct { - FilterLogParams - OrderId int64 `form:"order_id,optional"` - UserId int64 `form:"user_id,optional"` -} - -type FilterOrderRefundLogResponse struct { - Total int64 `json:"total"` - List []OrderRefundLog `json:"list"` -} - type FilterEmailLogResponse struct { Total int64 `json:"total"` List []MessageLog `json:"list"` @@ -936,6 +908,17 @@ type FilterNodeListResponse struct { List []Node `json:"list"` } +type FilterOrderRefundLogRequest struct { + FilterLogParams + OrderId int64 `form:"order_id,optional"` + UserId int64 `form:"user_id,optional"` +} + +type FilterOrderRefundLogResponse struct { + Total int64 `json:"total"` + List []OrderRefundLog `json:"list"` +} + type FilterRegisterLogRequest struct { FilterLogParams UserId int64 `form:"user_id,optional"` @@ -1027,6 +1010,32 @@ type GenerateCaptchaResponse struct { BlockImage string `json:"block_image,omitempty"` } +type GetAdminUserInviteListRequest struct { + UserId int64 `form:"user_id" validate:"required"` + Page int `form:"page"` + Size int `form:"size"` + Search string `form:"search"` + Enable *int `form:"enable"` + UserIdSearch int64 `form:"user_id_search"` +} + +type GetAdminUserInviteListResponse struct { + Total int64 `json:"total"` + List []AdminInvitedUser `json:"list"` +} + +type GetAdminUserInviteStatsRequest struct { + UserId int64 `form:"user_id" validate:"required"` +} + +type GetAdminUserInviteStatsResponse struct { + InviteCount int64 `json:"invite_count"` + TotalCommission int64 `json:"total_commission"` + CurrentCommission int64 `json:"current_commission"` + ReferralPercentage uint8 `json:"referral_percentage"` + OnlyFirstPurchase bool `json:"only_first_purchase"` +} + type GetAdsDetailRequest struct { Id int64 `form:"id"` } @@ -1145,48 +1154,6 @@ type GetCouponListResponse struct { List []Coupon `json:"list"` } -type GetPromoPriceListRequest struct { - PromoRuleId int64 `form:"promo_rule_id" validate:"required,gt=0"` - Page int64 `form:"page" validate:"required,gt=0"` - Size int64 `form:"size" validate:"required,gt=0,lte=200"` -} - -type GetPromoPriceListResponse struct { - Total int64 `json:"total"` - List []PromoPrice `json:"list"` -} - -type GetPromoRuleDetailRequest struct { - Id int64 `uri:"id" validate:"required,gt=0"` -} - -type GetPromoRuleListRequest struct { - Page int64 `form:"page" validate:"required,gt=0"` - Size int64 `form:"size" validate:"required,gt=0,lte=200"` - Type string `form:"type" validate:"omitempty,oneof=new_user inactive_user campaign"` - Enabled *bool `form:"enabled"` - Search string `form:"search,omitempty"` -} - -type GetPromoRuleListResponse struct { - Total int64 `json:"total"` - List []PromoRule `json:"list"` -} - -type GetPromoUsageListRequest struct { - Page int64 `form:"page" validate:"required,gt=0"` - Size int64 `form:"size" validate:"required,gt=0,lte=200"` - RuleId int64 `form:"rule_id,omitempty"` - UserId int64 `form:"user_id,omitempty"` - SubscribeId int64 `form:"subscribe_id,omitempty"` - OrderNo string `form:"order_no,omitempty"` -} - -type GetPromoUsageListResponse struct { - Total int64 `json:"total"` - List []PromoUsage `json:"list"` -} - type GetDetailRequest struct { Id int64 `form:"id" validate:"required"` } @@ -1327,6 +1294,19 @@ type GetGroupHistoryResponse struct { List []GroupHistory `json:"list"` } +type GetInviteManageListRequest struct { + Page int `form:"page"` + Size int `form:"size"` + Search string `form:"search"` + InviterId int64 `form:"inviter_id"` + InviteeId int64 `form:"invitee_id"` +} + +type GetInviteManageListResponse struct { + Total int64 `json:"total"` + List []InviteManageRecord `json:"list"` +} + type GetInviteRecordsRequest struct { Page int `form:"page"` Size int `form:"size"` @@ -1339,6 +1319,32 @@ type GetInviteRecordsResponse struct { List []InviteRecord `json:"list"` } +type GetLogMessageRawRequest struct { + Id int64 `form:"id" validate:"required"` +} + +type GetLogMessageRawResponse struct { + Id int64 `json:"id"` + Platform string `json:"platform"` + AppVersion string `json:"app_version"` + OsName string `json:"os_name"` + OsVersion string `json:"os_version"` + DeviceId string `json:"device_id"` + UserId *int64 `json:"user_id"` + SessionId string `json:"session_id"` + Level uint8 `json:"level"` + ErrorCode string `json:"error_code"` + Message string `json:"message"` + Stack string `json:"stack"` + Context interface{} `json:"context"` + ClientIP string `json:"client_ip"` + UserAgent string `json:"user_agent"` + Locale string `json:"locale"` + Digest string `json:"digest"` + OccurredAt int64 `json:"occurred_at"` + CreatedAt int64 `json:"created_at"` +} + type GetLoginLogRequest struct { Page int `form:"page"` Size int `form:"size"` @@ -1417,6 +1423,48 @@ type GetPreSendEmailCountResponse struct { Count int64 `json:"count"` } +type GetPromoPriceListRequest struct { + PromoRuleId int64 `form:"promo_rule_id" validate:"required,gt=0"` + Page int64 `form:"page" validate:"required,gt=0"` + Size int64 `form:"size" validate:"required,gt=0,lte=200"` +} + +type GetPromoPriceListResponse struct { + Total int64 `json:"total"` + List []PromoPrice `json:"list"` +} + +type GetPromoRuleDetailRequest struct { + Id int64 `uri:"id" validate:"required,gt=0"` +} + +type GetPromoRuleListRequest struct { + Page int64 `form:"page" validate:"required,gt=0"` + Size int64 `form:"size" validate:"required,gt=0,lte=200"` + Type string `form:"type" validate:"omitempty,oneof=new_user inactive_user campaign"` + Enabled *bool `form:"enabled"` + Search string `form:"search,omitempty"` +} + +type GetPromoRuleListResponse struct { + Total int64 `json:"total"` + List []PromoRule `json:"list"` +} + +type GetPromoUsageListRequest struct { + Page int64 `form:"page" validate:"required,gt=0"` + Size int64 `form:"size" validate:"required,gt=0,lte=200"` + RuleId int64 `form:"rule_id,omitempty"` + UserId int64 `form:"user_id,omitempty"` + SubscribeId int64 `form:"subscribe_id,omitempty"` + OrderNo string `form:"order_no,omitempty"` +} + +type GetPromoUsageListResponse struct { + Total int64 `json:"total"` + List []PromoUsage `json:"list"` +} + type GetRedemptionCodeListRequest struct { Page int64 `form:"page" validate:"required"` Size int64 `form:"size" validate:"required"` @@ -1708,6 +1756,19 @@ type GetUserTrafficStatsResponse struct { TotalTraffic int64 `json:"total_traffic"` } +type GetWithdrawalListRequest struct { + Page int `form:"page"` + Size int `form:"size"` + UserId *int64 `form:"user_id,omitempty"` + Status *uint8 `form:"status,omitempty"` + Method *uint8 `form:"method,omitempty"` +} + +type GetWithdrawalListResponse struct { + List []WithdrawalLog `json:"list"` + Total int64 `json:"total"` +} + type GiftLog struct { Type uint16 `json:"type"` UserId int64 `json:"user_id"` @@ -1768,6 +1829,21 @@ type InviteConfig struct { GiftDays int64 `json:"gift_days"` } +type InviteManageRecord struct { + InviterId int64 `json:"inviter_id"` + InviterIdentifier string `json:"inviter_identifier"` + InviteeId int64 `json:"invitee_id"` + InviteeIdentifier string `json:"invitee_identifier"` + InviteeAvatar string `json:"invitee_avatar"` + InviteeEnable bool `json:"invitee_enable"` + InvitedAt int64 `json:"invited_at"` + OrderCount int64 `json:"order_count"` + HasPurchased bool `json:"has_purchased"` + InviterCommission int64 `json:"inviter_commission"` + InviterGiftDays int64 `json:"inviter_gift_days"` + InviteeGiftDays int64 `json:"invitee_gift_days"` +} + type InviteRecord struct { Role string `json:"role"` PeerHash string `json:"peer_hash"` @@ -1949,8 +2025,6 @@ type Order struct { Amount int64 `json:"amount"` GiftAmount int64 `json:"gift_amount"` Discount int64 `json:"discount"` - PromoRuleId int64 `json:"promo_rule_id"` - PromoDiscount int64 `json:"promo_discount"` Coupon string `json:"coupon"` CouponDiscount int64 `json:"coupon_discount"` Commission int64 `json:"commission,omitempty"` @@ -1974,8 +2048,6 @@ type OrderDetail struct { Amount int64 `json:"amount"` GiftAmount int64 `json:"gift_amount"` Discount int64 `json:"discount"` - PromoRuleId int64 `json:"promo_rule_id"` - PromoDiscount int64 `json:"promo_discount"` Coupon string `json:"coupon"` CouponDiscount int64 `json:"coupon_discount"` Commission int64 `json:"commission,omitempty"` @@ -2158,6 +2230,45 @@ type PrivacyPolicyConfig struct { PrivacyPolicy string `json:"privacy_policy"` } +type PromoPrice struct { + Id int64 `json:"id"` + SubscribeId int64 `json:"subscribe_id"` + PromoRuleId int64 `json:"promo_rule_id"` + Quantity int64 `json:"quantity"` + PromoPrice int64 `json:"promo_price"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` +} + +type PromoPriceItem struct { + SubscribeId int64 `json:"subscribe_id" validate:"required,gt=0"` + Quantity int64 `json:"quantity" validate:"required,gt=0,lte=1000"` + PromoPrice int64 `json:"promo_price" validate:"required,gt=0"` +} + +type PromoRule struct { + Id int64 `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Params map[string]interface{} `json:"params"` + Priority int64 `json:"priority"` + Enabled bool `json:"enabled"` + StartTime *int64 `json:"start_time"` + EndTime *int64 `json:"end_time"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` +} + +type PromoUsage struct { + Id int64 `json:"id"` + UserId int64 `json:"user_id"` + PromoRuleId int64 `json:"promo_rule_id"` + SubscribeId int64 `json:"subscribe_id"` + OrderNo string `json:"order_no"` + PromoPrice int64 `json:"promo_price"` + CreatedAt int64 `json:"created_at"` +} + type Protocol struct { Type string `json:"type"` Port uint16 `json:"port"` @@ -2406,10 +2517,6 @@ type QueryUserSubscribeNodeListResponse struct { List []UserSubscribeInfo `json:"list"` } -type CancelWithdrawalRequest struct { - WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"` -} - type QueryWithdrawalLogListRequest struct { Page int `form:"page"` Size int `form:"size"` @@ -2420,28 +2527,6 @@ type QueryWithdrawalLogListResponse struct { Total int64 `json:"total"` } -type GetWithdrawalListRequest struct { - Page int `form:"page"` - Size int `form:"size"` - UserId *int64 `form:"user_id,omitempty"` - Status *uint8 `form:"status,omitempty"` - Method *uint8 `form:"method,omitempty"` -} - -type GetWithdrawalListResponse struct { - List []WithdrawalLog `json:"list"` - Total int64 `json:"total"` -} - -type ApproveWithdrawalRequest struct { - WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"` -} - -type RejectWithdrawalRequest struct { - WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"` - Reason string `json:"reason" validate:"required,max=500"` -} - type QuotaTask struct { Id int64 `json:"id"` Subscribers []int64 `json:"subscribers"` @@ -2528,6 +2613,11 @@ type RedemptionRecord struct { CreatedAt int64 `json:"created_at"` } +type RefundOrderRequest struct { + Id int64 `json:"id" validate:"required"` + Reason string `json:"reason,omitempty" validate:"omitempty,max=500"` +} + type RegisterConfig struct { StopRegister bool `json:"stop_register"` EnableTrial bool `json:"enable_trial"` @@ -2551,6 +2641,11 @@ type RegisterLog struct { Timestamp int64 `json:"timestamp"` } +type RejectWithdrawalRequest struct { + WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"` + Reason string `json:"reason" validate:"required,max=500"` +} + type RemoveFamilyMemberRequest struct { FamilyId int64 `json:"family_id" validate:"required,gt=0"` UserId int64 `json:"user_id" validate:"required,gt=0"` @@ -2809,6 +2904,11 @@ type SetNodeMultiplierRequest struct { Periods []TimePeriod `json:"periods"` } +type SetPromoPriceRequest struct { + PromoRuleId int64 `json:"promo_rule_id" validate:"required,gt=0"` + Items []PromoPriceItem `json:"items" validate:"required,min=1,dive"` +} + type Shadowsocks struct { Method string `json:"method" validate:"required"` Port int `json:"port" validate:"required"` @@ -2866,13 +2966,6 @@ type StripePayment struct { PublishableKey string `json:"publishable_key"` } -type SubscribePromo struct { - RuleName string `json:"rule_name"` - RuleType string `json:"rule_type"` - PromoPrice int64 `json:"promo_price"` - ExpiresAt int64 `json:"expires_at"` -} - type Subscribe struct { Id int64 `json:"id"` Name string `json:"name"` @@ -2975,6 +3068,13 @@ type SubscribeLog struct { Timestamp int64 `json:"timestamp"` } +type SubscribePromo struct { + RuleName string `json:"rule_name"` + RuleType string `json:"rule_type"` + PromoPrice int64 `json:"promo_price"` + ExpiresAt int64 `json:"expires_at"` +} + type SubscribeSortRequest struct { Sort []SortItem `json:"sort"` } @@ -3222,30 +3322,6 @@ type UpdateCouponRequest struct { Enable *bool `json:"enable,omitempty"` } -type SetPromoPriceRequest struct { - PromoRuleId int64 `json:"promo_rule_id" validate:"required,gt=0"` - Items []PromoPriceItem `json:"items" validate:"required,min=1,dive"` -} - -type DeletePromoPriceRequest struct { - Id int64 `uri:"id" validate:"required,gt=0"` -} - -type DeletePromoRuleRequest struct { - Id int64 `uri:"id" validate:"required,gt=0"` -} - -type UpdatePromoRuleRequest struct { - Id int64 `uri:"id" validate:"required,gt=0"` - Name string `json:"name" validate:"required,max=100"` - Type string `json:"type" validate:"required,oneof=new_user inactive_user campaign"` - Params map[string]interface{} `json:"params"` - Priority int64 `json:"priority" validate:"gte=0"` - Enabled *bool `json:"enabled"` - StartTime *int64 `json:"start_time"` - EndTime *int64 `json:"end_time"` -} - type UpdateDocumentRequest struct { Id int64 `json:"id" validate:"required"` Title string `json:"title" validate:"required"` @@ -3312,6 +3388,17 @@ type UpdatePaymentMethodRequest struct { Enable *bool `json:"enable" validate:"required"` } +type UpdatePromoRuleRequest struct { + Id int64 `uri:"id" validate:"required,gt=0"` + Name string `json:"name" validate:"required,max=100"` + Type string `json:"type" validate:"required,oneof=new_user inactive_user campaign"` + Params map[string]interface{} `json:"params"` + Priority int64 `json:"priority" validate:"gte=0"` + Enabled *bool `json:"enabled"` + StartTime *int64 `json:"start_time"` + EndTime *int64 `json:"end_time"` +} + type UpdateRedemptionCodeRequest struct { Id int64 `json:"id" validate:"required"` TotalCount int64 `json:"total_count,omitempty"` @@ -3470,7 +3557,7 @@ type User struct { EnableLoginNotify bool `json:"enable_login_notify"` EnableSubscribeNotify bool `json:"enable_subscribe_notify"` EnableTradeNotify bool `json:"enable_trade_notify"` - UseStatus bool `json:"use_status"` + UseStatus bool `json:"use_status"` // Whether to show the "bind email to get free trial" prompt AuthMethods []UserAuthMethod `json:"auth_methods"` UserDevices []UserDevice `json:"user_devices"` Rules []string `json:"rules"` @@ -3787,96 +3874,3 @@ type WithdrawalLog struct { CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } - -type GetAdminUserInviteStatsRequest struct { - UserId int64 `form:"user_id" validate:"required"` -} - -type GetAdminUserInviteStatsResponse struct { - InviteCount int64 `json:"invite_count"` - TotalCommission int64 `json:"total_commission"` - CurrentCommission int64 `json:"current_commission"` - ReferralPercentage uint8 `json:"referral_percentage"` - OnlyFirstPurchase bool `json:"only_first_purchase"` -} - -type GetAdminUserInviteListRequest struct { - UserId int64 `form:"user_id" validate:"required"` - Page int `form:"page"` - Size int `form:"size"` - Search string `form:"search"` - Enable *int `form:"enable"` - UserIdSearch int64 `form:"user_id_search"` -} - -type AdminInvitedUser struct { - Id int64 `json:"id"` - Avatar string `json:"avatar"` - Identifier string `json:"identifier"` - Enable bool `json:"enable"` - CreatedAt int64 `json:"created_at"` - OrderCount int64 `json:"order_count"` - HasPurchased bool `json:"has_purchased"` - InviterCommission int64 `json:"inviter_commission"` - InviterGiftDays int64 `json:"inviter_gift_days"` - InviteeGiftDays int64 `json:"invitee_gift_days"` -} - -type GetAdminUserInviteListResponse struct { - Total int64 `json:"total"` - List []AdminInvitedUser `json:"list"` -} - -type GetInviteManageListRequest struct { - Page int `form:"page"` - Size int `form:"size"` - Search string `form:"search"` - InviterId int64 `form:"inviter_id"` - InviteeId int64 `form:"invitee_id"` -} - -type InviteManageRecord struct { - InviterId int64 `json:"inviter_id"` - InviterIdentifier string `json:"inviter_identifier"` - InviteeId int64 `json:"invitee_id"` - InviteeIdentifier string `json:"invitee_identifier"` - InviteeAvatar string `json:"invitee_avatar"` - InviteeEnable bool `json:"invitee_enable"` - InvitedAt int64 `json:"invited_at"` - OrderCount int64 `json:"order_count"` - HasPurchased bool `json:"has_purchased"` - InviterCommission int64 `json:"inviter_commission"` - InviterGiftDays int64 `json:"inviter_gift_days"` - InviteeGiftDays int64 `json:"invitee_gift_days"` -} - -type GetInviteManageListResponse struct { - Total int64 `json:"total"` - List []InviteManageRecord `json:"list"` -} - -type GetLogMessageRawRequest struct { - Id int64 `form:"id" validate:"required"` -} - -type GetLogMessageRawResponse struct { - Id int64 `json:"id"` - Platform string `json:"platform"` - AppVersion string `json:"app_version"` - OsName string `json:"os_name"` - OsVersion string `json:"os_version"` - DeviceId string `json:"device_id"` - UserId *int64 `json:"user_id"` - SessionId string `json:"session_id"` - Level uint8 `json:"level"` - ErrorCode string `json:"error_code"` - Message string `json:"message"` - Stack string `json:"stack"` - Context json.RawMessage `json:"context"` - ClientIP string `json:"client_ip"` - UserAgent string `json:"user_agent"` - Locale string `json:"locale"` - Digest string `json:"digest"` - OccurredAt int64 `json:"occurred_at"` - CreatedAt int64 `json:"created_at"` -} diff --git a/ppanel.api b/ppanel.api index b6d8726..65566cb 100644 --- a/ppanel.api +++ b/ppanel.api @@ -31,6 +31,8 @@ import ( "apis/admin/marketing.api" "apis/admin/application.api" "apis/admin/group.api" + "apis/admin/invite.api" + "apis/admin/promo.api" "apis/public/user.api" "apis/public/subscribe.api" "apis/public/redemption.api" diff --git a/third_party/gozero/go.mod b/third_party/gozero/go.mod new file mode 100644 index 0000000..4bdaa27 --- /dev/null +++ b/third_party/gozero/go.mod @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..ca3b5d0 --- /dev/null +++ b/third_party/gozero/rest/rest.go @@ -0,0 +1,109 @@ +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 +)