enhance endpoint query

This commit is contained in:
Ulric Qin 2020-05-09 23:44:55 +08:00
parent 275ecdeacc
commit 6907ffa56c
1 changed files with 10 additions and 4 deletions

View File

@ -49,8 +49,11 @@ func buildEndpointWhere(query, batch, field string) *xorm.Session {
session := DB["mon"].Table(new(Endpoint))
if batch == "" && query != "" {
q := "%" + query + "%"
session = session.Where("ident like ? or alias like ?", q, q)
arr := strings.Fields(query)
for i := 0; i < len(arr); i++ {
q := "%" + arr[i] + "%"
session = session.Where("ident like ? or alias like ?", q, q)
}
}
if batch != "" {
@ -141,8 +144,11 @@ func buildEndpointUnderNodeWhere(leafids []int64, query, batch, field string) *x
session := DB["mon"].Where("id in (select endpoint_id from node_endpoint where node_id in (" + str.IdsString(leafids) + "))")
if batch == "" && query != "" {
q := "%" + query + "%"
session = session.Where("ident like ? or alias like ?", q, q)
arr := strings.Fields(query)
for i := 0; i < len(arr); i++ {
q := "%" + arr[i] + "%"
session = session.Where("ident like ? or alias like ?", q, q)
}
}
if batch != "" {