Skip to content

Commit ade6e63

Browse files
committed
feat(peer): add alias field and support filtering by alias
1 parent 9b769b9 commit ade6e63

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

cmd/apimain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/spf13/cobra"
2424
)
2525

26-
const DatabaseVersion = 264
26+
const DatabaseVersion = 265
2727

2828
// @title 管理系统API
2929
// @version 1.0

http/controller/admin/peer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func (ct *Peer) List(c *gin.Context) {
114114
if query.Ip != "" {
115115
tx.Where("last_online_ip like ?", "%"+query.Ip+"%")
116116
}
117+
if query.Alias != "" {
118+
tx.Where("alias like ?", "%"+query.Alias+"%")
119+
}
117120
})
118121
response.Success(c, res)
119122
}

http/request/admin/peer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type PeerForm struct {
1313
Uuid string `json:"uuid"`
1414
Version string `json:"version"`
1515
GroupId uint `json:"group_id"`
16+
Alias string `json:"alias"`
1617
}
1718

1819
type PeerBatchDeleteForm struct {
@@ -32,6 +33,7 @@ func (f *PeerForm) ToPeer() *model.Peer {
3233
Uuid: f.Uuid,
3334
Version: f.Version,
3435
GroupId: f.GroupId,
36+
Alias: f.Alias,
3537
}
3638
}
3739

@@ -43,6 +45,7 @@ type PeerQuery struct {
4345
Uuids string `json:"uuids" form:"uuids"`
4446
Ip string `json:"ip" form:"ip"`
4547
Username string `json:"username" form:"username"`
48+
Alias string `json:"alias" form:"alias"`
4649
}
4750

4851
type SimpleDataQuery struct {

model/peer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type Peer struct {
1515
LastOnlineTime int64 `json:"last_online_time" gorm:"default:0;not null;"`
1616
LastOnlineIp string `json:"last_online_ip" gorm:"default:'';not null;"`
1717
GroupId uint `json:"group_id" gorm:"default:0;not null;index"`
18+
Alias string `json:"alias" gorm:"default:'';not null;index"`
1819
TimeModel
1920
}
2021

0 commit comments

Comments
 (0)