Features:
- Node group CRUD operations with traffic-based filtering - Three grouping modes: average distribution, subscription-based, and traffic-based - Automatic and manual group recalculation with history tracking - Group assignment preview before applying changes - User subscription group locking to prevent automatic reassignment - Subscribe-to-group mapping configuration - Group calculation history and detailed reports - System configuration for group management (enabled/mode/auto_create) Database: - Add node_group table for group definitions - Add group_history and group_history_detail tables for tracking - Add node_group_ids (JSON) to nodes and subscribe tables - Add node_group_id and group_locked fields to user_subscribe table - Add migration files for schema changes
This commit is contained in:
@@ -50,6 +50,8 @@ func (l *CreateSubscribeLogic) CreateSubscribe(req *types.CreateSubscribeRequest
|
||||
Quota: req.Quota,
|
||||
Nodes: tool.Int64SliceToString(req.Nodes),
|
||||
NodeTags: tool.StringSliceToString(req.NodeTags),
|
||||
NodeGroupIds: subscribe.JSONInt64Slice(req.NodeGroupIds),
|
||||
NodeGroupId: req.NodeGroupId,
|
||||
Show: req.Show,
|
||||
Sell: req.Sell,
|
||||
Sort: 0,
|
||||
|
||||
@@ -30,12 +30,20 @@ func NewGetSubscribeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
||||
}
|
||||
|
||||
func (l *GetSubscribeListLogic) GetSubscribeList(req *types.GetSubscribeListRequest) (resp *types.GetSubscribeListResponse, err error) {
|
||||
total, list, err := l.svcCtx.SubscribeModel.FilterList(l.ctx, &subscribe.FilterParams{
|
||||
// Build filter params
|
||||
filterParams := &subscribe.FilterParams{
|
||||
Page: int(req.Page),
|
||||
Size: int(req.Size),
|
||||
Language: req.Language,
|
||||
Search: req.Search,
|
||||
})
|
||||
}
|
||||
|
||||
// Add NodeGroupId filter if provided
|
||||
if req.NodeGroupId > 0 {
|
||||
filterParams.NodeGroupId = &req.NodeGroupId
|
||||
}
|
||||
|
||||
total, list, err := l.svcCtx.SubscribeModel.FilterList(l.ctx, filterParams)
|
||||
if err != nil {
|
||||
l.Logger.Error("[GetSubscribeListLogic] get subscribe list failed: ", logger.Field("error", err.Error()))
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "get subscribe list failed: %v", err.Error())
|
||||
@@ -56,6 +64,14 @@ func (l *GetSubscribeListLogic) GetSubscribeList(req *types.GetSubscribeListRequ
|
||||
}
|
||||
sub.Nodes = tool.StringToInt64Slice(item.Nodes)
|
||||
sub.NodeTags = strings.Split(item.NodeTags, ",")
|
||||
// Handle NodeGroupIds - convert from JSONInt64Slice to []int64
|
||||
if item.NodeGroupIds != nil {
|
||||
sub.NodeGroupIds = []int64(item.NodeGroupIds)
|
||||
} else {
|
||||
sub.NodeGroupIds = []int64{}
|
||||
}
|
||||
// NodeGroupId is already int64, should be copied by DeepCopy
|
||||
sub.NodeGroupId = item.NodeGroupId
|
||||
resultList = append(resultList, sub)
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ func (l *UpdateSubscribeLogic) UpdateSubscribe(req *types.UpdateSubscribeRequest
|
||||
Quota: req.Quota,
|
||||
Nodes: tool.Int64SliceToString(req.Nodes),
|
||||
NodeTags: tool.StringSliceToString(req.NodeTags),
|
||||
NodeGroupIds: subscribe.JSONInt64Slice(req.NodeGroupIds),
|
||||
NodeGroupId: req.NodeGroupId,
|
||||
Show: req.Show,
|
||||
Sell: req.Sell,
|
||||
Sort: req.Sort,
|
||||
|
||||
Reference in New Issue
Block a user