added soft deleted
This commit is contained in:
1 parent
d1a6fcaadc
commit
e0d03730de
36 files changed
+327
-217
No files matched your search
@@ -75,7 +75,7 @@ func (r *repository) List(ctx context.Context, filter loansrepayment.ListFilter)
|
||||
}
|
||||
|
||||
func buildListQuery(filter loansrepayment.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
conditions := []string{"l.deleted_at IS NULL"}
|
||||
if filter.PassportId != "" {
|
||||
args = append(args, shared.LikePattern(filter.PassportId))
|
||||
conditions = append(conditions, fmt.Sprintf("l.passport_id ILIKE $%d", len(args)))
|
||||
@@ -91,15 +91,11 @@ func buildListQuery(filter loansrepayment.ListFilter) (whereClause string, args
|
||||
conditions = append(conditions, rbac.UserInBranchSQL("l.user_id", len(args)))
|
||||
}
|
||||
|
||||
if len(conditions) == 0 {
|
||||
return "", args
|
||||
}
|
||||
|
||||
return " WHERE " + strings.Join(conditions, " AND "), args
|
||||
}
|
||||
|
||||
func (r *repository) GetByID(ctx context.Context, id int64) (loansrepayment.LoanRepaymentDTO, error) {
|
||||
query := `SELECT ` + loanColumns + loanFromClause + ` WHERE l.id = $1`
|
||||
query := `SELECT ` + loanColumns + loanFromClause + ` WHERE l.id = $1 AND l.deleted_at IS NULL`
|
||||
return scanLoanRepayment(r.client.QueryRow(ctx, query, id))
|
||||
}
|
||||
|
||||
@@ -123,7 +119,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto loansrepayment.Up
|
||||
UPDATE loans SET
|
||||
user_id = $1, passport_serie = $2, passport_id = $3, account_number = $4,
|
||||
updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
|
||||
WHERE id = $5
|
||||
WHERE id = $5 AND deleted_at IS NULL
|
||||
RETURNING ` + loanReturningColumns + `
|
||||
)
|
||||
SELECT ` + loanColumns + `
|
||||
|
||||
Reference in new issue
Block a user