fix search list daily checklist

This commit is contained in:
giovanni
2026-01-30 11:49:13 +07:00
parent 616250d38b
commit 703c1548c9
@@ -3,6 +3,7 @@ package service
import (
"errors"
"math"
"regexp"
"sort"
"strconv"
"strings"
@@ -259,8 +260,9 @@ func (s dailyChecklistService) GetAll(c *fiber.Ctx, params *validation.Query) ([
}
if params.Search != "" {
like := "%" + params.Search + "%"
db = db.Where("(k.name ILIKE ? OR dc.category::text ILIKE ?)", like, like)
re := regexp.MustCompile("[^a-zA-Z0-9]")
like := re.ReplaceAll([]byte("%"+params.Search+"%"), []byte(""))
db = db.Where("(regexp_replace(k.name, '[^a-zA-Z0-9]', '', 'g') ILIKE ? OR regexp_replace(dc.category::text, '[^a-zA-Z0-9]', '', 'g') ILIKE ?)", string(like), string(like))
}
countDB := db.Session(&gorm.Session{})