feat: konfigurasi sistem toggle pemakaian pakan ovk negatif

This commit is contained in:
Adnan Zahir
2026-04-28 10:51:54 +07:00
parent 1d6e1fa5be
commit 6f6541d4c1
15 changed files with 347 additions and 1 deletions
@@ -264,6 +264,18 @@ func (s productService) GetAll(c *fiber.Ctx, params *validation.Query) ([]entity
db = db.Where("NOT "+existsQuery, entity.FlagableTypeProduct, depletionProductFlags)
}
}
if strings.TrimSpace(params.Flags) != "" {
cleanFlags := utils.ParseFlags(params.Flags)
if len(cleanFlags) > 0 {
db = db.Where(`
EXISTS (
SELECT 1 FROM flags f
WHERE f.flagable_type = ?
AND f.flagable_id = products.id
AND UPPER(f.name) IN ?
)`, entity.FlagableTypeProduct, cleanFlags)
}
}
return db.Order("created_at DESC").Order("updated_at DESC")
})
@@ -46,4 +46,5 @@ type Query struct {
ProductCategoryID int `query:"product_category_id" validate:"omitempty,number,min=1"`
IsDepletion *bool `query:"is_depletion" validate:"omitempty"`
IncludeAll *bool `query:"include_all" validate:"omitempty"`
Flags string `query:"flags" validate:"omitempty,max=200"`
}