fix: 查询like使用字符串拼接替代concat

This commit is contained in:
TsMask
2025-03-05 17:39:01 +08:00
parent 4e788497d7
commit 0c83bcecc6
25 changed files with 83 additions and 66 deletions

View File

@@ -1,6 +1,7 @@
package repository
import (
"fmt"
"time"
"be.ems/src/framework/database/db"
@@ -25,7 +26,7 @@ func (r NeConfigBackup) SelectByPage(query map[string]string) ([]model.NeConfigB
tx = tx.Where("neId = ?", v)
}
if v, ok := query["name"]; ok && v != "" {
tx = tx.Where("name like concat(concat('%', ?), '%')", v)
tx = tx.Where("name like ?", fmt.Sprintf("%%%s%%", v))
}
// 查询结果

View File

@@ -26,7 +26,7 @@ func (r NeHost) SelectByPage(query map[string]string) ([]model.NeHost, int64) {
tx = tx.Where("group_id = ?", v)
}
if v, ok := query["title"]; ok && v != "" {
tx = tx.Where("title like concat(?, '%')", v)
tx = tx.Where("title like ?", fmt.Sprintf("%s%%", v))
}
// 查询结果

View File

@@ -1,6 +1,7 @@
package repository
import (
"fmt"
"time"
"be.ems/src/framework/database/db"
@@ -25,7 +26,7 @@ func (r NeHostCmd) SelectByPage(query map[string]string) ([]model.NeHostCmd, int
tx = tx.Where("group_id = ?", v)
}
if v, ok := query["title"]; ok && v != "" {
tx = tx.Where("title like concat(?, '%')", v)
tx = tx.Where("title like ?", fmt.Sprintf("%s%%", v))
}
// 查询结果

View File

@@ -1,6 +1,7 @@
package repository
import (
"fmt"
"time"
"be.ems/src/framework/database/db"
@@ -71,7 +72,7 @@ func (r NeInfo) SelectByPage(query map[string]string) ([]model.NeInfo, int64) {
tx = tx.Where("ne_id = ?", v)
}
if v, ok := query["rmUid"]; ok && v != "" {
tx = tx.Where("rmUid like concat(?, '%')", v)
tx = tx.Where("rmUid like ?", fmt.Sprintf("%s%%", v))
}
// 查询结果

View File

@@ -1,6 +1,7 @@
package repository
import (
"fmt"
"time"
"be.ems/src/framework/database/db"
@@ -31,7 +32,7 @@ func (r NeLicense) SelectByPage(query map[string]string) ([]model.NeLicense, int
tx = tx.Where("serial_num = ?", v)
}
if v, ok := query["createBy"]; ok && v != "" {
tx = tx.Where("create_by like concat(?, '%')", v)
tx = tx.Where("create_by like ?", fmt.Sprintf("%s%%", v))
}
// 查询结果
@@ -69,7 +70,7 @@ func (r NeLicense) Select(param model.NeLicense) []model.NeLicense {
tx = tx.Where("expiry_date = ?", param.ExpiryDate)
}
if param.CreateBy != "" {
tx = tx.Where("create_by like concat(?, '%')", param.CreateBy)
tx = tx.Where("create_by like ?", fmt.Sprintf("%s%%", param.CreateBy))
}
// 查询数据

View File

@@ -1,6 +1,7 @@
package repository
import (
"fmt"
"strings"
"time"
@@ -28,10 +29,10 @@ func (r NeSoftware) SelectByPage(query map[string]string) ([]model.NeSoftware, i
}
}
if v, ok := query["name"]; ok && v != "" {
tx = tx.Where("name like concat(?, '%')", v)
tx = tx.Where("name like ?", fmt.Sprintf("%s%%", v))
}
if v, ok := query["version"]; ok && v != "" {
tx = tx.Where("version like concat(?, '%')", v)
tx = tx.Where("version like ?", fmt.Sprintf("%s%%", v))
}
// 查询结果
@@ -69,7 +70,7 @@ func (r NeSoftware) Select(param model.NeSoftware) []model.NeSoftware {
tx = tx.Where("version = ?", param.Version)
}
if param.Name != "" {
tx = tx.Where("name like concat(?, '%')", param.Name)
tx = tx.Where("name like ?", fmt.Sprintf("%s%%", param.Name))
}
// 查询数据

View File

@@ -1,6 +1,7 @@
package repository
import (
"fmt"
"time"
"be.ems/src/framework/database/db"
@@ -25,10 +26,10 @@ func (r NeVersion) SelectByPage(query map[string]string) ([]model.NeVersion, int
tx = tx.Where("ne_id = ?", v)
}
if v, ok := query["version"]; ok && v != "" {
tx = tx.Where("version like concat(?, '%')", v)
tx = tx.Where("version like ?", fmt.Sprintf("%s%%", v))
}
if v, ok := query["path"]; ok && v != "" {
tx = tx.Where("path like concat(?, '%')", v)
tx = tx.Where("path like ?", fmt.Sprintf("%s%%", v))
}
// 查询结果
@@ -63,10 +64,10 @@ func (r NeVersion) Select(param model.NeVersion) []model.NeVersion {
tx = tx.Where("ne_id = ?", param.NeId)
}
if param.Version != "" {
tx = tx.Where("version like concat(?, '%')", param.Version)
tx = tx.Where("version like ?", fmt.Sprintf("%s%%", param.Version))
}
if param.Path != "" {
tx = tx.Where("path like concat(?, '%')", param.Path)
tx = tx.Where("path like ?", fmt.Sprintf("%s%%", param.Path))
}
if param.Status != "" {
tx = tx.Where("status = ?", param.Status)