feat: 网元参数配置数据支持版本区分功能

feat(database): add ne_version and schema columns to ne_info table

feat(database): update ne_info table structure in upgrade script

fix(ne_config): handle id as number in Info and Add methods

fix(ne_config): validate neId and fetch neInfo in ListByNeType and DataAdd methods

fix(ne_info): extract version from ServerState in Add and Edit methods

refactor(ne_config): update NeConfig model to include NeVersion

refactor(ne_info): add NeVersion and Schema fields to NeInfo model

test(ne_config): enhance test cases to include version parsing and saving

refactor(ne_config): improve cache handling and querying by NeType and NeVersion

fix(ne_info): update NeInfo version during status change
This commit is contained in:
TsMask
2025-10-17 10:17:07 +08:00
parent 3b053d7f47
commit 8cd86a62d6
18 changed files with 1306 additions and 254 deletions

View File

@@ -469,23 +469,23 @@ amf:
type: "int"
value: "0"
access: "read-only"
filter: "0~15"
filter: "0-32"
display: "Index"
comment: "0~15"
comment: "Max 32"
- name: "plmnId"
type: "regex"
value: "00101"
access: "read-write"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
comment: ""
comment: "MCC and MNC is less than 6 digits."
- name: "tac"
type: "string"
value: "1"
access: "read-write"
filter: "0~8"
filter: "0-16777215"
display: "TAC"
comment: "0~16777215"
comment: "Multiple TACs separated by commas (tac1,tac2)"
slice:
display: "AMF Support Slice List"
sort: 11

View File

@@ -449,12 +449,12 @@ mme:
display: "Index"
comment: "0~65535"
- name: "imei"
type: "string"
value: "001"
type: "regex"
value: ""
access: "read-write"
filter: "0~64"
filter: "^([0-9]{3,16})$"
display: "IMEI"
comment: "0~64"
comment: "Only check IMEI Prefix, IMEI value is imei prefix value[0-9]{3-16} e.g:'86958304522' )"
enbList:
display: "Enb List Config"
sort: 19

View File

@@ -0,0 +1,423 @@
mme:
system:
display: "System Config"
sort: 1
list:
- name: "mmeName"
type: "string"
value: "MME1"
filter: "0~32"
display: "MME Name"
- name: "networkName.full"
type: "string"
value: "EPC"
filter: "0~64"
display: "Full Network Name"
- name: "networkName.short"
type: "string"
value: "Next"
filter: "0~16"
display: "Short Network Name"
- name: "s1.mtu"
type: "int"
value: "1500"
access: "read-write"
filter: "576~9000"
display: "MTU"
comment: "Maximum Transmission Unit"
- name: "s1.address"
type: "string"
value: "192.168.8.220"
access: "read-write"
filter: "IP"
display: "S1 Local Address"
comment: "Local IP for S1 interface"
- name: "s6a.local.address"
type: "string"
value: "172.16.5.220"
access: "read-write"
filter: "IP"
display: "Local S6a IP"
comment: "Local IP for Diameter S6a"
- name: "s6a.local.host"
type: "string"
value: "mme.epc.mnc001.mcc001.3gppnetwork.org"
access: "read-write"
filter: "0~128"
display: "Local Hostname"
comment: "MME Diameter Host FQDN"
- name: "s6a.local.realm"
type: "string"
value: "epc.mnc001.mcc001.3gppnetwork.org"
access: "read-write"
filter: "0~128"
display: "Local Realm"
comment: "Diameter Realm"
- name: "s11.local.address"
type: "string"
value: "172.16.5.220"
access: "read-write"
filter: "IP"
display: "Local S11 IP"
- name: "n26.local.address"
type: "string"
value: "172.16.5.210"
access: "read-write"
filter: "IP"
display: "Local N26 IP"
- name: "t3402.value"
type: "string"
value: "12m"
filter: "1s~60m"
display: "T3402 Timer"
- name: "t3412.value"
type: "string"
value: "54m"
display: "T3412 Timer"
- name: "t3423.value"
type: "string"
value: "12m"
display: "T3423 Timer"
- name: "message.gtp.t3ResponseDuration"
type: "string"
value: "2s"
display: "GTP Response Timeout"
- name: "message.gtp.n3ResponseRcount"
type: "int"
value: "3"
display: "GTP Response Retries"
- name: "message.gtp.t3HoldingDuration"
type: "string"
value: "6s"
display: "GTP Holding Duration"
- name: "message.gtp.n3HoldingRcount"
type: "int"
value: "1"
display: "GTP Holding Retries"
- name: "message.s6a"
type: "string"
value: "3s"
display: "S6a Timeout"
- name: "handover.value"
type: "string"
value: "300ms"
display: "Handover Timeout"
- name: "s1Flex.instance"
type: "int"
value: "0"
access: "read-write"
filter: "0~2"
display: "mme instance id for s1 flex"
comment: "mme instance id for s1 flex"
- name: "redisDb.enable"
type: "bool"
value: "false"
access: "read-write"
filter: '{"0":"false","1":"true"}'
display: "Enable Redis"
comment: "true|false"
- name: "redisDb.netType"
type: "string"
value: "tcp"
access: "read-write"
filter: '{"tcp":"tcp"}'
display: "Network Type"
comment: "Network type for Redis (tcp)"
- name: "redisDb.addr"
type: "string"
value: "172.16.5.140:6379"
access: "read-write"
filter: "IP:Port"
display: "Redis Master Address"
comment: "IP:Port format"
- name: "redisDb.slaveAddrList"
type: "string"
value: "172.16.5.148:6379"
access: "read-write"
filter: "IP:Port"
display: "Redis Slave Addresses"
comment: "List of Redis slaves for replication"
- name: "redisDb.poolSize"
type: "int"
value: "10"
access: "read-write"
filter: "1~1000"
display: "Connection Pool Size"
comment: "Max Redis connection pool size"
- name: "relativeCapacity"
type: "int"
value: "255"
filter: "0~255"
display: "MME Relative Capacity"
comment: "Used for load balancing among MMEs"
- name: "logDir"
type: "string"
value: "/var/log/"
access: "read-write"
filter: "0~128"
display: "Log Directory"
comment: "Directory where log files will be stored"
- name: "logNum"
type: "int"
value: "10"
access: "read-write"
filter: "1~100"
display: "Log File Count"
comment: "Maximum number of log files to retain"
- name: "logSize"
type: "int"
value: "200"
access: "read-write"
filter: "1~10000"
display: "Log File Size (MB)"
comment: "Max size per log file"
- name: "logLevel"
type: "enum"
value: "debug"
access: "read-write"
filter: '{"debug":"debug","info":"info","warn":"warn","error":"error"}'
display: "Log Level"
comment: "debug|info|warn|error"
gummei:
display: "GUMMEI List"
sort: 3
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "regex"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "mmeGid"
type: "int"
value: "2"
filter: "0~65535"
display: "MME Group ID"
- name: "mmeCode"
type: "int"
value: "1"
filter: "0~255"
display: "MME Code"
servedTai:
display: "TAI List"
sort: 4
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "regex"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "tac"
type: "int"
value: "1"
filter: "0~65535"
display: "TAC"
s6a:
display: "HSS List"
sort: 5
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "address"
type: "string"
value: "172.16.5.221"
filter: "IP"
display: "HSS Address"
- name: "priority"
type: "int"
value: "1"
filter: "1~10"
display: "Priority"
- name: "plmnList"
type: "array"
display: "PLMN IDs"
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "string"
value: ["00101"]
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
s11:
display: "SGW List"
sort: 9
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "address"
type: "string"
value: "172.16.5.222"
filter: "IP"
display: "SGW Address"
- name: "priority"
type: "int"
value: "1"
filter: "1~10"
display: "Priority"
- name: "tai"
type: "array"
display: "Tracking Areas"
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "string"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "tac"
type: "int"
value: "1"
filter: "0~65535"
display: "TAC"
s5s8:
display: "PGW List"
sort: 11
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "address"
type: "string"
value: "172.16.5.223"
filter: "IP"
display: "PGW Address"
- name: "priority"
type: "int"
value: "1"
filter: "1~10"
display: "Priority"
- name: "servedApn"
type: "array"
display: "Served APNs"
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "string"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "apn"
type: "string"
value: "internet"
filter: "0~128"
display: "APN"
n26:
display: "AMF List"
sort: 13
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "address"
type: "string"
value: "172.16.5.224"
filter: "IP"
display: "AMF Address"
- name: "priority"
type: "int"
value: "1"
filter: "1~10"
display: "Priority"
- name: "tai"
type: "array"
display: "Tracking Areas"
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "string"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "tac"
type: "int"
value: "1"
filter: "0~65535"
display: "TAC"
enbList:
display: "Enb List Config"
sort: 19
visible: "hide"
array:
- name: "index"
type: "int"
value: "0"
access: "read-only"
filter: "0~128"
display: "Index"
comment: "0~128"
- name: "name"
type: "string"
value: ""
access: "read-write"
filter: "0~64"
display: "ENB Name"
comment: "text content length 0~64"
- name: "address"
type: "string"
value: ""
access: "read-write"
filter: "0~64"
display: "ENB Address"
comment: "text content length 0~64"
- name: "position"
type: "string"
value: ""
access: "read-write"
filter: "0~64"
display: "Position"
comment: "location description. Prohibition of spaces, length of text content 0-64"

