fix: radioid contain radio type+radio ID like '4G_3" or "5G_6"
This commit is contained in:
@@ -653,6 +653,7 @@ func GetNBInfoFromNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
services.ResponseNotFound404UriNotExist(w, r)
|
services.ResponseNotFound404UriNotExist(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//neTypeLower := strings.ToLower(neType)
|
//neTypeLower := strings.ToLower(neType)
|
||||||
var neId string
|
var neId string
|
||||||
neIds := services.GetParamsArrByName("neId", r)
|
neIds := services.GetParamsArrByName("neId", r)
|
||||||
@@ -691,8 +692,7 @@ func GetNBInfoFromNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
requestURI2NF := fmt.Sprintf("%s%s", hostUri, r.RequestURI)
|
requestURI2NF := fmt.Sprintf("%s%s", hostUri, r.RequestURI)
|
||||||
|
|
||||||
// for apifox mock test
|
// for apifox mock test
|
||||||
// hostUri := "http://127.0.0.1:4523"
|
//requestURI2NF := "http://127.0.0.1:4523/m1/3157310-1528434-default/api/rest/ueManagement/v1/elementType/" + strings.ToLower(neType) + "/objectType/nbInfo?apifoxApiId=128848301"
|
||||||
// requestURI2NF := hostUri + "/m1/3157310-1528434-default/api/rest/ueManagement/v1/elementType/amf/objectType/nbInfo?apifoxApiId=128848301"
|
|
||||||
|
|
||||||
log.Debug("requestURI2NF:", requestURI2NF)
|
log.Debug("requestURI2NF:", requestURI2NF)
|
||||||
|
|
||||||
@@ -707,53 +707,60 @@ func GetNBInfoFromNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Error("Get system state from NF is failed:", err)
|
log.Error("Get system state from NF is failed:", err)
|
||||||
services.ResponseInternalServerError500ProcessError(w, err)
|
services.ResponseInternalServerError500ProcessError(w, err)
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// multi-tenancy solution
|
||||||
|
var tenantID, where, userName, radioType string
|
||||||
|
if strings.ToLower(neType) == "mme" {
|
||||||
|
radioType = "4G"
|
||||||
|
} else if strings.ToLower(neType) == "amf" {
|
||||||
|
radioType = "5G"
|
||||||
|
}
|
||||||
|
if tenantName != "" {
|
||||||
|
where = fmt.Sprintf("status='1' and tenant_name='%s'", tenantName)
|
||||||
|
tenantID, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "tenant_id", where)
|
||||||
} else {
|
} else {
|
||||||
// multi-tenancy solution
|
userName = ctx.LoginUserToUserName(r)
|
||||||
var tenantID, where, userName string
|
where = fmt.Sprintf("status='1' and user_name='%s'", userName)
|
||||||
if tenantName != "" {
|
tenantID, _ = dborm.XormGetSingleColStringByWhere("sys_user", "tenant_id", where)
|
||||||
where = fmt.Sprintf("status='1' and tenant_name='%s'", tenantName)
|
where = fmt.Sprintf("status='1' and tenant_id='%s'", tenantID)
|
||||||
tenantID, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "tenant_id", where)
|
tenantName, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "tenant_name", where)
|
||||||
} else {
|
}
|
||||||
userName = ctx.LoginUserToUserName(r)
|
log.Tracef("tenantName: %s userName: %s tenantID: %s", tenantName, userName, tenantID)
|
||||||
where = fmt.Sprintf("status='1' and user_name='%s'", userName)
|
if tenantID == "" {
|
||||||
tenantID, _ = dborm.XormGetSingleColStringByWhere("sys_user", "tenant_id", where)
|
var response NBInfoResponse
|
||||||
|
//var nbInfo *TenantNBInfo
|
||||||
|
_ = json.Unmarshal(resp.Body(), &response)
|
||||||
|
|
||||||
|
for i := 0; i < len(response.Data); i++ {
|
||||||
|
where = fmt.Sprintf("status='1' and tenancy_type='RADIO' and tenancy_key='%v'", radioType+"_"+response.Data[i].ID)
|
||||||
|
tenantID, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "parent_id", where)
|
||||||
where = fmt.Sprintf("status='1' and tenant_id='%s'", tenantID)
|
where = fmt.Sprintf("status='1' and tenant_id='%s'", tenantID)
|
||||||
tenantName, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "tenant_name", where)
|
tenantName, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "tenant_name", where)
|
||||||
|
log.Tracef("tenantName: %s tenantID: %s", tenantName, tenantID)
|
||||||
|
response.Data[i].TenantName = tenantName
|
||||||
}
|
}
|
||||||
log.Tracef("tenantName: %s userName: %s tenantID: %s", tenantName, userName, tenantID)
|
services.ResponseWithJson(w, resp.StatusCode(), &response)
|
||||||
if tenantID == "" {
|
return
|
||||||
var response NBInfoResponse
|
} else {
|
||||||
//var nbInfo *TenantNBInfo
|
// var response services.MapResponse
|
||||||
_ = json.Unmarshal(resp.Body(), &response)
|
var tenantNBInfos []TenantNBInfo
|
||||||
for i := 0; i < len(response.Data); i++ {
|
var nbInfos NBInfoResponse
|
||||||
where = fmt.Sprintf("status='1' and tenancy_type='RADIO' and tenancy_key='%v'", response.Data[i].ID)
|
var nbIDs []string
|
||||||
tenantID, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "parent_id", where)
|
// Get nodeB IDs by tenantID
|
||||||
where = fmt.Sprintf("status='1' and tenant_id='%s'", tenantID)
|
where = fmt.Sprintf("status='1' and tenancy_type='RADIO' and parent_id='%v'", tenantID)
|
||||||
tenantName, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "tenant_name", where)
|
dborm.XormFindColStringArrayByWhere("sys_tenant", "tenancy_key", where, &nbIDs)
|
||||||
log.Tracef("tenantName: %s tenantID: %s", tenantName, tenantID)
|
_ = json.Unmarshal(resp.Body(), &nbInfos)
|
||||||
response.Data[i].TenantName = tenantName
|
for _, n := range nbInfos.Data {
|
||||||
|
if global.IsMember(radioType+"_"+n.ID, nbIDs) {
|
||||||
|
n.TenantName = tenantName
|
||||||
|
tenantNBInfos = append(tenantNBInfos, n)
|
||||||
}
|
}
|
||||||
services.ResponseWithJson(w, resp.StatusCode(), &response)
|
|
||||||
} else {
|
|
||||||
// var response services.MapResponse
|
|
||||||
var tenantNBInfos []TenantNBInfo
|
|
||||||
var nbInfos NBInfoResponse
|
|
||||||
var nbIDs []string
|
|
||||||
// Get nodeB IDs by tenantID
|
|
||||||
where = fmt.Sprintf("status='1' and tenancy_type='RADIO' and parent_id='%v'", tenantID)
|
|
||||||
dborm.XormFindColStringArrayByWhere("sys_tenant", "tenancy_key", where, &nbIDs)
|
|
||||||
_ = json.Unmarshal(resp.Body(), &nbInfos)
|
|
||||||
for _, n := range nbInfos.Data {
|
|
||||||
if global.IsMember(n.ID, nbIDs) {
|
|
||||||
n.TenantName = tenantName
|
|
||||||
tenantNBInfos = append(tenantNBInfos, n)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.Tracef("nbIDs: %v", nbIDs)
|
|
||||||
nbInfos.Data = tenantNBInfos
|
|
||||||
services.ResponseWithJson(w, resp.StatusCode(), &nbInfos)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
log.Tracef("nbIDs: %v", nbIDs)
|
||||||
|
nbInfos.Data = tenantNBInfos
|
||||||
|
services.ResponseWithJson(w, resp.StatusCode(), &nbInfos)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user