feat(订阅): 添加协议列表字段并修复路由分组命名
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 27s

refactor(订阅): 调整节点计数字段位置并优化代码格式
This commit is contained in:
shanshanzhong 2025-10-22 05:05:41 -07:00
parent ea1ef3527b
commit d3fb2aa178
5 changed files with 11 additions and 8 deletions

View File

@ -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"`

View File

@ -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))
}
}

View File

@ -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

View File

@ -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, ","),

View File

@ -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"`