ch some
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"online-back/internal/identity/role"
|
||||
"online-back/internal/shared"
|
||||
"online-back/pkg/client/postgresql"
|
||||
"online-back/pkg/logging"
|
||||
"online-back/pkg/repository/genericrepo"
|
||||
@@ -46,7 +47,7 @@ func (r *repository) List(ctx context.Context, filter role.ListFilter) (role.Lis
|
||||
func buildListQuery(filter role.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
if filter.RoleName != "" {
|
||||
args = append(args, likePattern(filter.RoleName))
|
||||
args = append(args, shared.LikePattern(filter.RoleName))
|
||||
n := len(args)
|
||||
conditions = append(conditions, fmt.Sprintf(`r.name ILIKE $%d`, n))
|
||||
}
|
||||
@@ -58,13 +59,6 @@ func buildListQuery(filter role.ListFilter) (whereClause string, args []interfac
|
||||
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) (role.RoleDTO, error) {
|
||||
return r.generic.GetByID(ctx, id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user