修复(#104): 修复 goctl 重新生成代码漂移
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -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)
|
||||||
|
}
|
||||||
@@ -46,6 +46,7 @@ type (
|
|||||||
SpeedLimit int64 `json:"speed_limit"`
|
SpeedLimit int64 `json:"speed_limit"`
|
||||||
DeviceLimit int64 `json:"device_limit"`
|
DeviceLimit int64 `json:"device_limit"`
|
||||||
Quota int64 `json:"quota"`
|
Quota int64 `json:"quota"`
|
||||||
|
NewUserOnly *bool `json:"new_user_only"`
|
||||||
Nodes []int64 `json:"nodes"`
|
Nodes []int64 `json:"nodes"`
|
||||||
NodeTags []string `json:"node_tags"`
|
NodeTags []string `json:"node_tags"`
|
||||||
NodeGroupIds []int64 `json:"node_group_ids,omitempty"`
|
NodeGroupIds []int64 `json:"node_group_ids,omitempty"`
|
||||||
@@ -74,6 +75,7 @@ type (
|
|||||||
SpeedLimit int64 `json:"speed_limit"`
|
SpeedLimit int64 `json:"speed_limit"`
|
||||||
DeviceLimit int64 `json:"device_limit"`
|
DeviceLimit int64 `json:"device_limit"`
|
||||||
Quota int64 `json:"quota"`
|
Quota int64 `json:"quota"`
|
||||||
|
NewUserOnly *bool `json:"new_user_only"`
|
||||||
Nodes []int64 `json:"nodes"`
|
Nodes []int64 `json:"nodes"`
|
||||||
NodeTags []string `json:"node_tags"`
|
NodeTags []string `json:"node_tags"`
|
||||||
NodeGroupIds []int64 `json:"node_group_ids,omitempty"`
|
NodeGroupIds []int64 `json:"node_group_ids,omitempty"`
|
||||||
@@ -175,4 +177,3 @@ service ppanel {
|
|||||||
@handler ResetAllSubscribeToken
|
@handler ResetAllSubscribeToken
|
||||||
post /reset_all_token returns (ResetAllSubscribeTokenResponse)
|
post /reset_all_token returns (ResetAllSubscribeTokenResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ type (
|
|||||||
SubscribeId *int64 `form:"subscribe_id,omitempty"`
|
SubscribeId *int64 `form:"subscribe_id,omitempty"`
|
||||||
UserSubscribeId *int64 `form:"user_subscribe_id,omitempty"`
|
UserSubscribeId *int64 `form:"user_subscribe_id,omitempty"`
|
||||||
ShortCode string `form:"short_code,omitempty"`
|
ShortCode string `form:"short_code,omitempty"`
|
||||||
|
DeviceId *int64 `form:"device_id,omitempty"`
|
||||||
FamilyJoined *bool `form:"family_joined,omitempty"`
|
FamilyJoined *bool `form:"family_joined,omitempty"`
|
||||||
FamilyStatus string `form:"family_status,omitempty"`
|
FamilyStatus string `form:"family_status,omitempty"`
|
||||||
FamilyOwnerUserId *int64 `form:"family_owner_user_id,omitempty"`
|
FamilyOwnerUserId *int64 `form:"family_owner_user_id,omitempty"`
|
||||||
FamilyId *int64 `form:"family_id,omitempty"`
|
FamilyId *int64 `form:"family_id,omitempty"`
|
||||||
|
SortOrder string `form:"sort_order,omitempty"`
|
||||||
}
|
}
|
||||||
// GetUserListResponse
|
// GetUserListResponse
|
||||||
GetUserListResponse {
|
GetUserListResponse {
|
||||||
@@ -229,6 +231,40 @@ type (
|
|||||||
WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"`
|
WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"`
|
||||||
Reason string `json:"reason" validate:"required,max=500"`
|
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 (
|
@server (
|
||||||
@@ -381,4 +417,12 @@ service ppanel {
|
|||||||
@doc "Reject withdrawal"
|
@doc "Reject withdrawal"
|
||||||
@handler RejectWithdrawal
|
@handler RejectWithdrawal
|
||||||
post /withdrawal/reject (RejectWithdrawalRequest)
|
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)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -111,7 +111,7 @@ type (
|
|||||||
|
|
||||||
@server (
|
@server (
|
||||||
prefix: v1/server
|
prefix: v1/server
|
||||||
group: server
|
group: node/server
|
||||||
middleware: ServerMiddleware
|
middleware: ServerMiddleware
|
||||||
)
|
)
|
||||||
service ppanel {
|
service ppanel {
|
||||||
@@ -138,11 +138,10 @@ service ppanel {
|
|||||||
|
|
||||||
@server (
|
@server (
|
||||||
prefix: v2/server
|
prefix: v2/server
|
||||||
group: server
|
group: node/server
|
||||||
)
|
)
|
||||||
service ppanel {
|
service ppanel {
|
||||||
@doc "Get Server Protocol Config"
|
@doc "Get Server Protocol Config"
|
||||||
@handler QueryServerProtocolConfig
|
@handler QueryServerProtocolConfig
|
||||||
get /:server_id (QueryServerConfigRequest) returns (QueryServerConfigResponse)
|
get /:server_id (QueryServerConfigRequest) returns (QueryServerConfigResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,9 +162,11 @@ type (
|
|||||||
RegisterConfig {
|
RegisterConfig {
|
||||||
StopRegister bool `json:"stop_register"`
|
StopRegister bool `json:"stop_register"`
|
||||||
EnableTrial bool `json:"enable_trial"`
|
EnableTrial bool `json:"enable_trial"`
|
||||||
|
EnableTrialEmailWhitelist bool `json:"enable_trial_email_whitelist"`
|
||||||
TrialSubscribe int64 `json:"trial_subscribe"`
|
TrialSubscribe int64 `json:"trial_subscribe"`
|
||||||
TrialTime int64 `json:"trial_time"`
|
TrialTime int64 `json:"trial_time"`
|
||||||
TrialTimeUnit string `json:"trial_time_unit"`
|
TrialTimeUnit string `json:"trial_time_unit"`
|
||||||
|
TrialEmailDomainWhitelist string `json:"trial_email_domain_whitelist"`
|
||||||
EnableIpRegisterLimit bool `json:"enable_ip_register_limit"`
|
EnableIpRegisterLimit bool `json:"enable_ip_register_limit"`
|
||||||
IpRegisterLimit int64 `json:"ip_register_limit"`
|
IpRegisterLimit int64 `json:"ip_register_limit"`
|
||||||
IpRegisterLimitDuration int64 `json:"ip_register_limit_duration"`
|
IpRegisterLimitDuration int64 `json:"ip_register_limit_duration"`
|
||||||
@@ -228,6 +230,7 @@ type (
|
|||||||
SubscribeDiscount {
|
SubscribeDiscount {
|
||||||
Quantity int64 `json:"quantity"`
|
Quantity int64 `json:"quantity"`
|
||||||
Discount float64 `json:"discount"`
|
Discount float64 `json:"discount"`
|
||||||
|
NewUserOnly bool `json:"new_user_only"`
|
||||||
MapApple string `json:"map_apple"`
|
MapApple string `json:"map_apple"`
|
||||||
Promo *SubscribePromo `json:"promo"`
|
Promo *SubscribePromo `json:"promo"`
|
||||||
}
|
}
|
||||||
@@ -293,6 +296,7 @@ type (
|
|||||||
SpeedLimit int64 `json:"speed_limit"`
|
SpeedLimit int64 `json:"speed_limit"`
|
||||||
DeviceLimit int64 `json:"device_limit"`
|
DeviceLimit int64 `json:"device_limit"`
|
||||||
Quota int64 `json:"quota"`
|
Quota int64 `json:"quota"`
|
||||||
|
NewUserOnly bool `json:"new_user_only"`
|
||||||
Nodes []int64 `json:"nodes"`
|
Nodes []int64 `json:"nodes"`
|
||||||
NodeTags []string `json:"node_tags"`
|
NodeTags []string `json:"node_tags"`
|
||||||
NodeGroupIds []int64 `json:"node_group_ids,omitempty"`
|
NodeGroupIds []int64 `json:"node_group_ids,omitempty"`
|
||||||
@@ -557,10 +561,13 @@ type (
|
|||||||
}
|
}
|
||||||
UserSubscribe {
|
UserSubscribe {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
|
IdStr string `json:"id_str"`
|
||||||
UserId int64 `json:"user_id"`
|
UserId int64 `json:"user_id"`
|
||||||
OrderId int64 `json:"order_id"`
|
OrderId int64 `json:"order_id"`
|
||||||
SubscribeId int64 `json:"subscribe_id"`
|
SubscribeId int64 `json:"subscribe_id"`
|
||||||
Subscribe Subscribe `json:"subscribe"`
|
Subscribe Subscribe `json:"subscribe"`
|
||||||
|
NodeGroupId int64 `json:"node_group_id"`
|
||||||
|
NodeGroupName string `json:"node_group_name"`
|
||||||
StartTime int64 `json:"start_time"`
|
StartTime int64 `json:"start_time"`
|
||||||
ExpireTime int64 `json:"expire_time"`
|
ExpireTime int64 `json:"expire_time"`
|
||||||
FinishedAt int64 `json:"finished_at"`
|
FinishedAt int64 `json:"finished_at"`
|
||||||
@@ -908,6 +915,7 @@ type (
|
|||||||
AttachAppleTransactionResponse {
|
AttachAppleTransactionResponse {
|
||||||
ExpiresAt int64 `json:"expires_at"`
|
ExpiresAt int64 `json:"expires_at"`
|
||||||
Tier string `json:"tier"`
|
Tier string `json:"tier"`
|
||||||
|
ExistingOrderNo string `json:"existing_order_no,omitempty"`
|
||||||
}
|
}
|
||||||
RestoreAppleTransactionsRequest {
|
RestoreAppleTransactionsRequest {
|
||||||
Transactions []string `json:"transactions" validate:"required"`
|
Transactions []string `json:"transactions" validate:"required"`
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ require (
|
|||||||
github.com/spf13/cobra v1.8.1
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/stripe/stripe-go/v81 v81.1.0
|
github.com/stripe/stripe-go/v81 v81.1.0
|
||||||
github.com/twilio/twilio-go v1.23.11
|
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 v1.29.0
|
||||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
|
||||||
@@ -52,6 +53,8 @@ require (
|
|||||||
k8s.io/apimachinery v0.31.1
|
k8s.io/apimachinery v0.31.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/zeromicro/go-zero => ./third_party/gozero
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.2
|
github.com/DATA-DOG/go-sqlmock v1.5.2
|
||||||
github.com/Masterminds/sprig/v3 v3.3.0
|
github.com/Masterminds/sprig/v3 v3.3.0
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package common
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package common
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package common
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package common
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package apple
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package apple
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package apple
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package apple
|
||||||
+2065
-940
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
package common
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package common
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package common
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package common
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package server
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package server
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package server
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package server
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package server
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package server
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package apple
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package apple
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package apple
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
package apple
|
||||||
+5
-1
@@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/perfect-panel/server/internal/handler"
|
"github.com/perfect-panel/server/internal/handler"
|
||||||
"github.com/perfect-panel/server/internal/middleware"
|
"github.com/perfect-panel/server/internal/middleware"
|
||||||
"github.com/perfect-panel/server/internal/svc"
|
"github.com/perfect-panel/server/internal/svc"
|
||||||
|
"github.com/zeromicro/go-zero/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
@@ -64,7 +65,10 @@ func initServer(svc *svc.ServiceContext) *gin.Engine {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// register handlers
|
// 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")
|
r.StaticFile("/order-recovery.html", "./public/order-recovery.html")
|
||||||
// register subscribe handler
|
// register subscribe handler
|
||||||
handler.RegisterSubscribeHandlers(r, svc)
|
handler.RegisterSubscribeHandlers(r, svc)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/perfect-panel/server/internal/model/client"
|
"github.com/perfect-panel/server/internal/model/client"
|
||||||
"github.com/perfect-panel/server/internal/model/node"
|
"github.com/perfect-panel/server/internal/model/node"
|
||||||
"github.com/perfect-panel/server/internal/model/redemption"
|
"github.com/perfect-panel/server/internal/model/redemption"
|
||||||
@@ -76,6 +77,9 @@ type ServiceContext struct {
|
|||||||
NodeMultiplierManager *nodeMultiplier.Manager
|
NodeMultiplierManager *nodeMultiplier.Manager
|
||||||
AuthLimiter *limit.PeriodLimit
|
AuthLimiter *limit.PeriodLimit
|
||||||
DeviceManager *device.DeviceManager
|
DeviceManager *device.DeviceManager
|
||||||
|
AuthMiddleware func(c *gin.Context)
|
||||||
|
DeviceMiddleware func(c *gin.Context)
|
||||||
|
ServerMiddleware func(c *gin.Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServiceContext(c config.Config) *ServiceContext {
|
func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
|
|||||||
+264
-270
@@ -3,15 +3,21 @@
|
|||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import "encoding/json"
|
|
||||||
|
|
||||||
type ActivateOrderRequest struct {
|
type ActivateOrderRequest struct {
|
||||||
OrderNo string `json:"order_no" validate:"required"`
|
OrderNo string `json:"order_no" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RefundOrderRequest struct {
|
type AdminInvitedUser struct {
|
||||||
Id int64 `json:"id" validate:"required"`
|
Id int64 `json:"id"`
|
||||||
Reason string `json:"reason,omitempty" validate:"omitempty,max=500"`
|
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 {
|
type Ads struct {
|
||||||
@@ -126,6 +132,10 @@ type ApplicationVersion struct {
|
|||||||
IsDefault bool `json:"is_default"`
|
IsDefault bool `json:"is_default"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ApproveWithdrawalRequest struct {
|
||||||
|
WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"`
|
||||||
|
}
|
||||||
|
|
||||||
type AttachAppleTransactionByIdRequest struct {
|
type AttachAppleTransactionByIdRequest struct {
|
||||||
OrderNo string `json:"order_no" validate:"required"`
|
OrderNo string `json:"order_no" validate:"required"`
|
||||||
TransactionId string `json:"transaction_id" validate:"required"`
|
TransactionId string `json:"transaction_id" validate:"required"`
|
||||||
@@ -251,6 +261,10 @@ type BindTelegramResponse struct {
|
|||||||
ExpiredAt int64 `json:"expired_at"`
|
ExpiredAt int64 `json:"expired_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CancelWithdrawalRequest struct {
|
||||||
|
WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"`
|
||||||
|
}
|
||||||
|
|
||||||
type CheckUserRequest struct {
|
type CheckUserRequest struct {
|
||||||
Email string `form:"email" validate:"required"`
|
Email string `form:"email" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -316,45 +330,6 @@ type ContactRequest struct {
|
|||||||
Notes string `json:"notes" validate:"max=2000"`
|
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 {
|
type Coupon struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@@ -414,16 +389,6 @@ type CreateCouponRequest struct {
|
|||||||
Enable *bool `json:"enable,omitempty"`
|
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 {
|
type CreateDocumentRequest struct {
|
||||||
Title string `json:"title" validate:"required"`
|
Title string `json:"title" validate:"required"`
|
||||||
Content string `json:"content" validate:"required"`
|
Content string `json:"content" validate:"required"`
|
||||||
@@ -485,6 +450,16 @@ type CreatePaymentMethodRequest struct {
|
|||||||
Enable *bool `json:"enable" validate:"required"`
|
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 {
|
type CreateQuotaTaskRequest struct {
|
||||||
Subscribers []int64 `json:"subscribers"`
|
Subscribers []int64 `json:"subscribers"`
|
||||||
IsActive *bool `json:"is_active"`
|
IsActive *bool `json:"is_active"`
|
||||||
@@ -668,6 +643,14 @@ type DeletePaymentMethodRequest struct {
|
|||||||
Id int64 `json:"id" validate:"required"`
|
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 {
|
type DeleteRedemptionCodeRequest struct {
|
||||||
Id int64 `json:"id" validate:"required"`
|
Id int64 `json:"id" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -823,14 +806,6 @@ type FamilySummary struct {
|
|||||||
UpdatedAt int64 `json:"updated_at"`
|
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 {
|
type FileUploadCompleteRequest struct {
|
||||||
FileId string `json:"file_id" validate:"required"`
|
FileId string `json:"file_id" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -856,6 +831,14 @@ type FileUploadInitResponse struct {
|
|||||||
ExpiredAt int64 `json:"expired_at"`
|
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 {
|
type FilterBalanceLogRequest struct {
|
||||||
FilterLogParams
|
FilterLogParams
|
||||||
UserId int64 `form:"user_id,optional"`
|
UserId int64 `form:"user_id,optional"`
|
||||||
@@ -876,17 +859,6 @@ type FilterCommissionLogResponse struct {
|
|||||||
List []CommissionLog `json:"list"`
|
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 {
|
type FilterEmailLogResponse struct {
|
||||||
Total int64 `json:"total"`
|
Total int64 `json:"total"`
|
||||||
List []MessageLog `json:"list"`
|
List []MessageLog `json:"list"`
|
||||||
@@ -936,6 +908,17 @@ type FilterNodeListResponse struct {
|
|||||||
List []Node `json:"list"`
|
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 {
|
type FilterRegisterLogRequest struct {
|
||||||
FilterLogParams
|
FilterLogParams
|
||||||
UserId int64 `form:"user_id,optional"`
|
UserId int64 `form:"user_id,optional"`
|
||||||
@@ -1027,6 +1010,32 @@ type GenerateCaptchaResponse struct {
|
|||||||
BlockImage string `json:"block_image,omitempty"`
|
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 {
|
type GetAdsDetailRequest struct {
|
||||||
Id int64 `form:"id"`
|
Id int64 `form:"id"`
|
||||||
}
|
}
|
||||||
@@ -1145,48 +1154,6 @@ type GetCouponListResponse struct {
|
|||||||
List []Coupon `json:"list"`
|
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 {
|
type GetDetailRequest struct {
|
||||||
Id int64 `form:"id" validate:"required"`
|
Id int64 `form:"id" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -1327,6 +1294,19 @@ type GetGroupHistoryResponse struct {
|
|||||||
List []GroupHistory `json:"list"`
|
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 {
|
type GetInviteRecordsRequest struct {
|
||||||
Page int `form:"page"`
|
Page int `form:"page"`
|
||||||
Size int `form:"size"`
|
Size int `form:"size"`
|
||||||
@@ -1339,6 +1319,32 @@ type GetInviteRecordsResponse struct {
|
|||||||
List []InviteRecord `json:"list"`
|
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 {
|
type GetLoginLogRequest struct {
|
||||||
Page int `form:"page"`
|
Page int `form:"page"`
|
||||||
Size int `form:"size"`
|
Size int `form:"size"`
|
||||||
@@ -1417,6 +1423,48 @@ type GetPreSendEmailCountResponse struct {
|
|||||||
Count int64 `json:"count"`
|
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 {
|
type GetRedemptionCodeListRequest struct {
|
||||||
Page int64 `form:"page" validate:"required"`
|
Page int64 `form:"page" validate:"required"`
|
||||||
Size int64 `form:"size" validate:"required"`
|
Size int64 `form:"size" validate:"required"`
|
||||||
@@ -1708,6 +1756,19 @@ type GetUserTrafficStatsResponse struct {
|
|||||||
TotalTraffic int64 `json:"total_traffic"`
|
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 GiftLog struct {
|
||||||
Type uint16 `json:"type"`
|
Type uint16 `json:"type"`
|
||||||
UserId int64 `json:"user_id"`
|
UserId int64 `json:"user_id"`
|
||||||
@@ -1768,6 +1829,21 @@ type InviteConfig struct {
|
|||||||
GiftDays int64 `json:"gift_days"`
|
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 {
|
type InviteRecord struct {
|
||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
PeerHash string `json:"peer_hash"`
|
PeerHash string `json:"peer_hash"`
|
||||||
@@ -1949,8 +2025,6 @@ type Order struct {
|
|||||||
Amount int64 `json:"amount"`
|
Amount int64 `json:"amount"`
|
||||||
GiftAmount int64 `json:"gift_amount"`
|
GiftAmount int64 `json:"gift_amount"`
|
||||||
Discount int64 `json:"discount"`
|
Discount int64 `json:"discount"`
|
||||||
PromoRuleId int64 `json:"promo_rule_id"`
|
|
||||||
PromoDiscount int64 `json:"promo_discount"`
|
|
||||||
Coupon string `json:"coupon"`
|
Coupon string `json:"coupon"`
|
||||||
CouponDiscount int64 `json:"coupon_discount"`
|
CouponDiscount int64 `json:"coupon_discount"`
|
||||||
Commission int64 `json:"commission,omitempty"`
|
Commission int64 `json:"commission,omitempty"`
|
||||||
@@ -1974,8 +2048,6 @@ type OrderDetail struct {
|
|||||||
Amount int64 `json:"amount"`
|
Amount int64 `json:"amount"`
|
||||||
GiftAmount int64 `json:"gift_amount"`
|
GiftAmount int64 `json:"gift_amount"`
|
||||||
Discount int64 `json:"discount"`
|
Discount int64 `json:"discount"`
|
||||||
PromoRuleId int64 `json:"promo_rule_id"`
|
|
||||||
PromoDiscount int64 `json:"promo_discount"`
|
|
||||||
Coupon string `json:"coupon"`
|
Coupon string `json:"coupon"`
|
||||||
CouponDiscount int64 `json:"coupon_discount"`
|
CouponDiscount int64 `json:"coupon_discount"`
|
||||||
Commission int64 `json:"commission,omitempty"`
|
Commission int64 `json:"commission,omitempty"`
|
||||||
@@ -2158,6 +2230,45 @@ type PrivacyPolicyConfig struct {
|
|||||||
PrivacyPolicy string `json:"privacy_policy"`
|
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 Protocol struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Port uint16 `json:"port"`
|
Port uint16 `json:"port"`
|
||||||
@@ -2406,10 +2517,6 @@ type QueryUserSubscribeNodeListResponse struct {
|
|||||||
List []UserSubscribeInfo `json:"list"`
|
List []UserSubscribeInfo `json:"list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CancelWithdrawalRequest struct {
|
|
||||||
WithdrawalId int64 `json:"withdrawal_id" validate:"required,gt=0"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type QueryWithdrawalLogListRequest struct {
|
type QueryWithdrawalLogListRequest struct {
|
||||||
Page int `form:"page"`
|
Page int `form:"page"`
|
||||||
Size int `form:"size"`
|
Size int `form:"size"`
|
||||||
@@ -2420,28 +2527,6 @@ type QueryWithdrawalLogListResponse struct {
|
|||||||
Total int64 `json:"total"`
|
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 {
|
type QuotaTask struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Subscribers []int64 `json:"subscribers"`
|
Subscribers []int64 `json:"subscribers"`
|
||||||
@@ -2528,6 +2613,11 @@ type RedemptionRecord struct {
|
|||||||
CreatedAt int64 `json:"created_at"`
|
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 {
|
type RegisterConfig struct {
|
||||||
StopRegister bool `json:"stop_register"`
|
StopRegister bool `json:"stop_register"`
|
||||||
EnableTrial bool `json:"enable_trial"`
|
EnableTrial bool `json:"enable_trial"`
|
||||||
@@ -2551,6 +2641,11 @@ type RegisterLog struct {
|
|||||||
Timestamp int64 `json:"timestamp"`
|
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 {
|
type RemoveFamilyMemberRequest struct {
|
||||||
FamilyId int64 `json:"family_id" validate:"required,gt=0"`
|
FamilyId int64 `json:"family_id" validate:"required,gt=0"`
|
||||||
UserId int64 `json:"user_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"`
|
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 {
|
type Shadowsocks struct {
|
||||||
Method string `json:"method" validate:"required"`
|
Method string `json:"method" validate:"required"`
|
||||||
Port int `json:"port" validate:"required"`
|
Port int `json:"port" validate:"required"`
|
||||||
@@ -2866,13 +2966,6 @@ type StripePayment struct {
|
|||||||
PublishableKey string `json:"publishable_key"`
|
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 {
|
type Subscribe struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@@ -2975,6 +3068,13 @@ type SubscribeLog struct {
|
|||||||
Timestamp int64 `json:"timestamp"`
|
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 {
|
type SubscribeSortRequest struct {
|
||||||
Sort []SortItem `json:"sort"`
|
Sort []SortItem `json:"sort"`
|
||||||
}
|
}
|
||||||
@@ -3222,30 +3322,6 @@ type UpdateCouponRequest struct {
|
|||||||
Enable *bool `json:"enable,omitempty"`
|
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 {
|
type UpdateDocumentRequest struct {
|
||||||
Id int64 `json:"id" validate:"required"`
|
Id int64 `json:"id" validate:"required"`
|
||||||
Title string `json:"title" validate:"required"`
|
Title string `json:"title" validate:"required"`
|
||||||
@@ -3312,6 +3388,17 @@ type UpdatePaymentMethodRequest struct {
|
|||||||
Enable *bool `json:"enable" validate:"required"`
|
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 {
|
type UpdateRedemptionCodeRequest struct {
|
||||||
Id int64 `json:"id" validate:"required"`
|
Id int64 `json:"id" validate:"required"`
|
||||||
TotalCount int64 `json:"total_count,omitempty"`
|
TotalCount int64 `json:"total_count,omitempty"`
|
||||||
@@ -3470,7 +3557,7 @@ type User struct {
|
|||||||
EnableLoginNotify bool `json:"enable_login_notify"`
|
EnableLoginNotify bool `json:"enable_login_notify"`
|
||||||
EnableSubscribeNotify bool `json:"enable_subscribe_notify"`
|
EnableSubscribeNotify bool `json:"enable_subscribe_notify"`
|
||||||
EnableTradeNotify bool `json:"enable_trade_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"`
|
AuthMethods []UserAuthMethod `json:"auth_methods"`
|
||||||
UserDevices []UserDevice `json:"user_devices"`
|
UserDevices []UserDevice `json:"user_devices"`
|
||||||
Rules []string `json:"rules"`
|
Rules []string `json:"rules"`
|
||||||
@@ -3787,96 +3874,3 @@ type WithdrawalLog struct {
|
|||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_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"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import (
|
|||||||
"apis/admin/marketing.api"
|
"apis/admin/marketing.api"
|
||||||
"apis/admin/application.api"
|
"apis/admin/application.api"
|
||||||
"apis/admin/group.api"
|
"apis/admin/group.api"
|
||||||
|
"apis/admin/invite.api"
|
||||||
|
"apis/admin/promo.api"
|
||||||
"apis/public/user.api"
|
"apis/public/user.api"
|
||||||
"apis/public/subscribe.api"
|
"apis/public/subscribe.api"
|
||||||
"apis/public/redemption.api"
|
"apis/public/redemption.api"
|
||||||
|
|||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
module github.com/zeromicro/go-zero
|
||||||
|
|
||||||
|
go 1.24
|
||||||
|
|
||||||
|
require github.com/gin-gonic/gin v1.10.0
|
||||||
Vendored
+109
@@ -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
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user