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 -7
View File
@@ -123,7 +123,7 @@ func (r *repository) List(ctx context.Context, filter cardorder.ListFilter) (car
}
func buildListQuery(filter cardorder.ListFilter) (whereClause string, args []interface{}) {
var conditions []string
conditions := []string{"co.deleted_at IS NULL"}
if filter.Status != nil {
args = append(args, *filter.Status)
@@ -157,15 +157,11 @@ func buildListQuery(filter cardorder.ListFilter) (whereClause string, args []int
conditions = append(conditions, fmt.Sprintf("co.region = $%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) (cardorder.CardOrderDTO, error) {
query := `SELECT ` + cardOrderSelectColumns + cardOrderFromClause + ` WHERE co.id = $1`
query := `SELECT ` + cardOrderSelectColumns + cardOrderFromClause + ` WHERE co.id = $1 AND co.deleted_at IS NULL`
return scanCardOrderWithJoins(r.client.QueryRow(ctx, query, id))
}
@@ -207,7 +203,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto cardorder.UpdateC
query := fmt.Sprintf(`
WITH updated AS (
UPDATE card_orders SET %s, updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
WHERE id = $%d
WHERE id = $%d AND deleted_at IS NULL
RETURNING %s
)
SELECT %s