|
@@ -8,6 +8,7 @@ import (
|
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/model"
|
|
|
"gorm.io/gorm"
|
|
|
"math"
|
|
|
+ "strings"
|
|
|
)
|
|
|
|
|
|
type GatewayGroupRepository interface {
|
|
@@ -107,8 +108,10 @@ func (r *gatewayGroupRepository) GetGatewayGroupList(ctx context.Context,req v1.
|
|
|
query := r.db.WithContext(ctx).Model(&model.GatewayGroup{})
|
|
|
|
|
|
if req.Name != "" {
|
|
|
+ // 去除后所有的空白字符(包括空格、制表符\t、换行符等)
|
|
|
+ trimmedName := strings.TrimSpace(req.Name)
|
|
|
// 使用 LIKE 进行模糊匹配
|
|
|
- query = query.Where("name LIKE ?", fmt.Sprintf("%%%s%%", req.Name))
|
|
|
+ query = query.Where("name LIKE CONCAT('%', ?, '%')", trimmedName)
|
|
|
}
|
|
|
// 如果 HostId 被提供了,添加一个精确匹配条件
|
|
|
if req.HostId != 0 {
|