fix(rule): add type and default fields to rule group model and update related logic
This commit is contained in:
parent
94d316ec52
commit
979e39b9e5
@ -515,9 +515,11 @@ type (
|
|||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
|
Type string `json:"type"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
Rules string `json:"rules"`
|
Rules string `json:"rules"`
|
||||||
Enable bool `json:"enable"`
|
Enable bool `json:"enable"`
|
||||||
|
Default bool `json:"default"`
|
||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at"`
|
UpdatedAt int64 `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,9 +38,11 @@ func (l *GetRuleGroupListLogic) GetRuleGroupList() (resp *types.GetRuleGroupResp
|
|||||||
Id: v.Id,
|
Id: v.Id,
|
||||||
Icon: v.Icon,
|
Icon: v.Icon,
|
||||||
Name: v.Name,
|
Name: v.Name,
|
||||||
|
Type: v.Type,
|
||||||
Tags: strings.Split(v.Tags, ","),
|
Tags: strings.Split(v.Tags, ","),
|
||||||
Rules: v.Rules,
|
Rules: v.Rules,
|
||||||
Enable: v.Enable,
|
Enable: v.Enable,
|
||||||
|
Default: v.Default,
|
||||||
CreatedAt: v.CreatedAt.UnixMilli(),
|
CreatedAt: v.CreatedAt.UnixMilli(),
|
||||||
UpdatedAt: v.UpdatedAt.UnixMilli(),
|
UpdatedAt: v.UpdatedAt.UnixMilli(),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -283,10 +283,10 @@ func (m *customServerModel) FindServersByTag(ctx context.Context, tag string) ([
|
|||||||
func (m *customServerModel) SetDefaultRuleGroup(ctx context.Context, id int64) error {
|
func (m *customServerModel) SetDefaultRuleGroup(ctx context.Context, id int64) error {
|
||||||
return m.ExecCtx(ctx, func(conn *gorm.DB) error {
|
return m.ExecCtx(ctx, func(conn *gorm.DB) error {
|
||||||
// Reset all groups to not default
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
// Set the specified group as default
|
// 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))
|
}, cacheServerRuleGroupAllKeys, fmt.Sprintf("cache:serverRuleGroup:%v", id))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1560,9 +1560,11 @@ type ServerRuleGroup struct {
|
|||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
|
Type string `json:"type"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
Rules string `json:"rules"`
|
Rules string `json:"rules"`
|
||||||
Enable bool `json:"enable"`
|
Enable bool `json:"enable"`
|
||||||
|
Default bool `json:"default"`
|
||||||
CreatedAt int64 `json:"created_at"`
|
CreatedAt int64 `json:"created_at"`
|
||||||
UpdatedAt int64 `json:"updated_at"`
|
UpdatedAt int64 `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user