View File

@@ -0,0 +1,534 @@
pgwc:
pgwcSystem:
display: "PGWC Sytem Config"
sort: 1
list:
- name: "s58Ip"
type: "string"
value: "172.16.5.151"
access: "read-write"
filter: ''
display: "Local S58 IP"
comment: ""
- name: "n4Ipv4"
type: "ipv4"
value: "172.16.5.150"
access: "read-write"
filter: ""
display: "N4 IPv4"
comment: ""
- name: "n4Ipv6"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "N4 IPv6"
comment: ""
- name: "n4UIpv4"
type: "ipv4"
value: ""
access: "read-write"
filter: ""
display: "N4U IPv4"
comment: ""
- name: "n4UIpv6"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "N4U IPv6"
comment: ""
- name: "gxEnable"
type: "bool"
value: ""
access: "read-write"
filter: ''
display: "Gx Policy Enable"
comment: ""
- name: "gxChargingEnable"
type: "bool"
value: ""
access: "read-write"
filter: ''
display: "Gx Charging Enable"
comment: ""
- name: "gyChargingEnable"
type: "bool"
value: ""
access: "read-write"
filter: ''
display: "Gy Charging Enable"
comment: ""
- name: "primaryDnsIpv4"
type: "ipv4"
value: "114.114.114.114"
access: "read-write"
filter: ""
display: "Primary DNS IPv4"
comment: ""
- name: "secondaryDnsIpv4"
type: "ipv4"
value: ""
access: "read-write"
filter: ""
display: "Secondary DNS IPv4"
comment: ""
- name: "primaryDnsIpv6"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "Primary DNS IPv6"
comment: ""
- name: "secondaryDnsIpv6"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "Secondary DNS IPv6"
comment: ""
- name: "primaryPcscfIpv4"
type: "ipv4"
value: "172.16.5.110"
access: "read-write"
filter: ""
display: "Primary PCSCF IPv4"
comment: ""
- name: "secondaryPcscfIpv4"
type: "ipv4"
value: ""
access: "read-write"
filter: ""
display: "Secondary PCSCF IPv4"
comment: ""
- name: "primaryPcscfIpv6"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "Primary PCSCF IPv6"
comment: ""
- name: "secondaryPcscfIpv6"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "Secondary PCSCF IPv6"
comment: ""
- name: "ueMtu"
type: "int"
value: ""
access: "read-write"
filter: "0~65535"
display: "UE MTU"
comment: ""
localDiameterConfig:
display: "Local Diameter Config"
sort: 3
list:
- name: "ipAddr"
type: "string"
value: "172.16.5.150"
access: "read-write"
filter: ''
display: "Local Diameter IP"
comment: ""
- name: "hostName"
type: "string"
value: "pgwc.mnc001.mcc001.3gppnetwork.org"
access: "read-write"
filter: ''
display: "Local Diameter Host Name"
comment: ""
- name: "realmName"
type: "string"
value: "mnc001.mcc001.3gppnetwork.org"
access: "read-write"
filter: ''
display: "Local Diameter Realm Name"
comment: ""
- name: "gyServiceContextId"
type: "string"
value: "gy@3gpp"
access: "read-write"
filter: ''
display: "Local Gy Service Context ID"
comment: ""
- name: "gxServiceContextId"
type: "string"
value: "gx@3gpp"
access: "read-write"
filter: ''
display: "Local Gx Service Context ID"
comment: ""
remoteGyCfg:
display: "Remote Gy Config"
sort: 5
list:
- name: "enable"
type: "bool"
value: 'false'
access: "read-write"
filter: ""
display: "Remote Gy Enable"
comment: ""
- name: "remoteAddrs"
type: "string"
value: ""
access: "read-write"
filter: ''
display: "Remote Gy Addresses"
comment: "e.g. ipv4:port;ipv4:port;ipv4:port"
remoteGxCfg:
display: "Remote Gx Config"
sort: 7
list:
- name: "enable"
type: "bool"
value: 'false'
access: "read-write"
filter: ""
display: "Remote Gx Enable"
comment: ""
- name: "remoteAddrs"
type: "string"
value: ""
access: "read-write"
filter: ''
display: "Remote Gx Addresses"
comment: "e.g. ipv4:port;ipv4:port;ipv4:port"
upfConfig:
display: "UPF Config"
sort: 9
array:
- name: "index"
type: "int"
value: ""
access: "read-only"
filter: "0~2047"
display: "Index"
comment: ""
- name: "id"
type: "string"
value: ""
access: "read-write"
filter: "1~64"
display: "UPF ID"
comment: ""
- name: "addr"
type: "string"
value: ""
access: "read-write"
filter: "7~45"
display: "Address"
comment: "e.g. ip:port"
- name: "ipPoolType"
type: "string"
value: "IPv4v6"
access: "read-write"
filter: ""
display: "Ip Pool Type"
comment: "IPv4,IPv6,IPv4v6"
- name: "ipv4Pools"
type: "string"
value: ""
access: "read-write"
filter: "10~256"
display: "IPv4 Pools"
comment: "CIDR format, e.g. 192.168.1.0/24"
- name: "ipv6Pools"
type: "string"
value: ""
access: "read-write"
filter: "5~512"
display: "IPv6 Pools"
comment: "CIDR format, e.g. fe80::20c:29ff:fee4:dab7/50"
- name: "staticIpv4Enable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Static IPv4 Enable"
comment: ""
- name: "staticIpv4Start"
type: "ipv4"
value: ""
access: "read-write"
filter: ""
display: "Static IPv4 Start"
comment: "ipv4 format"
- name: "staticIpv4End"
type: "ipv4"
value: ""
access: "read-write"
filter: ""
display: "Static IPv4 End"
comment: "ipv4 format"
- name: "staticIpv6Enable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Static IPv6 Enable"
comment: ""
- name: "staticIpv6Start"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "Static IPv6 Start"
comment: "ipv6 format"
- name: "staticIpv6End"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "Static IPv6 End"
comment: "ipv6 format"
- name: "ueDnnIpPool"
display: "UE DNN IP Pool"
array:
- name: "index"
type: "int"
value: ""
access: "read-only"
filter: "0~2047"
display: "Index"
comment: ""
- name: "dnn"
type: "string"
value: ""
access: "read-write"
filter: "1~64"
display: "DNN"
comment: ""
- name: "ipPoolType"
type: "string"
value: "IPv4v6"
access: "read-write"
filter: ""
display: "Ip Pool Type"
comment: "IPv4,IPv6,IPv4v6"
- name: "ipv4Pools"
type: "string"
value: ""
access: "read-write"
filter: "10~256"
display: "IPv4 Pools"
comment: "CIDR format, e.g. 192.168.1.0/24"
- name: "ipv6Pools"
type: "string"
value: ""
access: "read-write"
filter: "5~512"
display: "IPv6 Pools"
comment: "CIDR format, e.g. fe80::20c:29ff:fee4:dab7/50"
- name: "staticIpv4Enable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Static IPv4 Enable"
comment: ""
- name: "staticIpv4Start"
type: "ipv4"
value: ""
access: "read-write"
filter: ""
display: "Static IPv4 Start"
comment: "ipv4 format"
- name: "staticIpv4End"
type: "ipv4"
value: ""
access: "read-write"
filter: ""
display: "Static IPv4 End"
comment: "ipv4 format"
- name: "staticIpv6Enable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Static IPv6 Enable"
comment: ""
- name: "staticIpv6Start"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "Static IPv6 Start"
comment: "ipv6 format"
- name: "staticIpv6End"
type: "ipv6"
value: ""
access: "read-write"
filter: ""
display: "Static IPv6 End"
comment: "ipv6 format"
dnnSelectUpf:
display: "DNN Select UPF"
sort: 11
array:
- name: "index"
type: "int"
value: "0"
access: "read-only"
filter: "0~65535"
display: "Index"
comment: ""
- name: "dnn"
type: "string"
value: ""
access: "read-write"
filter: "1~64"
display: "DNN"
comment: ""
- name: "upfId"
type: "string"
value: ""
access: "read-write"
filter: "1~64"
display: "UPF ID"
comment: ""
dnnTaiSelectUpf:
display: "DNN TAI Select UPF"
sort: 13
array:
- name: "index"
type: "int"
value: ""
access: "read-only"
filter: "0~65535"
display: "Index"
comment: ""
- name: "dnn"
type: "string"
value: ""
access: "read-write"
filter: "1~64"
display: "DNN"
comment: ""
- name: "tai"
type: "string"
value: ""
access: "read-write"
filter: "1~64"
display: "TAI"
comment: "MCC+MNC+TAC"
- name: "upfId"
type: "string"
value: "upf2-Id"
access: "read-write"
filter: "1~64"
display: "UPF ID"
comment: ""
localDhcpCfg:
display: "Local DHCP Config"
sort: 15
list:
- name: "enable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Enable"
comment: ""
- name: "localIp"
type: "string"
value: ""
access: "read-write"
filter: ""
display: "Local IP"
comment: ""
dnnselectdhcpserver:
display: "DNN Select DHCP Server"
sort: 17
array:
- name: "index"
type: "int"
value: ""
access: "read-only"
filter: "0~65535"
display: "Index"
comment: ""
- name: "enable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Enable"
comment: ""
- name: "dnn"
type: "string"
value: ""
access: "read-write"
filter: "1~64"
display: "DNN"
comment: ""
- name: "dhcpServerAddr"
type: "string"
value: ""
access: "read-write"
filter: ""
display: "DHCP Server IP"
comment: "e.g. 192.168.1.1"
offlineChargingConfig:
display: "Offline Charging Config"
sort: 19
list:
- name: "cdrFileName"
type: "string"
value: "smf.cdr"
access: "read-write"
filter: "1~64"
display: "CDR File Name"
comment: ""
- name: "cdrFilePath"
type: "string"
value: "/var/log/smfCdr"
access: "read-write"
filter: "1~256"
display: "CDR File Path"
comment: ""
- name: "cdrFileNum"
type: "int"
value: "50"
access: "read-write"
filter: "1~999999999"
display: "CDR File Num"
comment: ""
- name: "cdrFileSize"
type: "int"
value: "300"
access: "read-write"
filter: "1~999999"
display: "CDR File Size"
comment: "Megabytes"
- name: "cdrFileMaxAge"
type: "int"
value: "30"
access: "read-write"
filter: "0~9999"
display: "CDR File Max Age"
comment: "Days"
- name: "freeSubsCdrEnable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Free Subscribers CDR Enable"
comment: ""
- name: "timeThreshold"
type: "int"
value: "600"
access: "read-write"
filter: "0~999999999"
display: "Time Threshold"
comment: "Seconds"
- name: "volumeThreshold"
type: "int"
value: "0"
access: "read-write"
filter: "0~999999999999999"
display: "Volume Threshold"
comment: "Bytes"

