Просмотр исходного кода

feat(admin): Add filter by ip and username (#172)

lejianwen месяцев назад: 10
Родитель
Сommit
b770ab178d
2 измененных файлов с 8 добавлено и 0 удалено
  1. 6 0
      http/controller/admin/peer.go
  2. 2 0
      http/request/admin/peer.go

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

@@ -108,6 +108,12 @@ func (ct *Peer) List(c *gin.Context) {
108 108
 		if query.Uuids != "" {
109 109
 			tx.Where("uuid in (?)", query.Uuids)
110 110
 		}
111
+		if query.Username != "" {
112
+			tx.Where("username like ?", "%"+query.Username+"%")
113
+		}
114
+		if query.Ip != "" {
115
+			tx.Where("last_online_ip like ?", "%"+query.Ip+"%")
116
+		}
111 117
 	})
112 118
 	response.Success(c, res)
113 119
 }

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

@@ -41,6 +41,8 @@ type PeerQuery struct {
41 41
 	Id       string `json:"id" form:"id"`
42 42
 	Hostname string `json:"hostname" form:"hostname"`
43 43
 	Uuids    string `json:"uuids" form:"uuids"`
44
+	Ip       string `json:"ip" form:"ip"`
45
+	Username string `json:"username" form:"username"`
44 46
 }
45 47
 
46 48
 type SimpleDataQuery struct {