ch some
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"online-back/internal/identity/rbac"
|
||||
"online-back/internal/lending/loansrepayment"
|
||||
"online-back/internal/lending/shared"
|
||||
"online-back/internal/shared"
|
||||
"online-back/pkg/client/postgresql"
|
||||
"online-back/pkg/logging"
|
||||
"online-back/pkg/repository/genericrepo"
|
||||
@@ -77,7 +77,7 @@ func (r *repository) List(ctx context.Context, filter loansrepayment.ListFilter)
|
||||
func buildListQuery(filter loansrepayment.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
if filter.PassportId != "" {
|
||||
args = append(args, likePattern(filter.PassportId))
|
||||
args = append(args, shared.LikePattern(filter.PassportId))
|
||||
conditions = append(conditions, fmt.Sprintf("l.passport_id ILIKE $%d", len(args)))
|
||||
}
|
||||
|
||||
@@ -98,13 +98,6 @@ func buildListQuery(filter loansrepayment.ListFilter) (whereClause string, args
|
||||
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) (loansrepayment.LoanRepaymentDTO, error) {
|
||||
query := `SELECT ` + loanColumns + loanFromClause + ` WHERE l.id = $1`
|
||||
return scanLoanRepayment(r.client.QueryRow(ctx, query, id))
|
||||
|
||||
Reference in New Issue
Block a user