perf: 更新UDM签约数据表,同步数据支持MICO和RAT操作修改
This commit is contained in:
@@ -142,7 +142,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()))
|
||||
@@ -191,7 +192,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()))
|
||||
@@ -239,20 +241,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()))
|
||||
|
||||
@@ -141,12 +141,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()))
|
||||
@@ -196,8 +192,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)
|
||||
@@ -249,65 +245,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()))
|
||||
@@ -450,10 +389,10 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
if body.Type == "csv" {
|
||||
// 转换数据
|
||||
data := [][]string{}
|
||||
data = append(data, []string{"imsi", "msisdn", "ambr", "nssai", "arfb", "sar", "rat", "cn", "smf_sel", "sm_dat", "eps_dat"})
|
||||
data = append(data, []string{"IMSI", "MSISDN", "UeAmbrTpl", "NssaiTpl", "AreaForbiddenTpl", "ServiceAreaRestrictionTpl", "RatRestrictions", "CnTypeRestrictions", "SmfSel", "SmData", "EPSDat"})
|
||||
for _, v := range list {
|
||||
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})
|
||||
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)
|
||||
@@ -468,7 +407,7 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
data := [][]string{}
|
||||
for _, v := range list {
|
||||
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})
|
||||
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)
|
||||
|
||||
@@ -3,13 +3,13 @@ package model
|
||||
// UDMAuthUser UDM鉴权用户 u_auth_user
|
||||
type UDMAuthUser struct {
|
||||
ID string `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 默认ID
|
||||
IMSI string `json:"imsi" gorm:"imsi"` // SIM卡/USIM卡ID
|
||||
NeId string `json:"neId" gorm:"ne_id"` // UDM网元标识
|
||||
Amf string `json:"amf" gorm:"amf"` // AMF
|
||||
Status string `json:"status" gorm:"status"` // 状态
|
||||
Ki string `json:"ki" gorm:"ki"` // ki
|
||||
AlgoIndex string `json:"algoIndex" gorm:"algo_index"` // algoIndex
|
||||
Opc string `json:"opc" gorm:"opc"` // OPC
|
||||
IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID
|
||||
NeId string `json:"neId" gorm:"column:ne_id"` // UDM网元标识
|
||||
Amf string `json:"amf" gorm:"column:amf"` // AMF
|
||||
Status string `json:"status" gorm:"column:status"` // 状态
|
||||
Ki string `json:"ki" gorm:"column:ki"` // ki
|
||||
AlgoIndex string `json:"algoIndex" gorm:"column:algo_index"` // algoIndex
|
||||
Opc string `json:"opc" gorm:"column:opc"` // OPC
|
||||
}
|
||||
|
||||
// TableName 表名称
|
||||
|
||||
@@ -2,28 +2,40 @@ package model
|
||||
|
||||
// UDMSubUser UDM签约用户 u_sub_user
|
||||
type UDMSubUser struct {
|
||||
ID string `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
IMSI string `json:"imsi" gorm:"imsi"` // SIM卡/USIM卡ID
|
||||
MSISDN string `json:"msisdn" gorm:"msisdn"` // 用户电话号码
|
||||
NeId string `json:"neId" gorm:"ne_id"` // UDM网元标识
|
||||
Ambr string `json:"ambr" gorm:"ambr"` // SubUeAMBRTemp
|
||||
Nssai string `json:"nssai" gorm:"nssai"` // SubSNSSAITemp
|
||||
Rat string `json:"rat" gorm:"rat"` // rat VIRTUAL|WLAN|EUTRA|NR
|
||||
Arfb string `json:"arfb" gorm:"arfb"` // forbiddenAreasTemp
|
||||
Sar string `json:"sar" gorm:"sar"` // serviceAreaRestrictTemp
|
||||
Cn string `json:"cn" gorm:"cn"` // cnType EPC|5GC
|
||||
SmData string `json:"smData" gorm:"sm_data"` // smData
|
||||
SmfSel string `json:"smfSel" gorm:"smf_sel"` // smfSel
|
||||
EpsDat string `json:"epsDat" gorm:"eps_dat"` // Eps
|
||||
EpsFlag string `json:"epsFlag" gorm:"eps_flag"` // epsFlag
|
||||
EpsOdb string `json:"epsOdb" gorm:"eps_odb"` // epsOdb
|
||||
HplmnOdb string `json:"hplmnOdb" gorm:"hplmn_odb"` // hplmnOdb
|
||||
Ard string `json:"ard" gorm:"ard"` // Ard
|
||||
Epstpl string `json:"epstpl" gorm:"epstpl"` // Epstpl
|
||||
ContextId string `json:"contextId" gorm:"context_id"` // ContextId
|
||||
ApnContext string `json:"apnContext" gorm:"apn_context"` // apnContext
|
||||
StaticIp string `json:"staticIp" gorm:"static_ip"` // staticIpstatic_ip指给4G UE分配的静态IP,没有可不带此字段名
|
||||
Cag string `json:"cag" gorm:"cag"` // CAG
|
||||
ID string `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // 主键
|
||||
IMSI string `json:"imsi" gorm:"column:imsi"` // SIM卡/USIM卡ID
|
||||
MSISDN string `json:"msisdn" gorm:"column:msisdn"` // 用户电话号码
|
||||
NeId string `json:"neId" gorm:"column:ne_id"` // UDM网元标识
|
||||
|
||||
AmDat string `json:"amDat" gorm:"column:am_dat"` // AmData
|
||||
UeAmbrTpl string `json:"ambr" gorm:"column:ambr"` // AmData SubUeAMBRTemp
|
||||
NssaiTpl string `json:"nssai" gorm:"column:nssai"` // AmData SubSNSSAITemp
|
||||
RatRestrictions string `json:"rat" gorm:"column:rat"` // AmData RAT 0x00:VIRTUAL 0x01:WLAN 0x02:EUTRA 0x03:NR
|
||||
AreaForbiddenTpl string `json:"arfb" gorm:"column:arfb"` // AmData AreaForbidden
|
||||
ServiceAreaRestrictionTpl string `json:"sar" gorm:"column:sar"` // AmData serviceAreaRestrictTemp
|
||||
CnTypeRestrictions string `json:"cnType" gorm:"column:cn_type"` // AmData CNType 0x00:EPC和5GC 0x01:5GC 0x02:EPC 0x03:EPC+5GC
|
||||
RfspIndex string `json:"rfspIndex" gorm:"column:rfsp_index"` // AmData RfspIndex
|
||||
SubsRegTime string `json:"regTimer" gorm:"column:reg_timer"` // AmData RegTimer
|
||||
UeUsageType string `json:"ueUsageType" gorm:"column:ue_usage_type"` // AmData UEUsageType
|
||||
ActiveTime string `json:"activeTime" gorm:"column:active_time"` // AmData ActiveTime
|
||||
MicoAllowed string `json:"mico" gorm:"column:mico"` // AmData MICO
|
||||
OdbPs string `json:"odbPs" gorm:"column:odb_ps"` // AmData ODB_PS 0-all,1-hplmn,2-vplmn
|
||||
GroupId string `json:"groupId" gorm:"column:group_id"` // AmData GroupId
|
||||
|
||||
EpsDat string `json:"epsDat" gorm:"column:eps_dat"` // EpsDat
|
||||
EpsFlag string `json:"epsFlag" gorm:"column:eps_flag"` // EpsDat epsFlag
|
||||
EpsOdb string `json:"epsOdb" gorm:"column:eps_odb"` // EpsDat epsOdb
|
||||
HplmnOdb string `json:"hplmnOdb" gorm:"column:hplmn_odb"` // EpsDat hplmnOdb
|
||||
Ard string `json:"ard" gorm:"column:ard"` // EpsDat Ard
|
||||
Epstpl string `json:"epstpl" gorm:"column:epstpl"` // EpsDat Epstpl
|
||||
ContextId string `json:"contextId" gorm:"column:context_id"` // EpsDat ContextId
|
||||
ApnNum string `json:"apnNum" gorm:"column:apn_mum"` // EpsDat apnNum
|
||||
ApnContext string `json:"apnContext" gorm:"column:apn_context"` // EpsDat apnContext
|
||||
StaticIp string `json:"staticIp" gorm:"column:static_ip"` // EpsDat staticIp 指给4G UE分配的静态IP,没有可不带此字段名
|
||||
|
||||
SmData string `json:"smData" gorm:"column:sm_data"` // smData
|
||||
SmfSel string `json:"smfSel" gorm:"column:smf_sel"` // smfSel
|
||||
Cag string `json:"cag" gorm:"column:cag"` // CAG
|
||||
|
||||
// ====== 非数据库字段属性 ======
|
||||
|
||||
|
||||
@@ -14,23 +14,33 @@ import (
|
||||
// 实例化数据层 UDMSubUser 结构体
|
||||
var NewUDMSub = &UDMSubUser{
|
||||
selectSql: `select
|
||||
id, imsi, msisdn, ne_id, ambr, nssai, rat, arfb, sar, cn, sm_data, smf_sel,
|
||||
eps_dat, eps_flag, eps_odb, hplmn_odb, ard, epstpl, context_id, apn_context, static_ip, cag
|
||||
id, imsi, msisdn, ne_id,
|
||||
am_dat, ambr, nssai, rat, arfb, sar, cn_type, rfsp_index, reg_timer, ue_usage_type, active_time, mico, odb_ps, group_id,
|
||||
eps_dat, eps_flag, eps_odb, hplmn_odb, ard, epstpl, context_id, apn_mum, apn_context, static_ip,
|
||||
sm_data, smf_sel, cag
|
||||
from u_sub_user`,
|
||||
|
||||
resultMap: map[string]string{
|
||||
"id": "ID",
|
||||
"imsi": "IMSI",
|
||||
"msisdn": "MSISDN",
|
||||
"ne_id": "NeId",
|
||||
"ambr": "Ambr",
|
||||
"nssai": "Nssai",
|
||||
"rat": "Rat",
|
||||
"arfb": "Arfb",
|
||||
"sar": "Sar",
|
||||
"cn": "Cn",
|
||||
"sm_data": "SmData",
|
||||
"smf_sel": "SmfSel",
|
||||
"id": "ID",
|
||||
"imsi": "IMSI",
|
||||
"msisdn": "MSISDN",
|
||||
"ne_id": "NeId",
|
||||
|
||||
"am_dat": "AmDat",
|
||||
"ambr": "UeAmbrTpl",
|
||||
"nssai": "NssaiTpl",
|
||||
"rat": "RatRestrictions",
|
||||
"arfb": "AreaForbiddenTpl",
|
||||
"sar": "ServiceAreaRestrictionTpl",
|
||||
"cn_type": "CnTypeRestrictions",
|
||||
"rfsp_index": "RfspIndex",
|
||||
"reg_timer": "SubsRegTime",
|
||||
"ue_usage_type": "UeUsageType",
|
||||
"active_time": "ActiveTime",
|
||||
"mico": "MicoAllowed",
|
||||
"odb_ps": "OdbPs",
|
||||
"group_id": "GroupId",
|
||||
|
||||
"eps_dat": "EpsDat",
|
||||
"eps_flag": "EpsFlag",
|
||||
"eps_odb": "EpsOdb",
|
||||
@@ -38,9 +48,13 @@ var NewUDMSub = &UDMSubUser{
|
||||
"ard": "Ard",
|
||||
"epstpl": "Epstpl",
|
||||
"context_id": "ContextId",
|
||||
"apn_mum": "ApnNum",
|
||||
"apn_context": "ApnContext",
|
||||
"static_ip": "StaticIp",
|
||||
"cag": "Cag",
|
||||
|
||||
"sm_data": "SmData",
|
||||
"smf_sel": "SmfSel",
|
||||
"cag": "Cag",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -69,21 +69,16 @@ func (r *UDMAuthUser) ResetData(neId string) int64 {
|
||||
|
||||
// ParseInfo 解析单个用户imsi鉴权信息 data从命令MML得到的结果
|
||||
func (r *UDMAuthUser) ParseInfo(imsi, neId string, data map[string]string) model.UDMAuthUser {
|
||||
u := model.UDMAuthUser{
|
||||
IMSI: imsi,
|
||||
NeId: neId,
|
||||
Amf: data["amf"],
|
||||
Status: "1",
|
||||
Ki: data["ki"],
|
||||
AlgoIndex: data["algo"],
|
||||
Opc: data["opc"],
|
||||
}
|
||||
u := r.udmAuthRepository.SelectByIMSIAndNeID(imsi, neId)
|
||||
|
||||
// 补充用户ID用于更新
|
||||
auth := r.udmAuthRepository.SelectByIMSIAndNeID(imsi, neId)
|
||||
if auth.IMSI == imsi {
|
||||
u.ID = auth.ID
|
||||
}
|
||||
// 用于更新
|
||||
u.IMSI = imsi
|
||||
u.NeId = neId
|
||||
u.Amf = data["amf"]
|
||||
u.Ki = data["ki"]
|
||||
u.AlgoIndex = data["algo"]
|
||||
u.Opc = data["opc"]
|
||||
u.Status = "1"
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -170,3 +165,22 @@ func (r *UDMAuthUser) LoadData(neId, imsi, num string) {
|
||||
r.udmAuthRepository.Inserts(arr)
|
||||
}
|
||||
}
|
||||
|
||||
// ParseCommandParams 解析数据组成命令参数 ki=xx,xx=xx,...
|
||||
func (r *UDMAuthUser) ParseCommandParams(item model.UDMAuthUser) string {
|
||||
var conditions []string
|
||||
if item.Ki != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("ki=%s", item.Ki))
|
||||
}
|
||||
|
||||
if item.Amf != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("amf=%s", item.Amf))
|
||||
}
|
||||
if item.AlgoIndex != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("algo=%s", item.AlgoIndex))
|
||||
}
|
||||
if item.Opc != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("opc=%s", item.Opc))
|
||||
}
|
||||
return strings.Join(conditions, ",")
|
||||
}
|
||||
|
||||
@@ -50,12 +50,29 @@ func (r *UDMSubUser) dataByRedis(imsi, neId string) []model.UDMSubUser {
|
||||
// def_ambr,def_nssai,0,def_arfb,def_sar,3,1,12000,1,1000,0,1,-
|
||||
if v, ok := m["am-dat"]; ok {
|
||||
arr := strings.Split(v, ",")
|
||||
a.Ambr = arr[0]
|
||||
a.Nssai = arr[1]
|
||||
a.Rat = arr[2]
|
||||
a.Arfb = arr[3]
|
||||
a.Sar = arr[4]
|
||||
a.Cn = arr[5]
|
||||
a.AmDat = v
|
||||
a.UeAmbrTpl = arr[0]
|
||||
a.NssaiTpl = arr[1]
|
||||
a.RatRestrictions = arr[2]
|
||||
a.AreaForbiddenTpl = arr[3]
|
||||
a.ServiceAreaRestrictionTpl = arr[4]
|
||||
a.CnTypeRestrictions = arr[5]
|
||||
a.RfspIndex = arr[6]
|
||||
a.SubsRegTime = arr[7]
|
||||
a.UeUsageType = arr[8]
|
||||
a.ActiveTime = arr[9]
|
||||
a.MicoAllowed = "0" // arr[10]
|
||||
a.OdbPs = "1" // arr[11]
|
||||
a.GroupId = "-" // arr[12]
|
||||
if len(arr) > 10 {
|
||||
a.MicoAllowed = arr[10]
|
||||
}
|
||||
if len(arr) > 11 {
|
||||
a.OdbPs = arr[11]
|
||||
}
|
||||
if len(arr) > 12 && arr[12] != "-" {
|
||||
a.GroupId = arr[12]
|
||||
}
|
||||
}
|
||||
// 1,64,24,65,def_eps,1,2,010200000000,-
|
||||
if v, ok := m["eps-dat"]; ok {
|
||||
@@ -71,9 +88,11 @@ func (r *UDMSubUser) dataByRedis(imsi, neId string) []model.UDMSubUser {
|
||||
a.Ard = arr[3]
|
||||
a.Epstpl = arr[4]
|
||||
a.ContextId = arr[5]
|
||||
a.ApnNum = arr[6] // 导入和导出不用
|
||||
a.ApnContext = arr[7]
|
||||
// [6] 是不要的,导入和导出不用
|
||||
a.StaticIp = arr[8]
|
||||
if len(arr) >= 9 {
|
||||
a.StaticIp = arr[8]
|
||||
}
|
||||
}
|
||||
|
||||
arr = append(arr, a)
|
||||
@@ -91,27 +110,30 @@ func (r *UDMSubUser) ResetData(neId string) int64 {
|
||||
|
||||
// ParseInfo 解析单个用户imsi签约信息 data从命令MML得到的结果
|
||||
func (r *UDMSubUser) ParseInfo(imsi, neId string, data map[string]string) model.UDMSubUser {
|
||||
cnType, _ := strconv.ParseInt(data["CNType"][:4], 0, 64)
|
||||
rat, _ := strconv.ParseInt(data["RAT"][:4], 0, 64)
|
||||
u := r.udmSubRepository.SelectByIMSIAndNeID(imsi, neId)
|
||||
|
||||
cnType, _ := strconv.ParseInt(data["CNType"][:4], 0, 64) // 0x03(EPC|5GC)
|
||||
rat, _ := strconv.ParseInt(data["RAT"][:4], 0, 64) // 0x00(VIRTUAL|WLAN|EUTRA|NR)
|
||||
msisdn := data["MSISDN"]
|
||||
if imsMsisdnLen := strings.Index(msisdn, ","); imsMsisdnLen != -1 {
|
||||
msisdn = msisdn[:imsMsisdnLen]
|
||||
}
|
||||
|
||||
u := model.UDMSubUser{
|
||||
IMSI: imsi,
|
||||
MSISDN: msisdn,
|
||||
NeId: neId,
|
||||
Ambr: data["AMBR"],
|
||||
Arfb: data["AreaForbidden"],
|
||||
Cn: fmt.Sprint(cnType),
|
||||
SmData: data["SM-Data(snssai+dnn[1..n])"],
|
||||
Sar: data["ServiceAreaRestriction"],
|
||||
Nssai: data["NSSAI"],
|
||||
SmfSel: data["Smf-Selection"],
|
||||
Cag: data["cag"],
|
||||
Rat: fmt.Sprint(rat),
|
||||
}
|
||||
// 用于更新
|
||||
u.IMSI = imsi
|
||||
u.MSISDN = msisdn
|
||||
u.NeId = neId
|
||||
u.UeAmbrTpl = data["AMBR"]
|
||||
u.NssaiTpl = data["NSSAI"]
|
||||
u.AreaForbiddenTpl = data["AreaForbidden"]
|
||||
u.ServiceAreaRestrictionTpl = data["ServiceAreaRestriction"]
|
||||
u.CnTypeRestrictions = fmt.Sprint(cnType)
|
||||
u.RatRestrictions = fmt.Sprint(rat)
|
||||
u.MicoAllowed = data["MICO"]
|
||||
u.SmData = data["SM-Data(snssai+dnn[1..n])"]
|
||||
u.SmfSel = data["Smf-Selection"]
|
||||
u.Cag = data["cag"]
|
||||
|
||||
// 1,64,24,65,def_eps,1,2,010200000000,-
|
||||
if v, ok := data["EPS-Data"]; ok {
|
||||
u.EpsDat = v
|
||||
@@ -122,16 +144,11 @@ func (r *UDMSubUser) ParseInfo(imsi, neId string, data map[string]string) model.
|
||||
u.Ard = arr[3]
|
||||
u.Epstpl = arr[4]
|
||||
u.ContextId = arr[5]
|
||||
u.ApnNum = arr[6] // 导入和导出不用
|
||||
u.ApnContext = arr[7]
|
||||
// [6] 是不要的,导入和导出不用
|
||||
u.StaticIp = arr[8]
|
||||
}
|
||||
|
||||
// 补充用户ID用于更新
|
||||
sub := r.udmSubRepository.SelectByIMSIAndNeID(imsi, neId)
|
||||
if sub.IMSI == imsi {
|
||||
u.ID = sub.ID
|
||||
}
|
||||
// 补充用户拓展信息
|
||||
info := r.udmUserInfoRepository.SelectByIMSIAndNeID(imsi, neId)
|
||||
if info.IMSI == imsi {
|
||||
@@ -252,3 +269,75 @@ func (r *UDMSubUser) LoadData(neId, imsi, num, remark string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ParseCommandParams 解析数据组成命令参数 msisdn=xx,xx=xx,...
|
||||
func (r *UDMSubUser) ParseCommandParams(item model.UDMSubUser) string {
|
||||
var conditions []string
|
||||
if item.MSISDN != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("msisdn=%s", item.MSISDN))
|
||||
}
|
||||
|
||||
// AmData
|
||||
if item.UeAmbrTpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("ambr=%s", item.UeAmbrTpl))
|
||||
}
|
||||
if item.NssaiTpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("nssai=%s", item.NssaiTpl))
|
||||
}
|
||||
if item.AreaForbiddenTpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("arfb=%s", item.AreaForbiddenTpl))
|
||||
}
|
||||
if item.ServiceAreaRestrictionTpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("sar=%s", item.ServiceAreaRestrictionTpl))
|
||||
}
|
||||
if item.RatRestrictions != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("rat=%s", item.RatRestrictions))
|
||||
}
|
||||
if item.CnTypeRestrictions != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("cn=%s", item.CnTypeRestrictions))
|
||||
}
|
||||
if item.MicoAllowed != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("mico=%s", item.MicoAllowed))
|
||||
}
|
||||
|
||||
// EpsDat
|
||||
// if item.EpsDat != "" {
|
||||
// conditions = append(conditions, fmt.Sprintf("eps_dat=%s", item.EpsDat))
|
||||
// }
|
||||
if item.EpsFlag != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("eps_flag=%s", item.EpsFlag))
|
||||
}
|
||||
if item.EpsOdb != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("eps_odb=%s", item.EpsOdb))
|
||||
}
|
||||
if item.HplmnOdb != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("hplmn_odb=%s", item.HplmnOdb))
|
||||
}
|
||||
if item.Epstpl != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("epstpl=%s", item.Epstpl))
|
||||
}
|
||||
if item.Ard != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("ard=%s", item.Ard))
|
||||
}
|
||||
if item.ContextId != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("context_id=%s", item.ContextId))
|
||||
}
|
||||
if item.ApnContext != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("apn_context=%s", item.ApnContext))
|
||||
}
|
||||
if item.StaticIp != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("static_ip=%s", item.StaticIp))
|
||||
}
|
||||
|
||||
// 其他
|
||||
if item.SmfSel != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("smf_sel=%s", item.SmfSel))
|
||||
}
|
||||
if item.SmData != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("sm_data=%s", item.SmData))
|
||||
}
|
||||
if item.Cag != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("cag=%s", item.Cag))
|
||||
}
|
||||
return strings.Join(conditions, ",")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user