Commit 7f3bab59 authored by qiuqunfeng's avatar qiuqunfeng
Browse files

Refactor UpdateRule method to improve WAF service rule updates

- Modify the UpdateRule method to assign the RuleCategoryStatus directly to the wafService before updating the database.
- Enhance error handling for the database update operation to ensure clarity in failure cases.
parent 7df18457
......@@ -707,10 +707,11 @@ func (s *wafService) UpdateRule(ctx context.Context, req *RuleRequest) error {
}
} else {
// Update mode if service exists
if err := s.db.Model(wafService).Update("rule_category_status", model.RuleCategoryStatus{
wafService.RuleCategoryStatus = &model.RuleCategoryStatus{
CategoryID: req.CategoryID,
Status: req.Status,
}).Error; err != nil {
}
if err := s.db.Model(wafService).Update("rule_category_status", wafService.RuleCategoryStatus).Error; err != nil {
return fmt.Errorf("failed to update WAF service mode: %v", err)
}
}
......
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