diff --git a/cmd/apimain.go b/cmd/apimain.go index 3745ab0..31c9d1d 100644 --- a/cmd/apimain.go +++ b/cmd/apimain.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" ) -const DatabaseVersion = 264 +const DatabaseVersion = 265 // @title 管理系统API // @version 1.0 diff --git a/http/controller/admin/peer.go b/http/controller/admin/peer.go index 825be2e..d8914a4 100644 --- a/http/controller/admin/peer.go +++ b/http/controller/admin/peer.go @@ -114,6 +114,9 @@ func (ct *Peer) List(c *gin.Context) { if query.Ip != "" { tx.Where("last_online_ip like ?", "%"+query.Ip+"%") } + if query.Alias != "" { + tx.Where("alias like ?", "%"+query.Alias+"%") + } }) response.Success(c, res) } diff --git a/http/request/admin/peer.go b/http/request/admin/peer.go index 66c1b49..88db2c0 100644 --- a/http/request/admin/peer.go +++ b/http/request/admin/peer.go @@ -13,6 +13,7 @@ type PeerForm struct { Uuid string `json:"uuid"` Version string `json:"version"` GroupId uint `json:"group_id"` + Alias string `json:"alias"` } type PeerBatchDeleteForm struct { @@ -32,6 +33,7 @@ func (f *PeerForm) ToPeer() *model.Peer { Uuid: f.Uuid, Version: f.Version, GroupId: f.GroupId, + Alias: f.Alias, } } @@ -43,6 +45,7 @@ type PeerQuery struct { Uuids string `json:"uuids" form:"uuids"` Ip string `json:"ip" form:"ip"` Username string `json:"username" form:"username"` + Alias string `json:"alias" form:"alias"` } type SimpleDataQuery struct { diff --git a/model/peer.go b/model/peer.go index cd9be40..19f20d0 100644 --- a/model/peer.go +++ b/model/peer.go @@ -15,6 +15,7 @@ type Peer struct { LastOnlineTime int64 `json:"last_online_time" gorm:"default:0;not null;"` LastOnlineIp string `json:"last_online_ip" gorm:"default:'';not null;"` GroupId uint `json:"group_id" gorm:"default:0;not null;index"` + Alias string `json:"alias" gorm:"default:'';not null;index"` TimeModel }