feat: add type and default fields to rule group requests and update related logic

This commit is contained in:
Chang lue Tsen
2025-07-15 13:32:08 -04:00
committed by Leif Draven
parent 40c24fbc85
commit 994cc4bebb
11 changed files with 62 additions and 37 deletions
@@ -55,11 +55,13 @@ func (l *CreateRuleGroupLogic) CreateRuleGroup(req *types.CreateRuleGroupRequest
}
err = l.svcCtx.ServerModel.InsertRuleGroup(l.ctx, &server.RuleGroup{
Name: req.Name,
Icon: req.Icon,
Tags: tool.StringSliceToString(req.Tags),
Rules: strings.Join(rs, "\n"),
Enable: req.Enable,
Name: req.Name,
Icon: req.Icon,
Type: req.Type,
Tags: tool.StringSliceToString(req.Tags),
Rules: strings.Join(rs, "\n"),
Default: req.Default,
Enable: req.Enable,
})
if err != nil {
l.Errorw("[CreateRuleGroup] Insert Database Error: ", logger.Field("error", err.Error()))
@@ -36,12 +36,14 @@ func (l *UpdateRuleGroupLogic) UpdateRuleGroup(req *types.UpdateRuleGroupRequest
return err
}
err = l.svcCtx.ServerModel.UpdateRuleGroup(l.ctx, &server.RuleGroup{
Id: req.Id,
Icon: req.Icon,
Name: req.Name,
Tags: tool.StringSliceToString(req.Tags),
Rules: strings.Join(rs, "\n"),
Enable: req.Enable,
Id: req.Id,
Icon: req.Icon,
Type: req.Type,
Name: req.Name,
Tags: tool.StringSliceToString(req.Tags),
Rules: strings.Join(rs, "\n"),
Default: req.Default,
Enable: req.Enable,
})
if err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.DatabaseUpdateError), err.Error())