Add a synthetic "All" category to getappcategories
The mobile app needs an "All" tile to browse every product regardless of category. Rather than inserting a real app_category row (which would break once any category-scoped product filter treats it as an actual, empty category), the service now prepends a synthetic entry with categoryid=0 — reusing the "0 = no category filter" convention GetAllProducts already implements in FetchFilteredProducts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,5 +48,25 @@ func (s *utilsService) GetAppConfig(configID int) (models.Appconfig, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *utilsService) GetAppCategory() ([]models.AppCategory, error) {
|
func (s *utilsService) GetAppCategory() ([]models.AppCategory, error) {
|
||||||
return s.repo.GetAppCategory()
|
categories, err := s.repo.GetAppCategory()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// "All" is a synthetic pseudo-category, not a real app_category row — it
|
||||||
|
// must never be inserted into app_category itself, since product-listing
|
||||||
|
// filters (e.g. ProductController.GetAllProducts) already treat
|
||||||
|
// categoryid=0 as "no category filter". Keeping this row's id at 0 reuses
|
||||||
|
// that existing convention instead of adding a new one.
|
||||||
|
all := models.AppCategory{
|
||||||
|
Categoryid: 0,
|
||||||
|
Categoryname: "All",
|
||||||
|
Categorytype: 7,
|
||||||
|
Sortorder: 0,
|
||||||
|
Crossaxis: 1,
|
||||||
|
Mainaxis: 1,
|
||||||
|
Status: "Active",
|
||||||
|
}
|
||||||
|
|
||||||
|
return append([]models.AppCategory{all}, categories...), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user