This commit is contained in:
Daniel 2025-08-09 11:24:44 +08:00
parent 7b3acc642c
commit 580ecd617d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 62 additions and 7 deletions

View file

@ -202,6 +202,7 @@ type View struct {
GroupHidden int `json:"groupHidden"` // 分组是否隐藏0显示1空白隐藏2手动隐藏
}
// GetGroupValue 获取分组视图的分组值。
func (view *View) GetGroupValue() string {
if nil == view.GroupVal {
return ""
@ -209,8 +210,8 @@ func (view *View) GetGroupValue() string {
return view.GroupVal.String(false)
}
// GetGroup 获取指定分组 ID 的分组视图。
func (view *View) GetGroup(groupID string) *View {
// GetGroupByID 获取指定分组 ID 的分组视图。
func (view *View) GetGroupByID(groupID string) *View {
if nil == view.Groups {
return nil
}
@ -222,6 +223,32 @@ func (view *View) GetGroup(groupID string) *View {
return nil
}
// GetGroupByGroupValue 获取指定分组值的分组视图。
func (view *View) GetGroupByGroupValue(groupVal string) *View {
if nil == view.Groups {
return nil
}
for _, group := range view.Groups {
if group.GetGroupValue() == groupVal {
return group
}
}
return nil
}
// RemoveGroupByID 从分组视图列表中移除指定 ID 的分组视图。
func (view *View) RemoveGroupByID(groupID string) {
if nil == view.Groups {
return
}
for i, group := range view.Groups {
if group.ID == groupID {
view.Groups = append(view.Groups[:i], view.Groups[i+1:]...)
return
}
}
}
// GetGroupKey 获取分组视图的分组字段。
func (view *View) GetGroupKey(attrView *AttributeView) (ret *Key) {
if nil == view.Group || "" == view.Group.Field {