From d3fb2aa1788c16503737e0007706586e96d11b75 Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Wed, 22 Oct 2025 05:05:41 -0700 Subject: [PATCH] =?UTF-8?q?feat(=E8=AE=A2=E9=98=85):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E5=88=97=E8=A1=A8=E5=AD=97=E6=AE=B5=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=AF=E7=94=B1=E5=88=86=E7=BB=84=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(订阅): 调整节点计数字段位置并优化代码格式 --- apis/public/subscribe.api | 1 + internal/handler/routes.go | 4 ++-- .../logic/public/subscribe/querySubscribeListLogic.go | 10 +++++----- .../subscribe/queryUserSubscribeNodeListLogic.go | 1 + internal/types/types.go | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apis/public/subscribe.api b/apis/public/subscribe.api index 25234ad..f810600 100644 --- a/apis/public/subscribe.api +++ b/apis/public/subscribe.api @@ -41,6 +41,7 @@ type ( Name string `json:"name"` Uuid string `json:"uuid"` Protocol string `json:"protocol"` + Protocols string `json:"protocols"` Port uint16 `json:"port"` Address string `json:"address"` Tags []string `json:"tags"` diff --git a/internal/handler/routes.go b/internal/handler/routes.go index e684fb4..5f8d80d 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -867,10 +867,10 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) { serverGroupRouter.GET("/user", server.GetServerUserListHandler(serverCtx)) } - serverGroupRouterV2 := router.Group("/v2/server") + serverGroupRouter = router.Group("/v2/server") { // Get Server Protocol Config - serverGroupRouterV2.GET("/:server_id", server.QueryServerProtocolConfigHandler(serverCtx)) + serverGroupRouter.GET("/:server_id", server.QueryServerProtocolConfigHandler(serverCtx)) } } diff --git a/internal/logic/public/subscribe/querySubscribeListLogic.go b/internal/logic/public/subscribe/querySubscribeListLogic.go index 16d538e..7cf40b0 100644 --- a/internal/logic/public/subscribe/querySubscribeListLogic.go +++ b/internal/logic/public/subscribe/querySubscribeListLogic.go @@ -55,16 +55,16 @@ func (l *QuerySubscribeListLogic) QuerySubscribeList(req *types.QuerySubscribeLi _ = json.Unmarshal([]byte(item.Discount), &discount) sub.Discount = discount } - + // 计算节点数量 var nodeIds []int64 var tags []string - + // 解析节点ID if item.Nodes != "" { nodeIds = tool.StringToInt64Slice(item.Nodes) } - + // 解析标签 if item.NodeTags != "" { tagStrs := strings.Split(item.NodeTags, ",") @@ -74,7 +74,7 @@ func (l *QuerySubscribeListLogic) QuerySubscribeList(req *types.QuerySubscribeLi } } } - + // 获取节点数量 nodeCount, err := l.svcCtx.NodeModel.CountNodesByIdsAndTags(l.ctx, nodeIds, tags) if err != nil { @@ -82,7 +82,7 @@ func (l *QuerySubscribeListLogic) QuerySubscribeList(req *types.QuerySubscribeLi nodeCount = 0 // 出错时设置为0 } sub.NodeCount = nodeCount - + list[i] = sub } resp.List = list diff --git a/internal/logic/public/subscribe/queryUserSubscribeNodeListLogic.go b/internal/logic/public/subscribe/queryUserSubscribeNodeListLogic.go index 2ad05b8..1d9769d 100644 --- a/internal/logic/public/subscribe/queryUserSubscribeNodeListLogic.go +++ b/internal/logic/public/subscribe/queryUserSubscribeNodeListLogic.go @@ -141,6 +141,7 @@ func (l *QueryUserSubscribeNodeListLogic) getServers(userSub *user.Subscribe) (u Name: n.Name, Uuid: userSub.UUID, Protocol: n.Protocol, + Protocols: server.Protocols, Port: n.Port, Address: n.Address, Tags: strings.Split(n.Tags, ","), diff --git a/internal/types/types.go b/internal/types/types.go index 998adf6..3a44525 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -2021,6 +2021,7 @@ type Subscribe struct { UnitPrice int64 `json:"unit_price"` UnitTime string `json:"unit_time"` Discount []SubscribeDiscount `json:"discount"` + NodeCount int64 `json:"node_count"` Replacement int64 `json:"replacement"` Inventory int64 `json:"inventory"` Traffic int64 `json:"traffic"` @@ -2029,7 +2030,6 @@ type Subscribe struct { Quota int64 `json:"quota"` Nodes []int64 `json:"nodes"` NodeTags []string `json:"node_tags"` - NodeCount int64 `json:"node_count"` Show bool `json:"show"` Sell bool `json:"sell"` Sort int64 `json:"sort"` @@ -2645,6 +2645,7 @@ type UserSubscribeNodeInfo struct { Name string `json:"name"` Uuid string `json:"uuid"` Protocol string `json:"protocol"` + Protocols string `json:"protocols"` Port uint16 `json:"port"` Address string `json:"address"` Tags []string `json:"tags"`