mock shop page: can delete listings

This commit is contained in:
2026-02-05 17:18:56 -07:00
parent e7f39d69b3
commit 0e36012e6d
6 changed files with 163 additions and 28 deletions
+35
View File
@@ -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 {