feat(category): update list filter category

This commit is contained in:
Efril
2026-08-06 21:21:41 +07:00
parent b9ac97178f
commit a7c2d6cbb3
5 changed files with 34 additions and 0 deletions
+7
View File
@@ -196,6 +196,13 @@ func (h *CategoryHandler) ListCategories(c *gin.Context) {
req.ParentID = &parentID
}
}
// type=parent -> top level categories only
// type=child -> leaf categories (sub categories + top level ones without children)
if categoryType := c.Query("type"); categoryType != "" {
req.Type = categoryType
}
validationError, validationErrorCode := h.categoryValidator.ValidateListCategoriesRequest(req)
if validationError != nil {
logger.FromContext(ctx).WithError(validationError).Error("CategoryHandler::ListCategories -> request validation failed")