Browse Source

update 等级统计结果按照等级升序排序

Alvin 8 months ago
parent
commit
b4e82ec1b5
1 changed files with 11 additions and 3 deletions
  1. 11 3
      game/game_cluster/nodes/webadmin/service/synthesis.go

+ 11 - 3
game/game_cluster/nodes/webadmin/service/synthesis.go

@@ -3,6 +3,7 @@ package service
 import (
 	"context"
 	"math"
+	"sort"
 	"time"
 
 	mhayaTime "github.com/mhaya/extend/time"
@@ -659,10 +660,17 @@ func (s *Synthesis) FindUserLevel() (*entity.UserLevelCountResp, *code.Result) {
 		}
 	}
 
-	for k, v := range dataMap {
+	keys := make([]string, 0, len(dataMap))
+	for k := range dataMap {
+		keys = append(keys, k)
+	}
+
+	sort.Strings(keys)
+
+	for _, v := range keys {
 		results = append(results, &entity.UserLevelCountDetail{
-			Level:     cast.ToInt(k),
-			UserCount: v,
+			Level:     cast.ToInt(v),
+			UserCount: dataMap[v],
 		})
 	}