fix on shelf

This commit is contained in:
2026-08-31 15:51:36 +05:30
parent 4bce5ac854
commit d55f101834
11 changed files with 704 additions and 55 deletions

View File

@@ -854,3 +854,28 @@ func (ctl *ProductController) UnpublishProduct(c *fiber.Ctx) error {
"details": fiber.Map{"productid": input.Productid, "outlets": outlets},
})
}
// RelinkCatalogue repairs a tenant's pointers back into the global catalogue.
//
// Defaults to a DRY RUN. The pass rewrites the column that decides what a
// browse screen claims a shop already holds, and clearing a link is not
// reversible from the outside — so the whole plan should be readable before any
// of it happens. Pass `apply=true` to write.
func (ctl *ProductController) RelinkCatalogue(c *fiber.Ctx) error {
tenantID, _ := strconv.Atoi(c.Query("tenantid", "0"))
if tenantID <= 0 {
return c.Status(http.StatusBadRequest).JSON(fiber.Map{
"code": http.StatusBadRequest,
"message": "tenantid is required — this repairs one merchant's links, not the platform's",
"status": false,
})
}
// Anything but an explicit `apply=true` is a dry run, including a typo.
apply := c.Query("apply", "") == "true"
report, err := ctl.productService.RelinkCatalogue(tenantID, !apply)
if err != nil {
return c.JSON(fiber.Map{"code": http.StatusInternalServerError, "message": err.Error(), "status": false})
}
return c.JSON(fiber.Map{"code": 200, "message": "Success", "status": true, "details": report})
}