View File

@@ -611,6 +611,13 @@ smf:
filter: ""
display: "Local IP"
comment: ""
- name: "ntfyEnable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "DHCP Server Ntfy Enable"
comment: ""
dnnselectdhcpserver:
display: "DNN Select DHCP Server"
sort: 23
@@ -644,7 +651,7 @@ smf:
display: "DHCP Server IP"
comment: "e.g. 192.168.1.1"
offlineChargingConfig:
display: "Offline Charging Config"
display: "Charging Config"
sort: 25
list:
- name: "cdrFileName"
@@ -682,12 +689,19 @@ smf:
filter: "0~9999"
display: "CDR File Max Age"
comment: "Days"
- name: "onlineCdrEnable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Online Charging CDR Enable"
comment: ""
- name: "freeSubsCdrEnable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Free Subscribers CDR Enable"
display: "Offline Charging CDR Enable"
comment: ""
- name: "timeThreshold"
type: "int"

File diff suppressed because one or more lines are too long

View File

@@ -13,6 +13,8 @@ CREATE TABLE `ne_info` (
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
`ne_version` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '2' COMMENT '网元版本',
`schema` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'http' COMMENT '网元模式 http/https',
`ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
`port` int DEFAULT '0' COMMENT '端口',
`pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'PNF' COMMENT '''PNF'',''VNF''',
@@ -32,19 +34,19 @@ CREATE TABLE `ne_info` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元信息表 对应一个网元版本、网元授权、网元主机';
-- 初始网元数据
INSERT INTO `ne_info` VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', '172.16.5.100', 33030, 'PNF', 'AreaNet', '-', '-', '-', '1,2', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (2, 'IMS', '001', '4400HXIMS001', 'IMS_001', '172.16.5.110', 33030, 'PNF', 'AreaNet', '-', '-', '-', '3,4', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (3, 'AMF', '001', '4400HXAMF001', 'AMF_001', '172.16.5.120', 33030, 'PNF', 'AreaNet', '-', '-', '', '5,6', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (4, 'AUSF', '001', '4400HXAUSF001', 'AUSF_001', '172.16.5.130', 33030, 'PNF', 'AreaNet', '-', '-', '', '7,8', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (5, 'UDM', '001', '4400HXUDM001', 'UDM_001', '172.16.5.140', 33030, 'PNF', 'AreaNet', '-', '-', '-', '9,10,11', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (6, 'SMF', '001', '4400HXSMF001', 'SMF_001', '172.16.5.150', 33030, 'PNF', 'AreaNet', '-', '-', '-', '12,13', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (7, 'PCF', '001', '4400HXPCF001', 'PCF_001', '172.16.5.160', 33030, 'PNF', 'AreaNet', '-', '-', '-', '14,15', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (8, 'NSSF', '001', '4400HXNSSF001', 'NSSF_001', '172.16.5.170', 33030, 'PNF', 'AreaNet', '-', '-', '-', '16,17', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (9, 'NRF', '001', '4400HXNRF001', 'NRF_001', '172.16.5.180', 33030, 'PNF', 'AreaNet', '-', '-', '-', '18,19', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (10, 'UPF', '001', '4400HXUPF001', 'UPF_001', '172.16.5.190', 33030, 'PNF', 'AreaNet', '-', '-', '', '20,21,22', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (11, 'LMF', '001', '4400HXLMF001', 'LMF_001', '172.16.5.200', 33030, 'PNF', 'AreaNet', '-', '-', '-', '23,24', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (12, 'NEF', '001', '4400HXNEF001', 'NEF_001', '172.16.5.210', 33030, 'PNF', 'AreaNet', '-', '-', '-', '25,26', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (13, 'MME', '001', '4400HXMME001', 'MME_001', '172.16.5.220', 33030, 'PNF', 'AreaNet', '-', '-', '', '27,28', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (14, 'N3IWF', '001', '4400HXN3IWF001', 'N3IWF_001', '172.16.5.230', 33030, 'PNF', 'AreaNet', '-', '-', '', '29,30', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', "2", 'http', '172.16.5.100', 33030, 'PNF', 'AreaNet', '-', '-', '-', '1,2', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (2, 'IMS', '001', '4400HXIMS001', 'IMS_001', "2", 'http', '172.16.5.110', 33030, 'PNF', 'AreaNet', '-', '-', '-', '3,4', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (3, 'AMF', '001', '4400HXAMF001', 'AMF_001', "2", 'http', '172.16.5.120', 33030, 'PNF', 'AreaNet', '-', '-', '', '5,6', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (4, 'AUSF', '001', '4400HXAUSF001', 'AUSF_001', "2", 'http', '172.16.5.130', 33030, 'PNF', 'AreaNet', '-', '-', '', '7,8', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (5, 'UDM', '001', '4400HXUDM001', 'UDM_001', "2", 'http', '172.16.5.140', 33030, 'PNF', 'AreaNet', '-', '-', '-', '9,10,11', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (6, 'SMF', '001', '4400HXSMF001', 'SMF_001', "2", 'http', '172.16.5.150', 33030, 'PNF', 'AreaNet', '-', '-', '-', '12,13', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (7, 'PCF', '001', '4400HXPCF001', 'PCF_001', "2", 'http', '172.16.5.160', 33030, 'PNF', 'AreaNet', '-', '-', '-', '14,15', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (8, 'NSSF', '001', '4400HXNSSF001', 'NSSF_001', "2", 'http', '172.16.5.170', 33030, 'PNF', 'AreaNet', '-', '-', '-', '16,17', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (9, 'NRF', '001', '4400HXNRF001', 'NRF_001', "2", 'http', '172.16.5.180', 33030, 'PNF', 'AreaNet', '-', '-', '-', '18,19', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (10, 'UPF', '001', '4400HXUPF001', 'UPF_001', "2", 'http', '172.16.5.190', 33030, 'PNF', 'AreaNet', '-', '-', '', '20,21,22', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (11, 'LMF', '001', '4400HXLMF001', 'LMF_001', "2", 'http', '172.16.5.200', 33030, 'PNF', 'AreaNet', '-', '-', '-', '23,24', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (12, 'NEF', '001', '4400HXNEF001', 'NEF_001', "2", 'http', '172.16.5.210', 33030, 'PNF', 'AreaNet', '-', '-', '-', '25,26', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (13, 'MME', '001', '4400HXMME001', 'MME_001', "2", 'http', '172.16.5.220', 33030, 'PNF', 'AreaNet', '-', '-', '', '27,28', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
INSERT INTO `ne_info` VALUES (14, 'N3IWF', '001', '4400HXN3IWF001', 'N3IWF_001', "2", 'http', '172.16.5.230', 33030, 'PNF', 'AreaNet', '-', '-', '', '29,30', 0, '', 'supervisor', 1729063407329, 'supervisor', 1729063818372);
SET FOREIGN_KEY_CHECKS=1;

View File

@@ -9,6 +9,8 @@ CREATE TABLE IF NOT EXISTS `ne_info` (
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
`ne_version` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '2' COMMENT '网元版本',
`schema` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'http' COMMENT '网元模式 http/https',
`ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
`port` int DEFAULT '0' COMMENT '端口',
`pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'PNF' COMMENT '''PNF'',''VNF''',
@@ -33,6 +35,8 @@ ALTER TABLE `ne_info` ADD COLUMN IF NOT EXISTS `remark` varchar(255) CHARACTER S
ALTER TABLE `ne_info` ADD COLUMN IF NOT EXISTS `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者' AFTER `remark`;
ALTER TABLE `ne_info` ADD COLUMN IF NOT EXISTS `create_time` bigint NULL DEFAULT 0 COMMENT '创建时间' AFTER `create_by`;
ALTER TABLE `ne_info` ADD COLUMN IF NOT EXISTS `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者' AFTER `create_time`;
ALTER TABLE `ne_info` ADD COLUMN IF NOT EXISTS `ne_version` varchar(32) NULL DEFAULT '2' COMMENT '网元版本' AFTER `ne_name`;
ALTER TABLE `ne_info` ADD COLUMN IF NOT EXISTS `schema` varchar(12) NULL DEFAULT 'http' COMMENT '网元模式 http/https' AFTER `ne_version`;
ALTER TABLE `ne_info` MODIFY COLUMN `pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'PNF' COMMENT '\'PNF\',\'VNF\'' AFTER `port`;
ALTER TABLE `ne_info` MODIFY COLUMN `province` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '省份地域' AFTER `pv_flag`;
ALTER TABLE `ne_info` MODIFY COLUMN `ne_address` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'MAC地址' AFTER `dn`;
@@ -41,5 +45,6 @@ ALTER TABLE `ne_info` MODIFY COLUMN `status` int NULL DEFAULT 0 COMMENT '0离线
ALTER TABLE `ne_info` MODIFY COLUMN `update_time` bigint NULL DEFAULT 0 COMMENT '更新时间' AFTER `update_by`;
UPDATE `ne_info` SET `create_by` = 'system', `create_time` = UNIX_TIMESTAMP(NOW()) * 1000 WHERE `create_by` = '' OR `create_time` < 1000000000;
UPDATE `ne_info` SET `ne_version` = '2', `schema` = 'http' WHERE `ne_version` IS NULL OR `schema` IS NULL;
SET FOREIGN_KEY_CHECKS=1;

View File

@@ -45,13 +45,13 @@ func (s NeConfigController) List(c *gin.Context) {
// GET /info/:id
func (s NeConfigController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
id := c.Query("id")
if id == "" {
id := parse.Number(c.Query("id"))
if id == 0 {
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: id is empty"))
return
}
data := s.neConfigService.SelectById(id)
data := s.neConfigService.SelectById(fmt.Sprintf("%d", id))
if data.ID != id {
// 没有可访问参数配置数据!
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "neConfig.noData")))
@@ -86,7 +86,7 @@ func (s NeConfigController) Add(c *gin.Context) {
body.ParamJson = string(paramDataByte)
insertId := s.neConfigService.Insert(body)
if insertId != "" {
if insertId != 0 {
c.JSON(200, resp.Ok(nil))
return
}
@@ -106,7 +106,7 @@ func (s NeConfigController) Edit(c *gin.Context) {
}
// 检查是否存在
data := s.neConfigService.SelectById(body.ID)
data := s.neConfigService.SelectById(fmt.Sprintf("%d", body.ID))
if data.ID != body.ID {
// 没有可访问主机命令数据!
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "neConfig.noData")))
@@ -169,12 +169,19 @@ func (s NeConfigController) Remove(c *gin.Context) {
// @Description Network Element Parameter Configuration Available Attribute Values List Specify Network Element Type All Unpaged
// @Router /ne/config/list/{neType} [get]
func (s NeConfigController) ListByNeType(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
neId := c.DefaultQuery("neId", "001")
neType := c.Param("neType")
if neType == "" {
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neType is empty"))
return
}
data := s.neConfigService.SelectNeConfigByNeType(neType)
neInfo := s.neInfoService.FindByNeTypeAndNeID(neType, neId)
if neInfo.NeId != neId || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
data := s.neConfigService.FindByNeType(neInfo.NeType, neInfo.NeVersion)
c.JSON(200, resp.OkData(data))
}
@@ -332,8 +339,14 @@ func (s NeConfigController) DataAdd(c *gin.Context) {
return
}
neInfo := s.neInfoService.FindByNeTypeAndNeID(body.NeType, body.NeId)
if neInfo.NeId != body.NeId || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
// 检查是否array
info := s.neConfigService.SelectNeConfigByNeTypeAndParamName(body.NeType, body.ParamName)
info := s.neConfigService.FindByNeTypeAndParamName(body.NeType, neInfo.NeVersion, body.ParamName)
if info.ParamType != "array" {
c.JSON(200, resp.ErrMsg("this attribute does not support adding"))
return
@@ -345,12 +358,6 @@ func (s NeConfigController) DataAdd(c *gin.Context) {
return
}
neInfo := s.neInfoService.FindByNeTypeAndNeID(body.NeType, body.NeId)
if neInfo.NeId != body.NeId || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
// 网元直连
resData, err := neFetchlink.NeConfigInstall(neInfo, body.ParamName, body.Loc, body.ParamData)
if err != nil {
@@ -390,19 +397,19 @@ func (s NeConfigController) DataRemove(c *gin.Context) {
return
}
// 检查是否array
info := s.neConfigService.SelectNeConfigByNeTypeAndParamName(query.NeType, query.ParamName)
if info.ParamType != "array" {
c.JSON(200, resp.ErrMsg("this attribute does not support adding"))
return
}
neInfo := s.neInfoService.FindByNeTypeAndNeID(query.NeType, query.NeId)
if neInfo.NeId != query.NeId || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
// 检查是否array
info := s.neConfigService.FindByNeTypeAndParamName(query.NeType, neInfo.NeVersion, query.ParamName)
if info.ParamType != "array" {
c.JSON(200, resp.ErrMsg("this attribute does not support adding"))
return
}
// 网元直连
resData, err := neFetchlink.NeConfigDelete(neInfo, query.ParamName, query.Loc)
if err != nil {

View File

@@ -386,6 +386,7 @@ func (s *NeInfoController) Add(c *gin.Context) {
// 已有网元可获取的信息
if body.ServerState != nil {
if v, ok := body.ServerState["version"]; ok && v != nil {
body.NeVersion = fmt.Sprint(v)
neVersion.Version = v.(string)
}
if v, ok := body.ServerState["sn"]; ok && v != nil {
@@ -483,14 +484,15 @@ func (s *NeInfoController) Edit(c *gin.Context) {
// 已有网元可获取的信息
if body.ServerState != nil {
if v, ok := body.ServerState["version"]; ok && v != nil {
neVersion.Version = v.(string)
body.NeVersion = fmt.Sprint(v)
neVersion.Version = fmt.Sprint(v)
neVersion.UpdateBy = loginUserName
}
if v, ok := body.ServerState["sn"]; ok && v != nil {
neLicense.SerialNum = v.(string)
neLicense.SerialNum = fmt.Sprint(v)
}
if v, ok := body.ServerState["expire"]; ok && v != nil {
neLicense.ExpiryDate = v.(string)
neLicense.ExpiryDate = fmt.Sprint(v)
neLicense.Status = "1"
neLicense.UpdateBy = loginUserName
}

View File

@@ -2,8 +2,10 @@ package model
// NeConfig 网元_参数配置可用属性值
type NeConfig struct {
ID string `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
UpdateTime int64 `json:"updateTime" gorm:"column:update_time"` // 更新时间
NeType string `json:"neType" binding:"required" gorm:"column:ne_type"` // 网元类型
NeVersion string `json:"neVersion" gorm:"column:ne_version"` // 网元版本 前缀匹配
ParamName string `json:"paramName" binding:"required" gorm:"column:param_name"` // 参数名
ParamDisplay string `json:"paramDisplay" binding:"required" gorm:"column:param_display"` // 参数显示名
ParamType string `json:"paramType" gorm:"column:param_type"` // 参数类型 list列表单层 array数组多层
@@ -11,7 +13,6 @@ type NeConfig struct {
ParamSort int64 `json:"paramSort" gorm:"column:param_sort"` // 参数排序
ParamPerms string `json:"paramPerms" gorm:"column:param_perms"` // 操作权限 get只读 put可编辑 delete可删除 post可新增
Visible string `json:"visible" gorm:"column:visible"` // 可见性 默认public 单独网元self
UpdateTime int64 `json:"updateTime" gorm:"column:update_time"` // 更新时间
// ====== 非数据库字段属性 ======

View File

@@ -7,6 +7,8 @@ type NeInfo struct {
NeId string `json:"neId" gorm:"column:ne_id" binding:"required"`
RmUID string `json:"rmUid" gorm:"column:rm_uid"`
NeName string `json:"neName" gorm:"column:ne_name"`
NeVersion string `json:"neVersion" gorm:"column:ne_version"` // 网元版本
Schema string `json:"schema" gorm:"column:schema"` // 网元模式 http/https
IP string `json:"ip" gorm:"column:ip" binding:"required"`
Port int64 `json:"port" gorm:"column:port" binding:"required,number,max=65535,min=1"`
PvFlag string `json:"pvFlag" gorm:"column:pv_flag" binding:"oneof=PNF VNF"` // ''PNF'',''VNF''

View File

@@ -41,23 +41,39 @@ func TestConfig(t *testing.T) {
if configParamFile == "*" {
for _, v := range fileNameList {
params := parseData(filepath.Join(configParamDir, v))
filePath := filepath.Join(configParamDir, v)
version := parseVersion(filePath)
params := parseData(filePath)
if params == nil {
return
}
saveData(params)
saveData(version, params)
}
} else {
params := parseData(filepath.Join(configParamDir, configParamFile))
filePath := filepath.Join(configParamDir, configParamFile)
version := parseVersion(filePath)
params := parseData(filePath)
if params == nil {
return
}
saveData(params)
saveData(version, params)
}
}
// ========= Main =============
// 根据文件名获取版本号 mme_2_param_config.yaml -> 2
func parseVersion(filePaht string) string {
version := "2"
splits := strings.Split(filepath.Base(filePaht), "_")
if len(splits) > 0 {
if splits[2] == "param" {
version = splits[1]
}
}
return version
}
// parseData 文件转map数据
func parseData(filePaht string) []map[string]string {
data, err := parseStrToMap(filePaht)
@@ -74,7 +90,7 @@ func parseData(filePaht string) []map[string]string {
}
// saveData 保存数据
func saveData(params []map[string]string) {
func saveData(version string, params []map[string]string) {
// 定义排序函数
sort.Slice(params, func(i, j int) bool {
paramSortI := params[i]["paramSort"]
@@ -109,6 +125,7 @@ func saveData(params []map[string]string) {
}
neConfig := model.NeConfig{
NeVersion: version,
NeType: v["neType"],
ParamName: v["paramName"],
ParamDisplay: v["paramDisplay"],
@@ -153,14 +170,14 @@ func connDB() *gorm.DB {
}
// saveDB 表插入或更新
func saveDB(s model.NeConfig) string {
func saveDB(s model.NeConfig) int64 {
db := connDB()
// 检查是否存在
var id string
db.Raw("SELECT id FROM ne_config WHERE ne_type = ? AND param_name = ?", s.NeType, s.ParamName).Scan(&id)
var id int64
db.Raw("SELECT id FROM ne_config WHERE ne_type = ? AND ne_version = ? AND param_name = ?", s.NeType, s.NeVersion, s.ParamName).Scan(&id)
// 更新时间
s.UpdateTime = time.Now().UnixMilli()
if id != "" {
if id > 0 {
s.ID = id
db.Save(&s)
} else {

View File

@@ -3,6 +3,7 @@ package repository
import (
"time"
"be.ems/src/framework/database/db"
"be.ems/src/framework/datasource"
"be.ems/src/framework/logger"
"be.ems/src/modules/network_element/model"
@@ -45,9 +46,9 @@ func (r NeConfig) SelectByPage(query map[string]string) ([]model.NeConfig, int64
return rows, total
}
// SelectList 根据实体查询
func (r *NeConfig) SelectList(param model.NeConfig) []model.NeConfig {
tx := datasource.DB("").Model(&model.NeConfig{})
// Select 查询集合
func (r NeConfig) Select(param model.NeConfig) []model.NeConfig {
tx := db.DB("").Model(&model.NeConfig{})
// 查询条件拼接
if param.NeType != "" {
tx = tx.Where("ne_type = ?", param.NeType)
@@ -83,19 +84,19 @@ func (r *NeConfig) SelectByIds(ids []string) []model.NeConfig {
}
// Insert 新增信息
func (r *NeConfig) Insert(param model.NeConfig) string {
func (r *NeConfig) Insert(param model.NeConfig) int64 {
param.UpdateTime = time.Now().UnixMilli()
// 执行插入
if err := datasource.DB("").Create(&param).Error; err != nil {
logger.Errorf("insert err => %v", err.Error())
return ""
return 0
}
return param.ID
}
// Update 修改信息
func (r *NeConfig) Update(param model.NeConfig) int64 {
if param.ID == "" {
if param.ID == 0 {
return 0
}
param.UpdateTime = time.Now().UnixMilli()

View File

@@ -3,6 +3,7 @@ package repository
import (
"time"
"be.ems/src/framework/database/db"
"be.ems/src/framework/datasource"
"be.ems/src/framework/logger"
"be.ems/src/modules/network_element/model"
@@ -222,6 +223,26 @@ func (r *NeInfo) UpdateState(id, status string) int64 {
return tx.RowsAffected
}
// UpdateVersion 修改网元版本
func (r NeInfo) UpdateVersion(id string, neVersion string) int64 {
if id == "" {
return 0
}
tx := db.DB("").Model(&model.NeInfo{})
// 构建查询条件
tx = tx.Where("id = ?", id)
tx.Updates(map[string]any{
"ne_version": neVersion,
"update_time": time.Now().UnixMilli(),
})
// 执行更新
if err := tx.Error; err != nil {
logger.Errorf("update err => %v", err.Error())
return 0
}
return tx.RowsAffected
}
// DeleteByIds 批量删除网元信息
func (r NeInfo) DeleteByIds(ids []string) int64 {
if len(ids) <= 0 {

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"strings"
"be.ems/src/framework/constants/cachekey"
"be.ems/src/framework/constants"
"be.ems/src/framework/database/redis"
"be.ems/src/modules/network_element/model"
"be.ems/src/modules/network_element/repository"
@@ -21,92 +21,85 @@ type NeConfig struct {
neConfigRepository *repository.NeConfig // 网元参数配置可用属性值表
}
// RefreshByNeType 通过ne_type刷新redis中的缓存
func (r *NeConfig) RefreshByNeTypeAndNeID(neType string) []model.NeConfig {
// 多个
if neType == "" || neType == "*" {
neConfigList := r.neConfigRepository.SelectList(model.NeConfig{})
if len(neConfigList) > 0 {
neConfigGroup := map[string][]model.NeConfig{}
for _, v := range neConfigList {
if item, ok := neConfigGroup[v.NeType]; ok {
neConfigGroup[v.NeType] = append(item, v)
} else {
neConfigGroup[v.NeType] = []model.NeConfig{v}
}
}
for k, v := range neConfigGroup {
key := fmt.Sprintf("%sNeConfig:%s", cachekey.NE_DATA_KEY, strings.ToUpper(k))
redis.Del("", key)
if len(v) > 0 {
for i, item := range v {
if err := json.Unmarshal([]byte(item.ParamJson), &item.ParamData); err != nil {
continue
}
v[i] = item
}
values, _ := json.Marshal(v)
redis.Set("", key, string(values))
}
}
}
return neConfigList
// RefreshByNeType 通过ne_type刷新redis中的缓存 并返回分组数据
func (r *NeConfig) RefreshByNeTypeAndNeID(neType string) map[string][]model.NeConfig {
neConfig := model.NeConfig{}
if neType != "*" {
neConfig.NeType = neType
}
// 单个
key := fmt.Sprintf("%sNeConfig:%s", cachekey.NE_DATA_KEY, strings.ToUpper(neType))
redis.Del("", key)
neConfigList := r.neConfigRepository.SelectList(model.NeConfig{
NeType: neType,
})
if len(neConfigList) > 0 {
for i, v := range neConfigList {
if err := json.Unmarshal([]byte(v.ParamJson), &v.ParamData); err != nil {
continue
}
neConfigList[i] = v
neConfigList := r.neConfigRepository.Select(neConfig)
neConfigGroup := map[string][]model.NeConfig{}
for _, v := range neConfigList {
if err := json.Unmarshal([]byte(v.ParamJson), &v.ParamData); err != nil {
continue
}
neTypeVerKey := fmt.Sprintf("%s:%s", strings.ToUpper(v.NeType), v.NeVersion)
if item, ok := neConfigGroup[neTypeVerKey]; ok {
neConfigGroup[neTypeVerKey] = append(item, v)
} else {
neConfigGroup[neTypeVerKey] = []model.NeConfig{v}
}
values, _ := json.Marshal(neConfigList)
redis.Set("", key, string(values))
}
return neConfigList
for k, v := range neConfigGroup {
key := fmt.Sprintf("%s:NeConfig:%s", constants.CACHE_NE_DATA, k)
redis.Del("", key)
if len(v) > 0 {
values, _ := json.Marshal(v)
redis.Set("", key, string(values))
}
}
return neConfigGroup
}
// ClearNeCacheByNeType 清除网元类型参数配置缓存
func (r *NeConfig) ClearNeCacheByNeType(neType string) bool {
key := fmt.Sprintf("%sNeConfig:%s", cachekey.NE_DATA_KEY, neType)
key := fmt.Sprintf("%s:NeConfig:%s:*", constants.CACHE_NE_DATA, neType)
if neType == "*" {
key = fmt.Sprintf("%sNeConfig:*", cachekey.NE_DATA_KEY)
key = fmt.Sprintf("%s:NeConfig:*", constants.CACHE_NE_DATA)
}
keys, err := redis.GetKeys("", key)
if err != nil {
return false
}
err = redis.DelKeys("", keys)
return err == nil
return redis.DelKeys("", keys) == nil
}
// SelectNeConfigByNeType 查询网元类型参数配置
func (r *NeConfig) SelectNeConfigByNeType(neType string) []model.NeConfig {
var neConfigList []model.NeConfig
key := fmt.Sprintf("%sNeConfig:%s", cachekey.NE_DATA_KEY, strings.ToUpper(neType))
jsonStr, _ := redis.Get("", key)
if len(jsonStr) > 7 {
err := json.Unmarshal([]byte(jsonStr), &neConfigList)
if err != nil {
neConfigList = []model.NeConfig{}
// FindByNeType 查询网元类型参数配置
func (r *NeConfig) FindByNeType(neType, neVersion string) []model.NeConfig {
data := make([]model.NeConfig, 0)
keys, _ := redis.GetKeys("", fmt.Sprintf("%s:NeConfig:%s:*", constants.CACHE_NE_DATA, strings.ToUpper(neType)))
if len(keys) > 0 {
for _, key := range keys {
neTypeVer := strings.Split(key, ":")
if len(neTypeVer) != 4 {
continue
}
if strings.HasPrefix(neVersion, neTypeVer[3]) {
if jsonStr, _ := redis.Get("", key); len(jsonStr) > 7 {
json.Unmarshal([]byte(jsonStr), &data)
}
return data
}
}
} else {
neConfigList = r.RefreshByNeTypeAndNeID(neType)
}
return neConfigList
// 从数据库刷新缓存
neConfigGroup := r.RefreshByNeTypeAndNeID(neType)
for k, v := range neConfigGroup {
neTypeVer := strings.Split(k, ":")
if len(neTypeVer) == 2 && strings.HasPrefix(neVersion, neTypeVer[1]) {
data = v
break
}
}
return data
}
// SelectNeConfigByNeTypeAndParamName 查询网元类型参数配置By参数名
func (r *NeConfig) SelectNeConfigByNeTypeAndParamName(neType, paramName string) model.NeConfig {
neConfigList := r.SelectNeConfigByNeType(neType)
// FindByNeTypeAndParamName 查询网元类型参数配置By参数名
func (r *NeConfig) FindByNeTypeAndParamName(neType, neVersion, paramName string) model.NeConfig {
neConfigList := r.FindByNeType(neType, neVersion)
var neConfig model.NeConfig
for _, v := range neConfigList {
if v.ParamName == paramName {
if strings.HasPrefix(neVersion, v.NeVersion) && v.ParamName == paramName {
neConfig = v
break
}
@@ -121,7 +114,7 @@ func (r *NeConfig) SelectPage(query map[string]string) ([]model.NeConfig, int64)
// SelectConfigList 查询列表
func (r *NeConfig) SelectList(param model.NeConfig) []model.NeConfig {
return r.neConfigRepository.SelectList(param)
return r.neConfigRepository.Select(param)
}
// SelectByIds 通过ID查询
@@ -137,7 +130,7 @@ func (r *NeConfig) SelectById(id string) model.NeConfig {
}
// Insert 新增信息
func (r *NeConfig) Insert(param model.NeConfig) string {
func (r *NeConfig) Insert(param model.NeConfig) int64 {
return r.neConfigRepository.Insert(param)
}

View File

@@ -20,7 +20,7 @@ func (r NeConfig) GetOMCYaml(paramName string) []map[string]any {
// ModifyOMCYaml 修改OMC网元配置文件 /usr/local/etc/omc/omc.yaml
func (r NeConfig) ModifyOMCYaml(paramName, loc string, paramData any) error {
neConfig := r.SelectNeConfigByNeTypeAndParamName("OMC", paramName)
neConfig := r.FindByNeTypeAndParamName("OMC", "2", paramName)
if neConfig.ParamType == "list" {
if paramName == "trace" {
configPath := fmt.Sprint(config.Get("config")) // 获取配置文件路径

View File

@@ -303,6 +303,13 @@ func (r *NeInfo) bandNeStatus(arr *[]model.NeInfo) {
(*arr)[i].Status = status
if v.Status != status {
r.neInfoRepository.UpdateState(v.ID, status)
r.RefreshByNeTypeAndNeID(v.NeType, v.NeId)
}
// 网元版本设置为当前版本
version, ok := result["version"].(string)
if ok && version != v.NeVersion {
r.neInfoRepository.UpdateVersion(v.ID, version)
r.RefreshByNeTypeAndNeID(v.NeType, v.NeId)
}
}
}