合并 internal → main: 退款/提现/激活/CI 全面优化 #4

Open
shanshanzhong147 wants to merge 76 commits from internal into main
36 changed files with 1173 additions and 2572 deletions
Showing only changes of commit 075c1215ca - Show all commits
+1 -2
View File
@@ -12,9 +12,8 @@ RUN apk update --no-cache && apk add --no-cache tzdata ca-certificates
WORKDIR /build
# Copy go.mod, go.sum, and replace targets (third_party) before downloading deps
# Copy go.mod and go.sum first to take advantage of Docker caching
COPY go.mod go.sum ./
COPY third_party/ ./third_party/
RUN go mod download
# Copy the rest of the application code
-3
View File
@@ -33,7 +33,6 @@ require (
github.com/spf13/cobra v1.8.1
github.com/stripe/stripe-go/v81 v81.1.0
github.com/twilio/twilio-go v1.23.11
github.com/zeromicro/go-zero v0.0.0
go.opentelemetry.io/otel v1.29.0
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
@@ -53,8 +52,6 @@ require (
k8s.io/apimachinery v0.31.1
)
replace github.com/zeromicro/go-zero => ./third_party/gozero
require (
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/Masterminds/sprig/v3 v3.3.0
@@ -1,52 +0,0 @@
package common
import (
"github.com/gin-gonic/gin"
commonLogic "github.com/perfect-panel/server/internal/logic/common"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/internal/types"
"github.com/perfect-panel/server/pkg/constant"
"github.com/perfect-panel/server/pkg/result"
)
func CheckCodeLegacyHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return checkCodeLegacyHandler(svcCtx, false)
}
func CheckCodeLegacyV2Handler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return checkCodeLegacyHandler(svcCtx, true)
}
func checkCodeLegacyHandler(svcCtx *svc.ServiceContext, consume bool) func(c *gin.Context) {
return func(c *gin.Context) {
var req types.LegacyCheckVerificationCodeRequest
_ = c.ShouldBind(&req)
validateErr := svcCtx.Validate(&req)
if validateErr != nil {
result.ParamErrorResult(c, validateErr)
return
}
normalizedReq, legacyType3Mapped, err := commonLogic.NormalizeLegacyCheckVerificationCodeRequest(&req)
if err != nil {
result.ParamErrorResult(c, err)
return
}
l := commonLogic.NewCheckVerificationCodeLogic(c.Request.Context(), svcCtx)
resp, err := l.CheckVerificationCodeWithBehavior(normalizedReq, commonLogic.VerifyCodeCheckBehavior{
Source: "legacy",
Consume: consume,
LegacyType3Mapped: legacyType3Mapped,
AllowSceneFallback: constant.ParseVerifyType(normalizedReq.Type) != constant.DeleteAccount,
})
legacyResp := &types.LegacyCheckVerificationCodeResponse{}
if resp != nil {
legacyResp.Status = resp.Status
legacyResp.Exist = resp.Status
}
result.HttpResult(c, legacyResp, err)
}
}
@@ -1 +0,0 @@
package common
@@ -1 +0,0 @@
package common
@@ -1 +0,0 @@
package common
@@ -1 +0,0 @@
package common
@@ -1,11 +0,0 @@
package server
import (
"github.com/gin-gonic/gin"
serverhandler "github.com/perfect-panel/server/internal/handler/server"
"github.com/perfect-panel/server/internal/svc"
)
func GetServerConfigHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return serverhandler.GetServerConfigHandler(svcCtx)
}
@@ -1,11 +0,0 @@
package server
import (
"github.com/gin-gonic/gin"
serverhandler "github.com/perfect-panel/server/internal/handler/server"
"github.com/perfect-panel/server/internal/svc"
)
func GetServerUserListHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return serverhandler.GetServerUserListHandler(svcCtx)
}
@@ -1,11 +0,0 @@
package server
import (
"github.com/gin-gonic/gin"
serverhandler "github.com/perfect-panel/server/internal/handler/server"
"github.com/perfect-panel/server/internal/svc"
)
func PushOnlineUsersHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return serverhandler.PushOnlineUsersHandler(svcCtx)
}
@@ -1,11 +0,0 @@
package server
import (
"github.com/gin-gonic/gin"
serverhandler "github.com/perfect-panel/server/internal/handler/server"
"github.com/perfect-panel/server/internal/svc"
)
func QueryServerProtocolConfigHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return serverhandler.QueryServerProtocolConfigHandler(svcCtx)
}
@@ -1,11 +0,0 @@
package server
import (
"github.com/gin-gonic/gin"
serverhandler "github.com/perfect-panel/server/internal/handler/server"
"github.com/perfect-panel/server/internal/svc"
)
func ServerPushStatusHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return serverhandler.ServerPushStatusHandler(svcCtx)
}
@@ -1,11 +0,0 @@
package server
import (
"github.com/gin-gonic/gin"
serverhandler "github.com/perfect-panel/server/internal/handler/server"
"github.com/perfect-panel/server/internal/svc"
)
func ServerPushUserTrafficHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return serverhandler.ServerPushUserTrafficHandler(svcCtx)
}
@@ -1 +0,0 @@
package apple
@@ -1 +0,0 @@
package apple
@@ -1 +0,0 @@
package apple
@@ -1 +0,0 @@
package apple
+1171 -2304
View File
File diff suppressed because it is too large Load Diff
@@ -1 +0,0 @@
package common
@@ -1 +0,0 @@
package common
@@ -1 +0,0 @@
package common
@@ -1 +0,0 @@
package common
@@ -1 +0,0 @@
package server
@@ -1 +0,0 @@
package server
@@ -1 +0,0 @@
package server
@@ -1 +0,0 @@
package server
@@ -1 +0,0 @@
package server
@@ -1 +0,0 @@
package server
@@ -1 +0,0 @@
package apple
@@ -1 +0,0 @@
package apple
@@ -1 +0,0 @@
package apple
@@ -1 +0,0 @@
package apple
+1 -5
View File
@@ -22,7 +22,6 @@ import (
"github.com/perfect-panel/server/internal/handler"
"github.com/perfect-panel/server/internal/middleware"
"github.com/perfect-panel/server/internal/svc"
"github.com/zeromicro/go-zero/rest"
)
type Service struct {
@@ -65,10 +64,7 @@ func initServer(svc *svc.ServiceContext) *gin.Engine {
)
// register handlers
svc.AuthMiddleware = middleware.AuthMiddleware(svc)
svc.DeviceMiddleware = middleware.DeviceMiddleware(svc)
svc.ServerMiddleware = middleware.ServerMiddleware(svc)
handler.RegisterHandlers(rest.NewGinServer(r), svc)
handler.RegisterHandlers(r, svc)
r.StaticFile("/order-recovery.html", "./public/order-recovery.html")
// register subscribe handler
handler.RegisterSubscribeHandlers(r, svc)
-4
View File
@@ -4,7 +4,6 @@ import (
"context"
"time"
"github.com/gin-gonic/gin"
"github.com/perfect-panel/server/internal/model/client"
"github.com/perfect-panel/server/internal/model/node"
"github.com/perfect-panel/server/internal/model/redemption"
@@ -77,9 +76,6 @@ type ServiceContext struct {
NodeMultiplierManager *nodeMultiplier.Manager
AuthLimiter *limit.PeriodLimit
DeviceManager *device.DeviceManager
AuthMiddleware func(c *gin.Context)
DeviceMiddleware func(c *gin.Context)
ServerMiddleware func(c *gin.Context)
}
func NewServiceContext(c config.Config) *ServiceContext {
-5
View File
@@ -1,5 +0,0 @@
module github.com/zeromicro/go-zero
go 1.24
require github.com/gin-gonic/gin v1.10.0
-109
View File
@@ -1,109 +0,0 @@
package rest
import (
"net/http"
"path"
"strings"
"github.com/gin-gonic/gin"
)
type Middleware = gin.HandlerFunc
type Route struct {
Method string
Path string
Handler gin.HandlerFunc
}
type Server struct {
router *gin.Engine
}
type routeOptions struct {
prefix string
middleware []Middleware
}
type RouteOption func(*routeOptions)
func NewGinServer(router *gin.Engine) *Server {
return &Server{router: router}
}
func WithMiddlewares(middlewares []Middleware, routes ...Route) []Route {
for i := range routes {
routes[i].Handler = chain(middlewares, routes[i].Handler)
}
return routes
}
func WithPrefix(prefix string) RouteOption {
return func(options *routeOptions) {
options.prefix = prefix
}
}
func WithJwt(_ string) RouteOption {
return func(*routeOptions) {}
}
func WithJwtTransition(_, _ string) RouteOption {
return func(*routeOptions) {}
}
func WithSignature(_ any) RouteOption {
return func(*routeOptions) {}
}
func WithSSE() RouteOption {
return func(*routeOptions) {}
}
func WithMaxBytes(_ int64) RouteOption {
return func(*routeOptions) {}
}
func WithTimeout(_ any) RouteOption {
return func(*routeOptions) {}
}
func (s *Server) AddRoutes(routes []Route, opts ...RouteOption) {
options := routeOptions{}
for _, opt := range opts {
opt(&options)
}
for _, route := range routes {
s.router.Handle(route.Method, joinPath(options.prefix, route.Path), chain(options.middleware, route.Handler))
}
}
func chain(middlewares []Middleware, handler gin.HandlerFunc) gin.HandlerFunc {
if len(middlewares) == 0 {
return handler
}
return func(c *gin.Context) {
for _, middleware := range middlewares {
middleware(c)
if c.IsAborted() {
return
}
}
handler(c)
}
}
func joinPath(prefix, routePath string) string {
if prefix == "" {
return routePath
}
joined := path.Join("/", prefix, routePath)
if strings.HasSuffix(routePath, "/") && !strings.HasSuffix(joined, "/") {
joined += "/"
}
return joined
}
var (
_ http.Handler
)