Merge branch 'main' into multi-tenant
This commit is contained in:
@@ -15,19 +15,17 @@ import (
|
||||
)
|
||||
|
||||
// 实例化控制层 AlarmController 结构体
|
||||
var NewAlarmController = &AlarmController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
alarmService: neDataService.NewAlarmImpl,
|
||||
var NewAlarm = &AlarmController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
alarmService: neDataService.NewAlarm,
|
||||
}
|
||||
|
||||
// 告警数据
|
||||
//
|
||||
// PATH /alarm
|
||||
type AlarmController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// 告警信息服务
|
||||
alarmService neDataService.IAlarm
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
alarmService *neDataService.Alarm // 告警信息服务
|
||||
}
|
||||
|
||||
// 告警列表
|
||||
|
||||
@@ -16,19 +16,17 @@ import (
|
||||
)
|
||||
|
||||
// 实例化控制层 PerfKPIController 结构体
|
||||
var NewPerfKPIController = &PerfKPIController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
perfKPIService: neDataService.NewPerfKPIImpl,
|
||||
var NewPerfKPI = &PerfKPIController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
perfKPIService: neDataService.NewPerfKPI,
|
||||
}
|
||||
|
||||
// 性能统计
|
||||
//
|
||||
// PATH /kpi
|
||||
type PerfKPIController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// 统计信息服务
|
||||
perfKPIService neDataService.IPerfKPI
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
perfKPIService *neDataService.PerfKPI // 统计信息服务
|
||||
}
|
||||
|
||||
// 获取统计数据
|
||||
|
||||
@@ -22,19 +22,17 @@ import (
|
||||
)
|
||||
|
||||
// 实例化控制层 AMFController 结构体
|
||||
var NewAMFController = &AMFController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
ueEventService: neDataService.NewUEEventAMFImpl,
|
||||
var NewAMF = &AMFController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
ueEventService: neDataService.NewUEEventAMF,
|
||||
}
|
||||
|
||||
// 网元AMF
|
||||
//
|
||||
// PATH /amf
|
||||
type AMFController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// UE会话事件服务
|
||||
ueEventService neDataService.IUEEventAMF
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
ueEventService *neDataService.UEEventAMF // UE会话事件服务
|
||||
}
|
||||
|
||||
// UE会话列表
|
||||
@@ -127,11 +125,11 @@ func (s *AMFController) UEExport(c *gin.Context) {
|
||||
"F1": "Tenant Name",
|
||||
}
|
||||
// 读取字典数据 UE 事件类型
|
||||
dictUEEventType := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_event_type")
|
||||
dictUEEventType := sysService.NewSysDictData.SelectDictDataByType("ue_event_type")
|
||||
// 读取字典数据 UE 事件认证代码类型
|
||||
dictUEAauthCode := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_auth_code")
|
||||
dictUEAauthCode := sysService.NewSysDictData.SelectDictDataByType("ue_auth_code")
|
||||
// 读取字典数据 UE 事件CM状态
|
||||
dictUEEventCmState := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_event_cm_state")
|
||||
dictUEEventCmState := sysService.NewSysDictData.SelectDictDataByType("ue_event_cm_state")
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
for i, row := range rows {
|
||||
|
||||
@@ -23,19 +23,17 @@ import (
|
||||
)
|
||||
|
||||
// 实例化控制层 IMSController 结构体
|
||||
var NewIMSController = &IMSController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
cdrEventService: neDataService.NewCDREventIMSImpl,
|
||||
var NewIMS = &IMSController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
cdrEventService: neDataService.NewCDREventIMS,
|
||||
}
|
||||
|
||||
// 网元IMS
|
||||
//
|
||||
// PATH /ims
|
||||
type IMSController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// CDR会话事件服务
|
||||
cdrEventService neDataService.ICDREventIMS
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
cdrEventService *neDataService.CDREventIMS // CDR会话事件服务
|
||||
}
|
||||
|
||||
// CDR会话列表
|
||||
@@ -138,9 +136,9 @@ func (s *IMSController) CDRExport(c *gin.Context) {
|
||||
"I1": "Tenant Name", // for multi-tenancy
|
||||
}
|
||||
// 读取字典数据 CDR SIP响应代码类别类型
|
||||
dictCDRSipCode := sysService.NewSysDictDataImpl.SelectDictDataByType("cdr_sip_code")
|
||||
dictCDRSipCode := sysService.NewSysDictData.SelectDictDataByType("cdr_sip_code")
|
||||
// 读取字典数据 CDR 呼叫类型
|
||||
dictCDRCallType := sysService.NewSysDictDataImpl.SelectDictDataByType("cdr_call_type")
|
||||
dictCDRCallType := sysService.NewSysDictData.SelectDictDataByType("cdr_call_type")
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
for i, row := range rows {
|
||||
|
||||
@@ -23,19 +23,17 @@ import (
|
||||
)
|
||||
|
||||
// 实例化控制层 MMEController 结构体
|
||||
var NewMMEController = &MMEController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
ueEventService: neDataService.NewUEEventMMEImpl,
|
||||
var NewMME = &MMEController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
ueEventService: neDataService.NewUEEventMME,
|
||||
}
|
||||
|
||||
// 网元MME
|
||||
//
|
||||
// PATH /mme
|
||||
type MMEController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// UE会话事件服务
|
||||
ueEventService neDataService.IUEEventMME
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
ueEventService *neDataService.UEEventMME // UE会话事件服务
|
||||
}
|
||||
|
||||
// UE会话列表
|
||||
@@ -128,11 +126,11 @@ func (s *MMEController) UEExport(c *gin.Context) {
|
||||
"F1": "Tenant Name",
|
||||
}
|
||||
// 读取字典数据 UE 事件类型
|
||||
dictUEEventType := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_event_type")
|
||||
dictUEEventType := sysService.NewSysDictData.SelectDictDataByType("ue_event_type")
|
||||
// 读取字典数据 UE 事件认证代码类型
|
||||
dictUEAauthCode := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_auth_code")
|
||||
dictUEAauthCode := sysService.NewSysDictData.SelectDictDataByType("ue_auth_code")
|
||||
// 读取字典数据 UE 事件CM状态
|
||||
dictUEEventCmState := sysService.NewSysDictDataImpl.SelectDictDataByType("ue_event_cm_state")
|
||||
dictUEEventCmState := sysService.NewSysDictData.SelectDictDataByType("ue_event_cm_state")
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
for i, row := range rows {
|
||||
|
||||
@@ -22,22 +22,19 @@ import (
|
||||
)
|
||||
|
||||
// 实例化控制层 SMFController 结构体
|
||||
var NewSMFController = &SMFController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
cdrEventService: neDataService.NewCDREventSMFImpl,
|
||||
udmUserInfoService: *neDataService.NewUDMUserInfo,
|
||||
var NewSMF = &SMFController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
cdrEventService: neDataService.NewCDREventSMF,
|
||||
udmUserInfoService: neDataService.NewUDMUserInfo,
|
||||
}
|
||||
|
||||
// 网元SMF
|
||||
//
|
||||
// PATH /smf
|
||||
type SMFController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// CDR会话事件服务
|
||||
cdrEventService neDataService.ICDREventSMF
|
||||
// UDM用户信息服务
|
||||
udmUserInfoService neDataService.UDMUserInfo
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
cdrEventService *neDataService.CDREventSMF // CDR会话事件服务
|
||||
udmUserInfoService *neDataService.UDMUserInfo // UDM用户信息服务
|
||||
}
|
||||
|
||||
// CDR会话列表
|
||||
@@ -131,18 +128,31 @@ func (s *SMFController) CDRExport(c *gin.Context) {
|
||||
headerCells := map[string]string{
|
||||
"A1": "ID",
|
||||
"B1": "Charging ID",
|
||||
"C1": "Subscriber ID Data",
|
||||
"D1": "Subscriber ID Type",
|
||||
"E1": "Data Volume Uplink",
|
||||
"F1": "Data Volume Downlink",
|
||||
"G1": "Data Total Volume",
|
||||
"H1": "Duration",
|
||||
"I1": "Invocation Time",
|
||||
"J1": "PDU Session Charging Information",
|
||||
"K1": "Tenant Name", // for multi-tenancy
|
||||
"C1": "NE Name",
|
||||
"D1": "Resource Unique ID",
|
||||
"E1": "Subscriber ID Data",
|
||||
"F1": "Subscriber ID Type",
|
||||
"G1": "Data Volume Uplink",
|
||||
"H1": "Data Volume Downlink",
|
||||
"I1": "Data Total Volume",
|
||||
"J1": "Duration",
|
||||
"K1": "Invocation Time",
|
||||
"L1": "User Identifier",
|
||||
"M1": "SSC Mode",
|
||||
"N1": "DNN ID",
|
||||
"O1": "PDU Type",
|
||||
"P1": "RAT Type",
|
||||
"Q1": "PDU IPv4 Address",
|
||||
"R1": "Network Function IPv4",
|
||||
"S1": "PDU IPv6 Address Swith Prefix",
|
||||
"T1": "Record Network Function ID",
|
||||
"U1": "Record Type",
|
||||
"V1": "Record Opening Time",
|
||||
"W1": "Tenant Name", // for multi-tenancy
|
||||
}
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
|
||||
for i, row := range rows {
|
||||
idx := strconv.Itoa(i + 2)
|
||||
// 解析 JSON 字符串为 map
|
||||
@@ -167,12 +177,22 @@ func (s *SMFController) CDRExport(c *gin.Context) {
|
||||
subscriptionIDData = sub["subscriptionIDData"].(string)
|
||||
}
|
||||
}
|
||||
|
||||
// 网络功能 IPv4 地址
|
||||
networkFunctionIPv4Address := ""
|
||||
if v, ok := cdrJSON["nFunctionConsumerInformation"]; ok && v != nil {
|
||||
if conInfo, conInfoOk := v.(map[string]any); conInfoOk && conInfo != nil {
|
||||
networkFunctionIPv4Address = conInfo["networkFunctionIPv4Address"].(string)
|
||||
}
|
||||
}
|
||||
|
||||
// 数据量上行链路
|
||||
dataVolumeUplink := []string{}
|
||||
// 数据量下行链路
|
||||
dataVolumeDownlink := []string{}
|
||||
// 数据总量
|
||||
dataTotalVolume := []string{}
|
||||
|
||||
if v, ok := cdrJSON["listOfMultipleUnitUsage"]; ok && v != nil {
|
||||
usageList := v.([]any)
|
||||
if len(usageList) > 0 {
|
||||
@@ -207,32 +227,31 @@ func (s *SMFController) CDRExport(c *gin.Context) {
|
||||
invocationTimestamp = v.(string)
|
||||
}
|
||||
// 记录打开时间
|
||||
pduSessionChargingInformation := ""
|
||||
User_Identifier := ""
|
||||
SSC_Mode := ""
|
||||
RAT_Type := ""
|
||||
DNN_ID := ""
|
||||
PDU_Type := ""
|
||||
PDU_IPv4 := ""
|
||||
PDU_IPv6 := ""
|
||||
if v, ok := cdrJSON["pDUSessionChargingInformation"]; ok && v != nil {
|
||||
pduInfo := v.(map[string]any)
|
||||
|
||||
User_Identifier := ""
|
||||
if v, ok := pduInfo["userIdentifier"]; ok && v != nil {
|
||||
User_Identifier = v.(string)
|
||||
}
|
||||
SSC_Mode := ""
|
||||
if v, ok := pduInfo["sSCMode"]; ok && v != nil {
|
||||
SSC_Mode = v.(string)
|
||||
}
|
||||
RAT_Type := ""
|
||||
if v, ok := pduInfo["rATType"]; ok && v != nil {
|
||||
RAT_Type = v.(string)
|
||||
}
|
||||
DNN_ID := ""
|
||||
if v, ok := pduInfo["dNNID"]; ok && v != nil {
|
||||
DNN_ID = v.(string)
|
||||
}
|
||||
PDU_Type := ""
|
||||
if v, ok := pduInfo["pDUType"]; ok && v != nil {
|
||||
PDU_Type = v.(string)
|
||||
}
|
||||
PDU_IPv4 := ""
|
||||
PDU_IPv6 := ""
|
||||
if v, ok := pduInfo["pDUAddress"]; ok && v != nil {
|
||||
pDUAddress := v.(map[string]any)
|
||||
if addr, ok := pDUAddress["pDUIPv4Address"]; ok && addr != nil {
|
||||
@@ -243,11 +262,29 @@ func (s *SMFController) CDRExport(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
pduSessionChargingInformation = fmt.Sprintf(`User Identifier: %s
|
||||
SSC Mode: %s RAT Type: %s DNN ID: %s
|
||||
PDU Type: %s
|
||||
PDU IPv4 Address: %s
|
||||
PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6)
|
||||
// pduSessionChargingInformation = fmt.Sprintf(`User Identifier: %s
|
||||
// SSC Mode: %s RAT Type: %s DNN ID: %s
|
||||
// PDU Type: %s
|
||||
// PDU IPv4 Address: %s
|
||||
// PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6)
|
||||
}
|
||||
|
||||
// 记录网络参数ID
|
||||
recordNFID := ""
|
||||
if v, ok := cdrJSON["recordingNetworkFunctionID"]; ok && v != nil {
|
||||
recordNFID = v.(string)
|
||||
}
|
||||
|
||||
//记录开始时间
|
||||
recordOpeningTime := ""
|
||||
if v, ok := cdrJSON["recordOpeningTime"]; ok && v != nil {
|
||||
recordOpeningTime = v.(string)
|
||||
}
|
||||
|
||||
//记录类型
|
||||
recordType := ""
|
||||
if v, ok := cdrJSON["recordType"]; ok && v != nil {
|
||||
recordType = v.(string)
|
||||
}
|
||||
// for multi-tenant, get tenant name
|
||||
tenantName := row.TenantName
|
||||
@@ -255,15 +292,27 @@ PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID,
|
||||
dataCells = append(dataCells, map[string]any{
|
||||
"A" + idx: row.ID,
|
||||
"B" + idx: chargingID,
|
||||
"C" + idx: subscriptionIDData,
|
||||
"D" + idx: subscriptionIDType,
|
||||
"E" + idx: strings.Join(dataVolumeUplink, ","),
|
||||
"F" + idx: strings.Join(dataVolumeDownlink, ","),
|
||||
"G" + idx: strings.Join(dataTotalVolume, ","),
|
||||
"H" + idx: duration,
|
||||
"I" + idx: invocationTimestamp,
|
||||
"J" + idx: pduSessionChargingInformation,
|
||||
"K" + idx: tenantName,
|
||||
"C" + idx: row.NeName,
|
||||
"D" + idx: row.RmUID,
|
||||
"E" + idx: subscriptionIDData,
|
||||
"F" + idx: subscriptionIDType,
|
||||
"G" + idx: strings.Join(dataVolumeUplink, ","),
|
||||
"H" + idx: strings.Join(dataVolumeDownlink, ","),
|
||||
"I" + idx: strings.Join(dataTotalVolume, ","),
|
||||
"J" + idx: duration,
|
||||
"K" + idx: invocationTimestamp,
|
||||
"L" + idx: User_Identifier,
|
||||
"M" + idx: SSC_Mode,
|
||||
"N" + idx: DNN_ID,
|
||||
"O" + idx: PDU_Type,
|
||||
"P" + idx: RAT_Type,
|
||||
"Q" + idx: PDU_IPv4,
|
||||
"R" + idx: networkFunctionIPv4Address,
|
||||
"S" + idx: PDU_IPv6,
|
||||
"T" + idx: recordNFID,
|
||||
"U" + idx: recordType,
|
||||
"V" + idx: recordOpeningTime,
|
||||
"W" + idx: tenantName,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -22,19 +22,17 @@ import (
|
||||
)
|
||||
|
||||
// 实例化控制层 SMSCController 结构体
|
||||
var NewSMSCController = &SMSCController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
cdrEventService: neDataService.NewCDREventSMSCImpl,
|
||||
var NewSMSC = &SMSCController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
cdrEventService: neDataService.NewCDREventSMSC,
|
||||
}
|
||||
|
||||
// 网元SMSC
|
||||
//
|
||||
// PATH /smsc
|
||||
type SMSCController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// CDR会话事件服务
|
||||
cdrEventService neDataService.ICDREventSMSC
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
cdrEventService *neDataService.CDREventSMSC // CDR会话事件服务
|
||||
}
|
||||
|
||||
// CDR会话列表
|
||||
|
||||
@@ -24,17 +24,15 @@ import (
|
||||
// 实例化控制层 UDMAuthController 结构体
|
||||
var NewUDMAuth = &UDMAuthController{
|
||||
udmAuthService: neDataService.NewUDMAuthUser,
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
neInfoService: neService.NewNeInfo,
|
||||
}
|
||||
|
||||
// UDM鉴权用户
|
||||
//
|
||||
// PATH /udm/auth
|
||||
type UDMAuthController struct {
|
||||
// UDM鉴权信息服务
|
||||
udmAuthService *neDataService.UDMAuthUser
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
udmAuthService *neDataService.UDMAuthUser // UDM鉴权信息服务
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
}
|
||||
|
||||
// UDM鉴权用户重载数据
|
||||
@@ -48,7 +46,6 @@ func (s *UDMAuthController) ResetData(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
neId = ""
|
||||
data := s.udmAuthService.ResetData(neId)
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
@@ -58,7 +55,6 @@ func (s *UDMAuthController) ResetData(c *gin.Context) {
|
||||
// GET /list
|
||||
func (s *UDMAuthController) List(c *gin.Context) {
|
||||
querys := ctx.QueryMap(c)
|
||||
querys["neId"] = ""
|
||||
data := s.udmAuthService.SelectPage(querys)
|
||||
c.JSON(200, result.Ok(data))
|
||||
}
|
||||
@@ -102,7 +98,6 @@ func (s *UDMAuthController) Info(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
neId = ""
|
||||
// 解析返回的数据
|
||||
u := s.udmAuthService.ParseInfo(imsi, neId, data)
|
||||
s.udmAuthService.Insert(neId, u)
|
||||
@@ -142,7 +137,8 @@ func (s *UDMAuthController) Add(c *gin.Context) {
|
||||
defer telnetClient.Close()
|
||||
|
||||
// 发送MML
|
||||
cmd := fmt.Sprintf("add authdat:imsi=%s,ki=%s,amf=%s,algo=%s,opc=%s", body.IMSI, body.Ki, body.Amf, body.AlgoIndex, body.Opc)
|
||||
cmd := fmt.Sprintf("add authdat:imsi=%s,", body.IMSI)
|
||||
cmd += s.udmAuthService.ParseCommandParams(body)
|
||||
data, err := telnet.ConvertToStr(telnetClient, cmd)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
@@ -151,7 +147,6 @@ func (s *UDMAuthController) Add(c *gin.Context) {
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
s.udmAuthService.Insert(neId, body)
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
@@ -191,7 +186,8 @@ func (s *UDMAuthController) Adds(c *gin.Context) {
|
||||
defer telnetClient.Close()
|
||||
|
||||
// 发送MML
|
||||
cmd := fmt.Sprintf("baa authdat:start_imsi=%s,sub_num=%s,ki=%s,amf=%s,algo=%s,opc=%s", body.IMSI, num, body.Ki, body.Amf, body.AlgoIndex, body.Opc)
|
||||
cmd := fmt.Sprintf("baa authdat:start_imsi=%s,sub_num=%s,", body.IMSI, num)
|
||||
cmd += s.udmAuthService.ParseCommandParams(body)
|
||||
data, err := telnet.ConvertToStr(telnetClient, cmd)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
@@ -200,8 +196,7 @@ func (s *UDMAuthController) Adds(c *gin.Context) {
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
go s.udmAuthService.LoadData(neId, body.IMSI, num)
|
||||
s.udmAuthService.LoadData(neId, body.IMSI, num)
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
@@ -239,20 +234,8 @@ func (s *UDMAuthController) Edit(c *gin.Context) {
|
||||
defer telnetClient.Close()
|
||||
|
||||
// 发送MML
|
||||
cmd := fmt.Sprintf("mod authdata:imsi=%s", body.IMSI)
|
||||
// 修改的参数名称
|
||||
if body.Ki != "" {
|
||||
cmd += fmt.Sprintf(",ki=%s", body.Ki)
|
||||
}
|
||||
if body.Amf != "" {
|
||||
cmd += fmt.Sprintf(",amf=%s", body.Amf)
|
||||
}
|
||||
if body.AlgoIndex != "" {
|
||||
cmd += fmt.Sprintf(",algo=%s", body.AlgoIndex)
|
||||
}
|
||||
if body.Opc != "" {
|
||||
cmd += fmt.Sprintf(",opc=%s", body.Opc)
|
||||
}
|
||||
cmd := fmt.Sprintf("mod authdata:imsi=%s,", body.IMSI)
|
||||
cmd += s.udmAuthService.ParseCommandParams(body)
|
||||
data, err := telnet.ConvertToStr(telnetClient, cmd)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
@@ -261,7 +244,6 @@ func (s *UDMAuthController) Edit(c *gin.Context) {
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
s.udmAuthService.Insert(neId, body)
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
@@ -312,7 +294,6 @@ func (s *UDMAuthController) Remove(c *gin.Context) {
|
||||
}
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
s.udmAuthService.Delete(imsi, neId)
|
||||
}
|
||||
resultData[imsi] = data
|
||||
@@ -358,8 +339,7 @@ func (s *UDMAuthController) Removes(c *gin.Context) {
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
go s.udmAuthService.LoadData(neId, imsi, num)
|
||||
s.udmAuthService.LoadData(neId, imsi, num)
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
@@ -384,7 +364,6 @@ func (s *UDMAuthController) Export(c *gin.Context) {
|
||||
|
||||
querys["pageNum"] = 1
|
||||
querys["pageSize"] = 10000
|
||||
querys["neId"] = ""
|
||||
data := s.udmAuthService.SelectPage(querys)
|
||||
if parse.Number(data["total"]) == 0 {
|
||||
// 导出数据记录为空
|
||||
@@ -434,8 +413,8 @@ func (s *UDMAuthController) Export(c *gin.Context) {
|
||||
data = append(data, []string{v.IMSI, v.Ki, v.AlgoIndex, v.Amf, opc})
|
||||
}
|
||||
// 输出到文件
|
||||
err := file.WriterFileTXT(data, ",", filePath)
|
||||
if err != nil {
|
||||
|
||||
if err := file.WriterFileTXT(data, ",", filePath); err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -531,13 +510,11 @@ func (s *UDMAuthController) Import(c *gin.Context) {
|
||||
if strings.Contains(resultMsg, "ok") {
|
||||
if strings.HasSuffix(body.UploadPath, ".csv") {
|
||||
data := file.ReadFileCSV(localFilePath)
|
||||
neId := ""
|
||||
go s.udmAuthService.InsertData(neId, "csv", data)
|
||||
go s.udmAuthService.InsertData(neInfo.NeId, "csv", data)
|
||||
}
|
||||
if strings.HasSuffix(body.UploadPath, ".txt") {
|
||||
data := file.ReadFileTXT(",", localFilePath)
|
||||
neId := ""
|
||||
go s.udmAuthService.InsertData(neId, "txt", data)
|
||||
go s.udmAuthService.InsertData(neInfo.NeId, "txt", data)
|
||||
}
|
||||
}
|
||||
c.JSON(200, result.OkMsg(resultMsg))
|
||||
|
||||
@@ -23,17 +23,15 @@ import (
|
||||
// 实例化控制层 UDMSubController 结构体
|
||||
var NewUDMSub = &UDMSubController{
|
||||
udmSubService: neDataService.NewUDMSub,
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
neInfoService: neService.NewNeInfo,
|
||||
}
|
||||
|
||||
// UDM签约用户
|
||||
//
|
||||
// PATH /udm/sub
|
||||
type UDMSubController struct {
|
||||
// UDM签约信息服务
|
||||
udmSubService *neDataService.UDMSubUser
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
udmSubService *neDataService.UDMSubUser // UDM签约信息服务
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
}
|
||||
|
||||
// UDM签约用户重载数据
|
||||
@@ -47,7 +45,6 @@ func (s *UDMSubController) ResetData(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
neId = ""
|
||||
data := s.udmSubService.ResetData(neId)
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
@@ -57,7 +54,6 @@ func (s *UDMSubController) ResetData(c *gin.Context) {
|
||||
// GET /list
|
||||
func (s *UDMSubController) List(c *gin.Context) {
|
||||
querys := ctx.QueryMap(c)
|
||||
querys["neId"] = ""
|
||||
querys["userName"] = ctx.LoginUserToUserName(c)
|
||||
data := s.udmSubService.SelectPage(querys)
|
||||
c.JSON(200, result.Ok(data))
|
||||
@@ -102,7 +98,6 @@ func (s *UDMSubController) Info(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
neId = ""
|
||||
// 解析返回的数据
|
||||
u := s.udmSubService.ParseInfo(imsi, neId, data)
|
||||
s.udmSubService.Insert(neId, u)
|
||||
@@ -142,12 +137,8 @@ func (s *UDMSubController) Add(c *gin.Context) {
|
||||
defer telnetClient.Close()
|
||||
|
||||
// 发送MML
|
||||
cmd := fmt.Sprintf("add udmuser:imsi=%s,msisdn=%s,ambr=%s,nssai=%s,arfb=%s,sar=%s,rat=%s,cn=%s,smf_sel=%s,sm_data=%s,eps_flag=%s,eps_odb=%s,hplmn_odb=%s,ard=%s,epstpl=%s,context_id=%s,apn_context=%s,cag=%s",
|
||||
body.IMSI, body.MSISDN, body.Ambr, body.Nssai, body.Arfb, body.Sar, body.Rat, body.Cn, body.SmfSel, body.SmData, body.EpsFlag, body.EpsOdb, body.HplmnOdb, body.Ard, body.Epstpl, body.ContextId, body.ApnContext, body.Cag)
|
||||
// static_ip指给4G UE分配的静态IP,没有可不带此字段名,批量添加IP会自动递增
|
||||
if body.StaticIp != "" {
|
||||
cmd += fmt.Sprintf(",static_ip=%s", body.StaticIp)
|
||||
}
|
||||
cmd := fmt.Sprintf("add udmuser:imsi=%s,", body.IMSI)
|
||||
cmd += s.udmSubService.ParseCommandParams(body)
|
||||
data, err := telnet.ConvertToStr(telnetClient, cmd)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
@@ -156,7 +147,6 @@ func (s *UDMSubController) Add(c *gin.Context) {
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
body.NeId = neId
|
||||
s.udmSubService.Insert(neId, body)
|
||||
}
|
||||
@@ -197,8 +187,8 @@ func (s *UDMSubController) Adds(c *gin.Context) {
|
||||
defer telnetClient.Close()
|
||||
|
||||
// 发送MML
|
||||
cmd := fmt.Sprintf("baa udmuser:start_imsi=%s,start_msisdn=%s,sub_num=%s,ambr=%s,nssai=%s,arfb=%s,sar=%s,rat=%s,cn=%s,smf_sel=%s,sm_data=%s,eps_flag=%s,eps_odb=%s,hplmn_odb=%s,ard=%s,epstpl=%s,context_id=%s,apn_context=%s,cag=%s",
|
||||
body.IMSI, body.MSISDN, num, body.Ambr, body.Nssai, body.Arfb, body.Sar, body.Rat, body.Cn, body.SmfSel, body.SmData, body.EpsFlag, body.EpsOdb, body.HplmnOdb, body.Ard, body.Epstpl, body.ContextId, body.ApnContext, body.Cag)
|
||||
cmd := fmt.Sprintf("baa udmuser:start_imsi=%s,start_msisdn=%s,sub_num=%s,", body.IMSI, body.MSISDN, num)
|
||||
cmd += s.udmSubService.ParseCommandParams(body)
|
||||
// static_ip指给4G UE分配的静态IP,没有可不带此字段名,批量添加IP会自动递增
|
||||
if body.StaticIp != "" {
|
||||
cmd += fmt.Sprintf(",static_ip=%s", body.StaticIp)
|
||||
@@ -211,8 +201,7 @@ func (s *UDMSubController) Adds(c *gin.Context) {
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
go s.udmSubService.LoadData(neId, body.IMSI, num, body.Remark)
|
||||
s.udmSubService.LoadData(neId, body.IMSI, num, body.Remark)
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
@@ -250,65 +239,8 @@ func (s *UDMSubController) Edit(c *gin.Context) {
|
||||
defer telnetClient.Close()
|
||||
|
||||
// 发送MML
|
||||
cmd := fmt.Sprintf("mod udmuser:imsi=%s", body.IMSI)
|
||||
// 修改的参数名称
|
||||
if body.MSISDN != "" {
|
||||
cmd += fmt.Sprintf(",msisdn=%s", body.MSISDN)
|
||||
}
|
||||
if body.Ambr != "" {
|
||||
cmd += fmt.Sprintf(",ambr=%s", body.Ambr)
|
||||
}
|
||||
if body.Nssai != "" {
|
||||
cmd += fmt.Sprintf(",nssai=%s", body.Nssai)
|
||||
}
|
||||
if body.Arfb != "" {
|
||||
cmd += fmt.Sprintf(",arfb=%s", body.Arfb)
|
||||
}
|
||||
if body.Sar != "" {
|
||||
cmd += fmt.Sprintf(",sar=%s", body.Sar)
|
||||
}
|
||||
if body.Rat != "" {
|
||||
cmd += fmt.Sprintf(",rat=%s", body.Rat)
|
||||
}
|
||||
if body.Cn != "" {
|
||||
cmd += fmt.Sprintf(",cn=%s", body.Cn)
|
||||
}
|
||||
if body.SmfSel != "" {
|
||||
cmd += fmt.Sprintf(",smf_sel=%s", body.SmfSel)
|
||||
}
|
||||
if body.SmData != "" {
|
||||
cmd += fmt.Sprintf(",sm_data=%s", body.SmData)
|
||||
}
|
||||
if body.EpsDat != "" {
|
||||
cmd += fmt.Sprintf(",eps_dat=%s", body.EpsDat)
|
||||
}
|
||||
if body.EpsFlag != "" {
|
||||
cmd += fmt.Sprintf(",eps_flag=%s", body.EpsFlag)
|
||||
}
|
||||
if body.EpsOdb != "" {
|
||||
cmd += fmt.Sprintf(",eps_odb=%s", body.EpsOdb)
|
||||
}
|
||||
if body.HplmnOdb != "" {
|
||||
cmd += fmt.Sprintf(",hplmn_odb=%s", body.HplmnOdb)
|
||||
}
|
||||
if body.Epstpl != "" {
|
||||
cmd += fmt.Sprintf(",epstpl=%s", body.Epstpl)
|
||||
}
|
||||
if body.Ard != "" {
|
||||
cmd += fmt.Sprintf(",ard=%s", body.Ard)
|
||||
}
|
||||
if body.ContextId != "" {
|
||||
cmd += fmt.Sprintf(",context_id=%s", body.ContextId)
|
||||
}
|
||||
if body.ApnContext != "" {
|
||||
cmd += fmt.Sprintf(",apn_context=%s", body.ApnContext)
|
||||
}
|
||||
if body.Cag != "" {
|
||||
cmd += fmt.Sprintf(",cag=%s", body.Cag)
|
||||
}
|
||||
if body.StaticIp != "" {
|
||||
cmd += fmt.Sprintf(",static_ip=%s", body.StaticIp)
|
||||
}
|
||||
cmd := fmt.Sprintf("mod udmuser:imsi=%s,", body.IMSI)
|
||||
cmd += s.udmSubService.ParseCommandParams(body)
|
||||
data, err := telnet.ConvertToStr(telnetClient, cmd)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
@@ -317,7 +249,6 @@ func (s *UDMSubController) Edit(c *gin.Context) {
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
body.NeId = neId
|
||||
s.udmSubService.Insert(neId, body)
|
||||
}
|
||||
@@ -369,7 +300,6 @@ func (s *UDMSubController) Remove(c *gin.Context) {
|
||||
}
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
s.udmSubService.Delete(neId, imsi)
|
||||
}
|
||||
resultData[imsi] = data
|
||||
@@ -415,9 +345,7 @@ func (s *UDMSubController) Removes(c *gin.Context) {
|
||||
|
||||
// 命令ok时
|
||||
if strings.Contains(data, "ok") {
|
||||
neId = ""
|
||||
go s.udmSubService.LoadData(neId, imsi, num, "-(Deleted)-")
|
||||
|
||||
s.udmSubService.LoadData(neId, imsi, num, "-(Deleted)-")
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
@@ -442,11 +370,6 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
|
||||
querys["pageNum"] = 1
|
||||
querys["pageSize"] = 10000
|
||||
|
||||
// for multi-tenancy
|
||||
querys["userName"] = ctx.LoginUserToUserName(c)
|
||||
querys["neId"] = ""
|
||||
|
||||
data := s.udmSubService.SelectPage(querys)
|
||||
if parse.Number(data["total"]) == 0 {
|
||||
// 导出数据记录为空
|
||||
@@ -469,14 +392,13 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
if fileType == "csv" {
|
||||
// 转换数据
|
||||
data := [][]string{}
|
||||
data = append(data, []string{"imsi", "msisdn", "ambr", "nssai", "arfb", "sar", "rat", "cn", "smf_sel", "sm_dat", "eps_dat", "tenant_name"})
|
||||
data = append(data, []string{"IMSI", "MSISDN", "UeAmbrTpl", "NssaiTpl", "AreaForbiddenTpl", "ServiceAreaRestrictionTpl", "RatRestrictions", "CnTypeRestrictions", "SmfSel", "SmData", "EPSDat"})
|
||||
for _, v := range rows {
|
||||
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
|
||||
data = append(data, []string{v.IMSI, v.MSISDN, v.Ambr, v.Nssai, v.Arfb, v.Sar, v.Rat, v.Cn, v.SmfSel, v.SmData, epsDat, v.TenantName})
|
||||
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat})
|
||||
}
|
||||
// 输出到文件
|
||||
err := file.WriterFileCSV(data, filePath)
|
||||
if err != nil {
|
||||
if err := file.WriterFileCSV(data, filePath); err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -487,11 +409,10 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
data := [][]string{}
|
||||
for _, v := range rows {
|
||||
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
|
||||
data = append(data, []string{v.IMSI, v.MSISDN, v.Ambr, v.Nssai, v.Arfb, v.Sar, v.Rat, v.Cn, v.SmfSel, v.SmData, epsDat, v.TenantName})
|
||||
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat})
|
||||
}
|
||||
// 输出到文件
|
||||
err := file.WriterFileTXT(data, ",", filePath)
|
||||
if err != nil {
|
||||
if err := file.WriterFileTXT(data, ",", filePath); err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -571,13 +492,11 @@ func (s *UDMSubController) Import(c *gin.Context) {
|
||||
if strings.Contains(data, "ok") {
|
||||
if strings.HasSuffix(body.UploadPath, ".csv") {
|
||||
data := file.ReadFileCSV(localFilePath)
|
||||
neId := ""
|
||||
go s.udmSubService.InsertData(neId, "csv", data)
|
||||
go s.udmSubService.InsertData(neInfo.NeId, "csv", data)
|
||||
}
|
||||
if strings.HasSuffix(body.UploadPath, ".txt") {
|
||||
data := file.ReadFileTXT(",", localFilePath)
|
||||
neId := ""
|
||||
go s.udmSubService.InsertData(neId, "txt", data)
|
||||
go s.udmSubService.InsertData(neInfo.NeId, "txt", data)
|
||||
}
|
||||
}
|
||||
c.JSON(200, result.OkMsg(data))
|
||||
|
||||
@@ -10,19 +10,17 @@ import (
|
||||
)
|
||||
|
||||
// 实例化控制层 UPFController 结构体
|
||||
var NewUPFController = &UPFController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
perfKPIService: neDataService.NewPerfKPIImpl,
|
||||
var NewUPF = &UPFController{
|
||||
neInfoService: neService.NewNeInfo,
|
||||
perfKPIService: neDataService.NewPerfKPI,
|
||||
}
|
||||
|
||||
// 网元UPF
|
||||
//
|
||||
// PATH /upf
|
||||
type UPFController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// 统计信息服务
|
||||
perfKPIService neDataService.IPerfKPI
|
||||
neInfoService *neService.NeInfo // 网元信息服务
|
||||
perfKPIService *neDataService.PerfKPI // 统计信息服务
|
||||
}
|
||||
|
||||
// 总流量数 N3上行 N6下行
|
||||
|
||||
Reference in New Issue
Block a user