added soft deleted
This commit is contained in:
1 parent
d1a6fcaadc
commit
e0d03730de
36 files changed
+327
-217
No files matched your search
@@ -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
|
||||
|
||||
@@ -104,7 +104,7 @@ func (r *repository) List(ctx context.Context, filter cardpinorders.ListFilter)
|
||||
}
|
||||
|
||||
func buildListQuery(filter cardpinorders.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
conditions := []string{"cpo.deleted_at IS NULL"}
|
||||
|
||||
if filter.Status != nil {
|
||||
args = append(args, *filter.Status)
|
||||
@@ -133,15 +133,11 @@ func buildListQuery(filter cardpinorders.ListFilter) (whereClause string, args [
|
||||
conditions = append(conditions, fmt.Sprintf("cpo.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) (cardpinorders.CardPinOrderDTO, error) {
|
||||
query := `SELECT ` + cardPinOrderSelectColumns + cardPinOrderFromClause + ` WHERE cpo.id = $1`
|
||||
query := `SELECT ` + cardPinOrderSelectColumns + cardPinOrderFromClause + ` WHERE cpo.id = $1 AND cpo.deleted_at IS NULL`
|
||||
return scanCardPinOrderWithJoins(r.client.QueryRow(ctx, query, id))
|
||||
}
|
||||
|
||||
@@ -182,7 +178,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto cardpinorders.Upd
|
||||
query := fmt.Sprintf(`
|
||||
WITH updated AS (
|
||||
UPDATE card_pin_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
|
||||
|
||||
@@ -117,7 +117,7 @@ func (r *repository) List(ctx context.Context, filter cardrekwizit.ListFilter) (
|
||||
}
|
||||
|
||||
func buildListQuery(filter cardrekwizit.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
conditions := []string{"cro.deleted_at IS NULL"}
|
||||
|
||||
if filter.Status != nil {
|
||||
args = append(args, *filter.Status)
|
||||
@@ -146,15 +146,11 @@ func buildListQuery(filter cardrekwizit.ListFilter) (whereClause string, args []
|
||||
conditions = append(conditions, fmt.Sprintf("cro.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) (cardrekwizit.CardRekwizitOrderDTO, error) {
|
||||
query := `SELECT ` + cardRekwizitOrderSelectColumns + cardRekwizitOrderFromClause + ` WHERE cro.id = $1`
|
||||
query := `SELECT ` + cardRekwizitOrderSelectColumns + cardRekwizitOrderFromClause + ` WHERE cro.id = $1 AND cro.deleted_at IS NULL`
|
||||
return scanCardRekwizitOrderWithJoins(r.client.QueryRow(ctx, query, id))
|
||||
}
|
||||
|
||||
@@ -195,7 +191,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto cardrekwizit.Upda
|
||||
query := fmt.Sprintf(`
|
||||
WITH updated AS (
|
||||
UPDATE card_rekwizit_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
|
||||
|
||||
@@ -97,7 +97,7 @@ func (r *repository) List(ctx context.Context, filter cards.ListFilter) (cards.L
|
||||
}
|
||||
|
||||
func buildListQuery(filter cards.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
conditions := []string{"c.deleted_at IS NULL"}
|
||||
|
||||
if filter.UserId != nil {
|
||||
args = append(args, *filter.UserId)
|
||||
@@ -114,15 +114,11 @@ func buildListQuery(filter cards.ListFilter) (whereClause string, args []interfa
|
||||
conditions = append(conditions, fmt.Sprintf("c.type = $%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) (cards.CardDTO, error) {
|
||||
query := `SELECT ` + cardSelectColumns + cardFromClause + ` WHERE c.id = $1`
|
||||
query := `SELECT ` + cardSelectColumns + cardFromClause + ` WHERE c.id = $1 AND c.deleted_at IS NULL`
|
||||
return scanCardWithUser(r.client.QueryRow(ctx, query, id))
|
||||
}
|
||||
|
||||
@@ -162,7 +158,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto cards.UpdateCardD
|
||||
query := fmt.Sprintf(`
|
||||
WITH updated AS (
|
||||
UPDATE cards 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
|
||||
|
||||
@@ -100,7 +100,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto paymentcard.Updat
|
||||
query := fmt.Sprintf(`
|
||||
UPDATE card_types SET
|
||||
price = $1, name = $2, notes = $3, active = $4
|
||||
WHERE id = $5
|
||||
WHERE id = $5 AND deleted_at IS NULL
|
||||
RETURNING %s`, cardReturningColumns)
|
||||
|
||||
item, err := scanPaymentCard(r.client.QueryRow(ctx, query, dto.Price, name, dto.Notes, dto.Active, id))
|
||||
@@ -113,7 +113,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto paymentcard.Updat
|
||||
func (r *repository) UpdateActive(ctx context.Context, id int64, active bool) (paymentcard.PaymentCardDTO, error) {
|
||||
query := fmt.Sprintf(`
|
||||
UPDATE card_types SET active = $1
|
||||
WHERE id = $2
|
||||
WHERE id = $2 AND deleted_at IS NULL
|
||||
RETURNING %s`, cardReturningColumns)
|
||||
|
||||
item, err := scanPaymentCard(r.client.QueryRow(ctx, query, active, id))
|
||||
|
||||
@@ -95,7 +95,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto reasonscard.Updat
|
||||
UPDATE card_states SET
|
||||
price = $1, name = $2, notes = $3, active = $4,
|
||||
updated_at = (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
|
||||
WHERE id = $5
|
||||
WHERE id = $5 AND deleted_at IS NULL
|
||||
RETURNING %s`, reasonReturningColumns)
|
||||
|
||||
item, err := scanReasonCard(r.client.QueryRow(ctx, query, dto.Price, name, dto.Notes, dto.Active, id))
|
||||
|
||||
@@ -135,7 +135,7 @@ func (r *repository) List(ctx context.Context, filter visamaster.ListFilter) (vi
|
||||
}
|
||||
|
||||
func buildListQuery(filter visamaster.ListFilter) (whereClause string, args []interface{}) {
|
||||
var conditions []string
|
||||
conditions := []string{"o.deleted_at IS NULL"}
|
||||
|
||||
if filter.Name != "" {
|
||||
args = append(args, shared.LikePattern(filter.Name))
|
||||
@@ -168,15 +168,11 @@ func buildListQuery(filter visamaster.ListFilter) (whereClause string, args []in
|
||||
conditions = append(conditions, fmt.Sprintf("o.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) (visamaster.VisaMasterPaymentOrderDTO, error) {
|
||||
query := `SELECT ` + orderSelectColumns + orderFromClause + ` WHERE o.id = $1`
|
||||
query := `SELECT ` + orderSelectColumns + orderFromClause + ` WHERE o.id = $1 AND o.deleted_at IS NULL`
|
||||
return scanOrder(r.client.QueryRow(ctx, query, id))
|
||||
}
|
||||
|
||||
@@ -217,7 +213,7 @@ func (r *repository) Update(ctx context.Context, id int64, dto visamaster.Update
|
||||
query := fmt.Sprintf(`
|
||||
WITH updated AS (
|
||||
UPDATE visa_master_payment_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
|
||||
|
||||
Reference in new issue
Block a user