i got this structures: type permissonsLabels struct { ResourceCode string…
- User
i got this structures:
type permissonsLabels struct { ResourceCode string gorm:"column:resource_code" GroupTitle string gorm:"column:group_title" PermissionsIDs string gorm:"column:permissons_ids" Label string gorm:"column:label" Dependence *string gorm:"column:dependence" }
type PermissionsLabels map[string][]*PermissionsGroups
type PermissionsGroups map[string][]*PermissionsItem
type PermissionsItem struct{ Id string json:"id" Label string json:"label" Dependence *string json:"dependence,omitempty" }
I want to rewrite this function: func (u *uiStorageImpl) toPermissionsLabels(dto []*permissonsLabels) *domain.PermissionsLabels {
codepermissionsLabels := make(domain.PermissionsLabels) for _, item := range dto { permissionsLabels[item.GroupTitle] = append(permissionsLabels[item.GroupTitle], ) // permissionsLabels[item.ResourceCode] = append(permissionsLabels[item.ResourceCode], domain.PermissionsItem{ // Id: item.PermissionsIDs, // Label: item.Label, // Dependence: item.Dependence, // }) } return &permissionsLabels}
- Assistant
To rewrite the
toPermissionsLabelsfunction based on your provided structures, it seems you want to mappermissonsLabelsto a formattedPermissionsLabels, where each group inPermissionsGroupsis populated withPermissionsItem.Given your existing structures, we need to do the following in the function: