Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchennn committed Jul 20, 2023
1 parent 95fa928 commit f0eb9a7
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions backend/WebUI/api_webui.go
Original file line number Diff line number Diff line change
Expand Up @@ -1361,39 +1361,37 @@ func dbOperation(ueId string, servingPlmnId string, method string, subsData *Sub
// Set Sd value to lower case
if subsData != nil {
if subsData.AccessAndMobilitySubscriptionData.Nssai != nil {
if subsData.AccessAndMobilitySubscriptionData.Nssai.DefaultSingleNssais != nil {
for i, defaultSingleNssai := range subsData.AccessAndMobilitySubscriptionData.Nssai.DefaultSingleNssais {
subsData.AccessAndMobilitySubscriptionData.Nssai.DefaultSingleNssais[i].Sd = strings.ToLower(defaultSingleNssai.Sd)
}
defaultSingleNssais := subsData.AccessAndMobilitySubscriptionData.Nssai.DefaultSingleNssais
for i, defaultSingleNssai := range defaultSingleNssais {
defaultSingleNssais[i].Sd = strings.ToLower(defaultSingleNssai.Sd)
}
if subsData.AccessAndMobilitySubscriptionData.Nssai.SingleNssais != nil {
for i, singleNssai := range subsData.AccessAndMobilitySubscriptionData.Nssai.SingleNssais {
subsData.AccessAndMobilitySubscriptionData.Nssai.SingleNssais[i].Sd = strings.ToLower(singleNssai.Sd)
}

singleNssais := subsData.AccessAndMobilitySubscriptionData.Nssai.SingleNssais
for i, singleNssai := range singleNssais {
singleNssais[i].Sd = strings.ToLower(singleNssai.Sd)
}
}
if subsData.SessionManagementSubscriptionData != nil {
for i, subscriptionData := range subsData.SessionManagementSubscriptionData {
subsData.SessionManagementSubscriptionData[i].SingleNssai.Sd = strings.ToLower(subscriptionData.SingleNssai.Sd)
}

subscriptionDatas := subsData.SessionManagementSubscriptionData
for i, subscriptionData := range subscriptionDatas {
subscriptionDatas[i].SingleNssai.Sd = strings.ToLower(subscriptionData.SingleNssai.Sd)
}
if subsData.SmfSelectionSubscriptionData.SubscribedSnssaiInfos != nil {
for sd, subscribedSnssaiInfo := range subsData.SmfSelectionSubscriptionData.SubscribedSnssaiInfos {
val := subscribedSnssaiInfo
newSd := strings.ToLower(sd)
if newSd != sd {
subsData.SmfSelectionSubscriptionData.SubscribedSnssaiInfos[newSd] = val
delete(subsData.SmfSelectionSubscriptionData.SubscribedSnssaiInfos, sd)
}

subscribedSnssaiInfos := subsData.SmfSelectionSubscriptionData.SubscribedSnssaiInfos
for sd, subscribedSnssaiInfo := range subscribedSnssaiInfos {
val := subscribedSnssaiInfo
newSd := strings.ToLower(sd)
if newSd != sd {
subsData.SmfSelectionSubscriptionData.SubscribedSnssaiInfos[newSd] = val
delete(subsData.SmfSelectionSubscriptionData.SubscribedSnssaiInfos, sd)
}
}
if subsData.SmPolicyData.SmPolicySnssaiData != nil {
for i, snssaiData := range subsData.SmPolicyData.SmPolicySnssaiData {
subsData.SmPolicyData.SmPolicySnssaiData[i].Snssai.Sd = snssaiData.Snssai.Sd
}

smPolicySnssaiDatas := subsData.SmPolicyData.SmPolicySnssaiData
for i, snssaiData := range smPolicySnssaiDatas {
smPolicySnssaiDatas[i].Snssai.Sd = snssaiData.Snssai.Sd
}
}

// Replace all data with new one
if method == "put" {
if err := mongoapi.RestfulAPIDeleteMany(flowRuleDataColl, filter); err != nil {
Expand Down

0 comments on commit f0eb9a7

Please sign in to comment.