Commit ef401310 authored by qiuqunfeng's avatar qiuqunfeng
Browse files

Refactor ListRules method to return structured response for rule groups

- Introduce a new response structure to encapsulate rule group items
- Map existing rules to the new response format, including category details
- Ensure consistent response format for improved API usability
parent c5077443
......@@ -156,7 +156,20 @@ func (c *WafController) ListRules(ctx *gin.Context) {
utils.AssembleResponse(ctx, nil, err)
return
}
utils.AssembleResponse(ctx, rules, nil)
type resp struct {
Items []service.RuleGroupResp `json:"items"`
}
items := []service.RuleGroupResp{}
for _, rule := range rules {
items = append(items, service.RuleGroupResp{
CategoryID: rule.CategoryID,
Status: rule.Status,
Category: rule.Category,
Description: rule.Description,
})
}
utils.AssembleResponse(ctx, resp{Items: items}, nil)
}
func (c *WafController) SaveRuleCategoryToDB(ctx *gin.Context) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment