- UserSubscribe/UserSubscribeDetail 新增 node_group_id/node_group_name 字段 - 管理员查询用户订阅列表批量填充分组名 - 管理员查询单个订阅详情填充分组名 - ThrottleResult/UserSubscribeDetail 新增 throttle_start/throttle_end 字段 - 限速时返回限速窗口起止时间(秒级 Unix 时间戳) Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -3,6 +3,7 @@ package user
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/perfect-panel/server/internal/model/group"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
"github.com/perfect-panel/server/internal/types"
|
||||
"github.com/perfect-panel/server/pkg/logger"
|
||||
@@ -38,10 +39,33 @@ func (l *GetUserSubscribeLogic) GetUserSubscribe(req *types.GetUserSubscribeList
|
||||
Total: int64(len(data)),
|
||||
}
|
||||
|
||||
// 收集所有 node_group_id,批量查分组名
|
||||
groupIdSet := make(map[int64]struct{})
|
||||
for _, item := range data {
|
||||
if item.NodeGroupId > 0 {
|
||||
groupIdSet[item.NodeGroupId] = struct{}{}
|
||||
}
|
||||
}
|
||||
groupNames := make(map[int64]string)
|
||||
if len(groupIdSet) > 0 {
|
||||
ids := make([]int64, 0, len(groupIdSet))
|
||||
for id := range groupIdSet {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
var groups []group.NodeGroup
|
||||
if err := l.svcCtx.DB.WithContext(l.ctx).Where("id IN ?", ids).Find(&groups).Error; err == nil {
|
||||
for _, g := range groups {
|
||||
groupNames[g.Id] = g.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, item := range data {
|
||||
var sub types.UserSubscribe
|
||||
tool.DeepCopy(&sub, item)
|
||||
sub.Short, _ = tool.FixedUniqueString(item.Token, 8, "")
|
||||
sub.NodeGroupId = item.NodeGroupId
|
||||
sub.NodeGroupName = groupNames[item.NodeGroupId]
|
||||
resp.List = append(resp.List, sub)
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user