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

@@ -20,10 +20,10 @@ func (r SysLogLogin) SelectByPage(query map[string]string, dataScopeSQL string)
tx := db.DB("").Model(&model.SysLogLogin{})
// 查询条件拼接
if v, ok := query["loginIp"]; ok && v != "" {
tx = tx.Where("login_ip like concat(?, '%')", v)
tx = tx.Where("login_ip like ?", fmt.Sprintf("%s%%", v))
}
if v, ok := query["userName"]; ok && v != "" {
tx = tx.Where("user_name like concat(?, '%')", v)
tx = tx.Where("user_name like ?", fmt.Sprintf("%s%%", v))
}
if v, ok := query["statusFlag"]; ok && v != "" {
tx = tx.Where("status_flag = ?", v)