mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-29 19:40:25 +08:00
服务列表可以搜索端口号
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"github.com/iwind/TeaGo/rands"
|
"github.com/iwind/TeaGo/rands"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -640,9 +641,15 @@ func (this *ServerDAO) CountAllEnabledServersMatch(tx *dbs.Tx, groupId int64, ke
|
|||||||
Param("groupId", numberutils.FormatInt64(groupId))
|
Param("groupId", numberutils.FormatInt64(groupId))
|
||||||
}
|
}
|
||||||
if len(keyword) > 0 {
|
if len(keyword) > 0 {
|
||||||
|
if regexp.MustCompile(`^\d+$`).MatchString(keyword) {
|
||||||
|
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword OR JSON_CONTAINS(http, :portRange, '$.listen') OR JSON_CONTAINS(https, :portRange, '$.listen') OR JSON_CONTAINS(tcp, :portRange, '$.listen') OR JSON_CONTAINS(tls, :portRange, '$.listen'))").
|
||||||
|
Param("portRange", maps.Map{"portRange": keyword}.AsJSON()).
|
||||||
|
Param("keyword", "%"+keyword+"%")
|
||||||
|
} else {
|
||||||
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword)").
|
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword)").
|
||||||
Param("keyword", "%"+keyword+"%")
|
Param("keyword", "%"+keyword+"%")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if userId > 0 {
|
if userId > 0 {
|
||||||
query.Attr("userId", userId)
|
query.Attr("userId", userId)
|
||||||
}
|
}
|
||||||
@@ -674,9 +681,14 @@ func (this *ServerDAO) ListEnabledServersMatch(tx *dbs.Tx, offset int64, size in
|
|||||||
Param("groupId", numberutils.FormatInt64(groupId))
|
Param("groupId", numberutils.FormatInt64(groupId))
|
||||||
}
|
}
|
||||||
if len(keyword) > 0 {
|
if len(keyword) > 0 {
|
||||||
|
if regexp.MustCompile(`^\d+$`).MatchString(keyword) {
|
||||||
|
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword OR JSON_CONTAINS(http, :portRange, '$.listen') OR JSON_CONTAINS(https, :portRange, '$.listen') OR JSON_CONTAINS(tcp, :portRange, '$.listen') OR JSON_CONTAINS(tls, :portRange, '$.listen'))").
|
||||||
|
Param("portRange", string(maps.Map{"portRange": keyword}.AsJSON()))
|
||||||
|
} else {
|
||||||
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword)").
|
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword)").
|
||||||
Param("keyword", "%"+keyword+"%")
|
Param("keyword", "%"+keyword+"%")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if userId > 0 {
|
if userId > 0 {
|
||||||
query.Attr("userId", userId)
|
query.Attr("userId", userId)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user