ch some
This commit is contained in:
1 parent
28509eb4ca
commit
d1a6fcaadc
102 files changed
+2089
-1957
No files matched your search
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"online-back/internal/cards/reasonscard"
|
||||
"online-back/internal/cards/shared"
|
||||
"online-back/internal/shared"
|
||||
"online-back/pkg/client/postgresql"
|
||||
"online-back/pkg/logging"
|
||||
"online-back/pkg/repository/genericrepo"
|
||||
@@ -48,7 +48,7 @@ func (r *repository) List(ctx context.Context, filter reasonscard.ListFilter) (r
|
||||
func buildListQuery(filter reasonscard.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
if filter.ReasonName != "" {
|
||||
args = append(args, likePattern(filter.ReasonName))
|
||||
args = append(args, shared.LikePattern(filter.ReasonName))
|
||||
n := len(args)
|
||||
conditions = append(conditions, fmt.Sprintf(`(
|
||||
r.name->>'en' ILIKE $%[1]d OR r.name->>'ru' ILIKE $%[1]d OR r.name->>'tm' ILIKE $%[1]d
|
||||
@@ -62,13 +62,6 @@ func buildListQuery(filter reasonscard.ListFilter) (whereClause string, args []i
|
||||
return " WHERE " + strings.Join(conditions, " AND "), args
|
||||
}
|
||||
|
||||
func likePattern(term string) string {
|
||||
term = strings.ReplaceAll(term, `\`, `\\`)
|
||||
term = strings.ReplaceAll(term, `%`, `\%`)
|
||||
term = strings.ReplaceAll(term, `_`, `\_`)
|
||||
return "%" + term + "%"
|
||||
}
|
||||
|
||||
func (r *repository) GetByID(ctx context.Context, id int64) (reasonscard.ReasonCardDTO, error) {
|
||||
return r.generic.GetByID(ctx, id)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user