fix: UE online user total number issue

This commit is contained in:
zhangsz
2025-05-09 15:58:54 +08:00
parent 1eab9c0c55
commit 3b16d090c1
3 changed files with 12 additions and 96 deletions

View File

@@ -252,8 +252,9 @@ type SmfUEInfoResponse struct {
}
type UEInfoResponse struct {
Total int `json:"total"`
Data []TenantUEInfo `json:"data"`
Total int `json:"total"`
TenantNum int `json:"tenantNum"`
Data []TenantUEInfo `json:"data"`
}
// Get UEInfo from NF/NFs, SMF Online users
@@ -314,6 +315,7 @@ func GetSMFUEInfoFromNF(w http.ResponseWriter, r *http.Request) {
if tenantID == "" {
var ueInfos UEInfoResponse
_ = json.Unmarshal(resp.Body(), &ueInfos)
response.Total = ueInfos.Total
for i := 0; i < len(ueInfos.Data); i++ {
where = fmt.Sprintf("status='1' and tenancy_type='IMSI' and '%s' like tenancy_key", ueInfos.Data[i].IMSI[5:])
tenantID, _ = dborm.XormGetSingleColStringByWhere("sys_tenant", "parent_id", where)
@@ -324,7 +326,6 @@ func GetSMFUEInfoFromNF(w http.ResponseWriter, r *http.Request) {
ueInfos.Data[i].NeID = neInfo.NeId
ueInfos.Data[i].TenantName = tenantName
response.Data = append(response.Data, ueInfos.Data[i])
response.Total = i
}
// services.ResponseWithJson(w, resp.StatusCode(), &response)
// return
@@ -344,9 +345,14 @@ func GetSMFUEInfoFromNF(w http.ResponseWriter, r *http.Request) {
n.NeID = neInfo.NeId
n.TenantName = tenantName
response.Data = append(response.Data, n)
response.Total++
response.TenantNum++
}
}
if ueInfos.Total > len(ueInfos.Data) {
response.Total = ueInfos.Total
} else {
response.Total = response.TenantNum
}
// var response UEInfoResponse
// response.Data = tenantUEInfos
// services.ResponseWithJson(w, resp.StatusCode(), &response)