refactor(订阅): 调整节点计数字段位置并优化代码格式
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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, ","),
|
||||
|
||||
Reference in New Issue
Block a user