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

@@ -21,10 +21,10 @@ func (r SysRole) SelectByPage(query map[string]string) ([]model.SysRole, int64)
tx = tx.Where("del_flag = '0' and role_id > 1")
// 查询条件拼接
if v, ok := query["roleName"]; ok && v != "" {
tx = tx.Where("role_name like concat(?, '%')", v)
tx = tx.Where("role_name like ?", fmt.Sprintf("%s%%", v))
}
if v, ok := query["roleKey"]; ok && v != "" {
tx = tx.Where("role_key like concat(?, '%')", v)
tx = tx.Where("role_key like ?", fmt.Sprintf("%s%%", v))
}
if v, ok := query["statusFlag"]; ok && v != "" {
tx = tx.Where("status_flag = ?", v)
@@ -78,10 +78,10 @@ func (r SysRole) Select(sysRole model.SysRole) []model.SysRole {
tx = tx.Where("del_flag = '0'")
// 查询条件拼接
if sysRole.RoleKey != "" {
tx = tx.Where("role_key like concat(?, '%')", sysRole.RoleKey)
tx = tx.Where("role_key like ?", fmt.Sprintf("%s%%", sysRole.RoleKey))
}
if sysRole.RoleName != "" {
tx = tx.Where("role_name like concat(?, '%')", sysRole.RoleName)
tx = tx.Where("role_name like ?", fmt.Sprintf("%s%%", sysRole.RoleName))
}
if sysRole.StatusFlag != "" {
tx = tx.Where("status_flag = ?", sysRole.StatusFlag)