mock shop page: can delete listings
This commit is contained in:
@@ -365,6 +365,41 @@ func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *Store) DeleteMockListing(ctx context.Context, ids AccountShopListingIDs) error {
|
||||
_, listingTableName, err := getMockShopAndListingsTableNames(ids.Platform)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tag, err := db.db.Exec(
|
||||
ctx,
|
||||
fmt.Sprintf(
|
||||
`
|
||||
DELETE FROM
|
||||
%s
|
||||
WHERE
|
||||
account_id = @account_id
|
||||
AND shop_id = @shop_id
|
||||
AND listing_id = @listing_id
|
||||
`,
|
||||
listingTableName,
|
||||
),
|
||||
pgx.NamedArgs{
|
||||
"account_id": ids.AccountID,
|
||||
"shop_id": ids.ShopID,
|
||||
"listing_id": ids.ListingID,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to perform query: %w", err)
|
||||
}
|
||||
if tag.RowsAffected() == 0 {
|
||||
return fmt.Errorf("%w: listing not found", consts.ErrNotFound)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *Store) ListMockListingsForShop(ctx context.Context, acctID int64, platform Platform, shopID string) ([]MockListing, error) {
|
||||
shopTableName, listingsTableName, err := getMockShopAndListingsTableNames(platform)
|
||||
if err != nil {
|
||||
|
||||
@@ -72,6 +72,10 @@ func (v_ctx *StoreWithContext) UpdateMockListing(listing MockListing) error {
|
||||
return v_ctx.Store.UpdateMockListing(v_ctx.ctx, listing)
|
||||
}
|
||||
|
||||
func (v_ctx *StoreWithContext) DeleteMockListing(ids AccountShopListingIDs) error {
|
||||
return v_ctx.Store.DeleteMockListing(v_ctx.ctx, ids)
|
||||
}
|
||||
|
||||
func (v_ctx *StoreWithContext) ListMockListingsForShop(acctID int64, platform Platform, shopID string) ([]MockListing, error) {
|
||||
return v_ctx.Store.ListMockListingsForShop(v_ctx.ctx, acctID, platform, shopID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user