Browse Source

feat(peer): add alias field and support filtering by alias

lejianwen 5 months ago
parent
commit
f09c898f16
4 changed files with 8 additions and 1 deletions
  1. 1 1
      cmd/apimain.go
  2. 3 0
      http/controller/admin/peer.go
  3. 3 0
      http/request/admin/peer.go
  4. 1 0
      model/peer.go

+ 1 - 1
cmd/apimain.go

@@ -23,7 +23,7 @@ import (
23 23
 	"github.com/spf13/cobra"
24 24
 )
25 25
 
26
-const DatabaseVersion = 264
26
+const DatabaseVersion = 265
27 27
 
28 28
 // @title 管理系统API
29 29
 // @version 1.0

+ 3 - 0
http/controller/admin/peer.go

@@ -114,6 +114,9 @@ func (ct *Peer) List(c *gin.Context) {
114 114
 		if query.Ip != "" {
115 115
 			tx.Where("last_online_ip like ?", "%"+query.Ip+"%")
116 116
 		}
117
+		if query.Alias != "" {
118
+			tx.Where("alias like ?", "%"+query.Alias+"%")
119
+		}
117 120
 	})
118 121
 	response.Success(c, res)
119 122
 }

+ 3 - 0
http/request/admin/peer.go

@@ -13,6 +13,7 @@ type PeerForm struct {
13 13
 	Uuid     string `json:"uuid"`
14 14
 	Version  string `json:"version"`
15 15
 	GroupId  uint   `json:"group_id"`
16
+	Alias    string `json:"alias"`
16 17
 }
17 18
 
18 19
 type PeerBatchDeleteForm struct {
@@ -32,6 +33,7 @@ func (f *PeerForm) ToPeer() *model.Peer {
32 33
 		Uuid:     f.Uuid,
33 34
 		Version:  f.Version,
34 35
 		GroupId:  f.GroupId,
36
+		Alias:    f.Alias,
35 37
 	}
36 38
 }
37 39
 
@@ -43,6 +45,7 @@ type PeerQuery struct {
43 45
 	Uuids    string `json:"uuids" form:"uuids"`
44 46
 	Ip       string `json:"ip" form:"ip"`
45 47
 	Username string `json:"username" form:"username"`
48
+	Alias    string `json:"alias" form:"alias"`
46 49
 }
47 50
 
48 51
 type SimpleDataQuery struct {

+ 1 - 0
model/peer.go

@@ -15,6 +15,7 @@ type Peer struct {
15 15
 	LastOnlineTime int64  `json:"last_online_time"  gorm:"default:0;not null;"`
16 16
 	LastOnlineIp   string `json:"last_online_ip"  gorm:"default:'';not null;"`
17 17
 	GroupId        uint   `json:"group_id"  gorm:"default:0;not null;index"`
18
+	Alias          string `json:"alias" gorm:"default:'';not null;index"`
18 19
 	TimeModel
19 20
 }
20 21