insert prices change
This commit is contained in:
parent
db9684debc
commit
544c5348f1
3 changed files with 10 additions and 10 deletions
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type Prices interface {
|
||||
insertPrices(ctx context.Context, prices []Price) error
|
||||
insertPrices(ctx context.Context, now time.Time, updatedAt sql.NullTime, prices []Price) error
|
||||
getPricesWithDays(ctx context.Context, userId int64, days time.Time) ([]Price, error)
|
||||
getDistinctPrices(ctx context.Context, userId int64, merchUuid string, days time.Time) ([]Price, error)
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ type Prices interface {
|
|||
deleteZeroPrices(ctx context.Context, userId int64, now sql.NullTime, list []int64) error
|
||||
}
|
||||
|
||||
func (r *repo) insertPrices(ctx context.Context, prices []Price) error {
|
||||
func (r *repo) insertPrices(ctx context.Context, now time.Time, updatedAt sql.NullTime, prices []Price) error {
|
||||
q := `
|
||||
INSERT INTO merch_prices (created_at, updated_at, merch_id, origin_id, price)
|
||||
SELECT $1, $2, src.merch_id, src.origin_id, src.price
|
||||
|
|
@ -40,7 +40,7 @@ func (r *repo) insertPrices(ctx context.Context, prices []Price) error {
|
|||
priceValues = append(priceValues, price.Price)
|
||||
}
|
||||
|
||||
_, err := r.db.Exec(ctx, q, merchIds, originIds, priceValues)
|
||||
_, err := r.db.Exec(ctx, q, now, updatedAt, merchIds, originIds, priceValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue