ch some
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

This commit is contained in:
2026-09-04 19:33:26 +05:00
parent 28509eb4ca
commit d1a6fcaadc
102 changed files with 2089 additions and 1957 deletions

View File

@@ -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))