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,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)