fix: 查询like使用字符串拼接替代concat
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user