fix(rule): add type and default fields to rule group model and update related logic
This commit is contained in:
committed by
Leif Draven
parent
94d316ec52
commit
979e39b9e5
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user