Pārlūkot izejas kodu

增加-数据结构

userxzz 8 mēneši atpakaļ
vecāks
revīzija
5c6c206da1

+ 9 - 5
game/game_cluster/internal/mdb/models/whitelist.go

@@ -1,12 +1,16 @@
 package models
 
+import (
+	"time"
+)
+
 // Whitelist ip白名单
 type Whitelist struct {
-	Id        string `gorm:"column:id;primaryKey" json:"id" bson:"_id"`
-	IP        string `json:"ip" bson:"ip"` // Ip
-	Desc      string `gorm:"column:desc;comment:描述" json:"desc" bson:"desc"`
-	CreatedAt uint64 `gorm:"column:created_at;autoCreateTime" json:"created_at" bson:"created_at"`
-	DeletedAt uint64 `gorm:"column:deleted_at;" json:"deleted_at" bson:"deleted_at"`
+	Id        string    `gorm:"column:id;primaryKey" json:"id" bson:"_id"`
+	IP        string    `json:"ip" bson:"ip"` // Ip
+	Desc      string    `gorm:"column:desc;comment:描述" json:"desc" bson:"desc"`
+	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" bson:"created_at"`
+	DeletedAt time.Time `gorm:"column:deleted_at;" json:"deleted_at" bson:"deleted_at"`
 }
 
 func (w *Whitelist) TableName() string {

+ 4 - 2
game/game_cluster/nodes/webadmin/controller/whitelist.go

@@ -40,8 +40,10 @@ func (w *Whitelist) GetWhitelist(ctx *gin.Context) {
 		return
 	}
 	ctx.JSON(200, gin.H{
-		"code": 200,
-		"data": whitelists,
+		"code":  200,
+		"data":  whitelists,
+		"msg":   "success",
+		"total": req.Count,
 	})
 }
 

+ 4 - 3
game/game_cluster/nodes/webadmin/entity/whitelist.go

@@ -1,9 +1,10 @@
 package entity
 
 type WhitelistListReq struct {
-	Page int    `json:"page" binding:"required"`
-	Size int    `json:"size" binding:"required"`
-	IP   string `json:"ip"`
+	Page  int    `json:"page" binding:"required"`
+	Size  int    `json:"size" binding:"required"`
+	Count int64  `json:"count"`
+	IP    string `json:"ip"`
 }
 
 type WhitelistAddReq struct {

+ 5 - 1
game/game_cluster/nodes/webadmin/service/whitelist.go

@@ -100,7 +100,11 @@ func (w *Whitelist) GetAll(req *entity.WhitelistListReq) ([]models.Whitelist, er
 	// 设置分页选项
 	skip := (page - 1) * pageSize
 	findOptions := options.Find().SetSkip(int64(skip)).SetLimit(int64(pageSize))
-
+	count, err := collection.CountDocuments(ctx, bson.D{})
+	if err != nil {
+		return nil, err
+	}
+	req.Count = count
 	// 查询数据库
 	var results []models.Whitelist
 	cursor, err := collection.Find(ctx, bson.D{}, findOptions)