27 lines
778 B
Go
27 lines
778 B
Go
package tools
|
|
|
|
import "gitea.pena/PenaSide/tariffs/internal/models"
|
|
|
|
func ConvertPrivilegesToMap(privileges []models.Privilege) map[string][]models.PrivilegeResponse {
|
|
resultMap := make(map[string][]models.PrivilegeResponse)
|
|
|
|
for _, privilege := range privileges {
|
|
svcKey := privilege.ServiceKey
|
|
if _, ok := resultMap[svcKey]; !ok {
|
|
resultMap[svcKey] = []models.PrivilegeResponse{}
|
|
}
|
|
resultMap[svcKey] = append(resultMap[svcKey], models.PrivilegeResponse{
|
|
Name: privilege.Name,
|
|
PrivilegeID: privilege.PrivilegeID,
|
|
ServiceKey: privilege.ServiceKey,
|
|
Description: privilege.Description,
|
|
Type: privilege.Type,
|
|
Value: privilege.Value,
|
|
Price: privilege.Price,
|
|
Amount: privilege.Amount,
|
|
})
|
|
}
|
|
|
|
return resultMap
|
|
}
|