fix: 查询like使用字符串拼接替代concat
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"be.ems/src/framework/database/db"
|
||||
@@ -19,13 +20,13 @@ func (r SysJob) SelectByPage(query map[string]string) ([]model.SysJob, int64) {
|
||||
tx := db.DB("").Model(&model.SysJob{})
|
||||
// 查询条件拼接
|
||||
if v, ok := query["jobName"]; ok && v != "" {
|
||||
tx = tx.Where("job_name like concat(?, '%')", v)
|
||||
tx = tx.Where("job_name like ?", fmt.Sprintf("%s%%", v))
|
||||
}
|
||||
if v, ok := query["jobGroup"]; ok && v != "" {
|
||||
tx = tx.Where("job_group = ?", v)
|
||||
}
|
||||
if v, ok := query["invokeTarget"]; ok && v != "" {
|
||||
tx = tx.Where("invoke_target like concat(?, '%')", v)
|
||||
tx = tx.Where("invoke_target like ?", fmt.Sprintf("%s%%", v))
|
||||
}
|
||||
if v, ok := query["statusFlag"]; ok && v != "" {
|
||||
tx = tx.Where("status_flag = ?", v)
|
||||
@@ -56,13 +57,13 @@ func (r SysJob) Select(sysJob model.SysJob) []model.SysJob {
|
||||
tx := db.DB("").Model(&model.SysJob{})
|
||||
// 查询条件拼接
|
||||
if sysJob.JobName != "" {
|
||||
tx = tx.Where("job_name like concat(?, '%')", sysJob.JobName)
|
||||
tx = tx.Where("job_name like ?", fmt.Sprintf("%s%%", sysJob.JobName))
|
||||
}
|
||||
if sysJob.JobGroup != "" {
|
||||
tx = tx.Where("job_group = ?", sysJob.JobGroup)
|
||||
}
|
||||
if sysJob.InvokeTarget != "" {
|
||||
tx = tx.Where("invoke_target like concat(?, '%')", sysJob.InvokeTarget)
|
||||
tx = tx.Where("invoke_target like ?", fmt.Sprintf("%s%%", sysJob.InvokeTarget))
|
||||
}
|
||||
if sysJob.StatusFlag != "" {
|
||||
tx = tx.Where("status_flag = ?", sysJob.StatusFlag)
|
||||
|
||||
@@ -28,7 +28,7 @@ func (r SysJobLog) SelectByPage(query map[string]string) ([]model.SysJobLog, int
|
||||
tx = tx.Where("status_flag = ?", v)
|
||||
}
|
||||
if v, ok := query["invokeTarget"]; ok && v != "" {
|
||||
tx = tx.Where("invoke_target like concat(?, '%')", v)
|
||||
tx = tx.Where("invoke_target like ?", fmt.Sprintf("%s%%", v))
|
||||
}
|
||||
if v, ok := query["beginTime"]; ok && v != "" {
|
||||
if len(v) == 10 {
|
||||
@@ -72,7 +72,7 @@ func (r SysJobLog) Select(sysJobLog model.SysJobLog) []model.SysJobLog {
|
||||
tx := db.DB("").Model(&model.SysJobLog{})
|
||||
// 查询条件拼接
|
||||
if sysJobLog.JobName != "" {
|
||||
tx = tx.Where("job_name like concat(?, '%')", sysJobLog.JobName)
|
||||
tx = tx.Where("job_name like ?", fmt.Sprintf("%s%%", sysJobLog.JobName))
|
||||
}
|
||||
if sysJobLog.JobGroup != "" {
|
||||
tx = tx.Where("job_group = ?", sysJobLog.JobGroup)
|
||||
@@ -81,7 +81,7 @@ func (r SysJobLog) Select(sysJobLog model.SysJobLog) []model.SysJobLog {
|
||||
tx = tx.Where("status_flag = ?", sysJobLog.StatusFlag)
|
||||
}
|
||||
if sysJobLog.InvokeTarget != "" {
|
||||
tx = tx.Where("invoke_target like concat(?, '%')", sysJobLog.InvokeTarget)
|
||||
tx = tx.Where("invoke_target like ?", fmt.Sprintf("%s%%", sysJobLog.InvokeTarget))
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
|
||||
Reference in New Issue
Block a user