fix(rule): add type and default fields to rule group model and update related logic

This commit is contained in:
Chang lue Tsen
2025-07-16 12:46:47 -04:00
committed by Leif Draven
parent 94d316ec52
commit 979e39b9e5
4 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -283,10 +283,10 @@ func (m *customServerModel) FindServersByTag(ctx context.Context, tag string) ([
func (m *customServerModel) SetDefaultRuleGroup(ctx context.Context, id int64) error {
return m.ExecCtx(ctx, func(conn *gorm.DB) error {
// Reset all groups to not default
if err := conn.Model(&RuleGroup{}).Update("default", false).Error; err != nil {
if err := conn.Model(&RuleGroup{}).Where("`id` != ?", id).Update("default", false).Error; err != nil {
return err
}
// Set the specified group as default
return conn.Model(&RuleGroup{}).Where("id = ?", id).Update("default", true).Error
return conn.Model(&RuleGroup{}).Where("`id` = ?", id).Update("default", true).Error
}, cacheServerRuleGroupAllKeys, fmt.Sprintf("cache:serverRuleGroup:%v", id))
}