added soft deleted
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:
guwandyk committed 2026-09-05 17:58:23 +05:00
1 parent d1a6fcaadc
commit e0d03730de
36 files changed
+327 -217

No files matched your search

+3 -6
View File
@@ -84,7 +84,7 @@ func (r *repository) List(ctx context.Context, filter currency.ListFilter) (curr
}
func buildListQuery(filter currency.ListFilter) (whereClause string, args []interface{}) {
var conditions []string
conditions := []string{"c.deleted_at IS NULL"}
if filter.Search != "" {
args = append(args, shared.LikePattern(filter.Search))
@@ -104,14 +104,11 @@ func buildListQuery(filter currency.ListFilter) (whereClause string, args []inte
conditions = append(conditions, fmt.Sprintf("c.currency_to = $%d", len(args)))
}
if len(conditions) == 0 {
return "", args
}
return " WHERE " + strings.Join(conditions, " AND "), args
}
func (r *repository) GetByID(ctx context.Context, id int64) (currency.CurrencyDTO, error) {
query := `SELECT ` + currencySelectColumns + currencyFromClause + ` WHERE c.id = $1`
query := `SELECT ` + currencySelectColumns + currencyFromClause + ` WHERE c.id = $1 AND c.deleted_at IS NULL`
return scanCurrencyWithUsers(r.client.QueryRow(ctx, query, id))
}
@@ -139,7 +136,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto currency.UpdateCu
currency_from = $1, currency_to = $2, value = $3::numeric,
updated_by = $4,
updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
WHERE id = $5
WHERE id = $5 AND deleted_at IS NULL
RETURNING ` + currencyColumnsSQL + `
)
SELECT ` + currencySelectColumns + `