del: 移除param_config表相关引用
This commit is contained in:
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
@@ -29,15 +29,6 @@
|
||||
"program": "d:/local.git/be.ems/sshsvc/sshsvc.go",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "debug loadpconf",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "d:/local.git/be.ems/tools/loadpconf",
|
||||
"args": ["-p","../../config/param/smf_param_config.yaml"],
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "debug crontask",
|
||||
"type": "go",
|
||||
@@ -52,7 +43,6 @@
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "d:/local.git/be.ems/tools/encode",
|
||||
//"args": ["-p","../../config/param/smf_param_config.yaml"],
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -890,7 +890,7 @@
|
||||
}
|
||||
|
||||
|
||||
"param_config": {
|
||||
"ne_config": {
|
||||
"retFmt": "GetDB",
|
||||
"retMsg": "RetCode = %d operation succeeded\n\n",
|
||||
"errMsg": "ErrorCode = %d operation failed: %s\n\n",
|
||||
@@ -903,27 +903,22 @@
|
||||
"cols": [
|
||||
{
|
||||
"name": "ne_type",
|
||||
"display": "NE type",
|
||||
"display": "NE Type",
|
||||
"length": 10
|
||||
},
|
||||
{
|
||||
"name": "ne_id",
|
||||
"display": "NE ID",
|
||||
"length": 28
|
||||
},
|
||||
{
|
||||
"name": "top_tag",
|
||||
"display": "Parameters tag",
|
||||
"name": "param_display",
|
||||
"display": "Parameter Display",
|
||||
"length": 128
|
||||
},
|
||||
{
|
||||
"name": "param_name",
|
||||
"display": "Parameter name list",
|
||||
"display": "Parameter Name",
|
||||
"length": 256
|
||||
},
|
||||
{
|
||||
"name": "param_value",
|
||||
"display": "Parameter value list",
|
||||
"display": "Parameter Value",
|
||||
"length": 256
|
||||
}
|
||||
],
|
||||
|
||||
@@ -43,7 +43,7 @@ INSERT INTO `mml_command` VALUES (1594, 'OMC', 'neManagement', 'Network Element
|
||||
INSERT INTO `mml_command` VALUES (1595, 'OMC', 'neManagement', 'Network Element Management', 'add', 'neinfo', 'Add Network Element', '[{\"alias\":\"ne_type\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"netype\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"neid\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"rm_uid\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"Resource management UID\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"rmuid\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ip\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"IP address\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"ip\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"port\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"Port\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"port\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ne_name\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE name\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"nename\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"pv_flag\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"PV flag\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"pvflag\",\"optional\":\"false\",\"type\":\"string\"}]', 'Active');
|
||||
INSERT INTO `mml_command` VALUES (1596, 'OMC', 'neManagement', 'Network Element Management', 'mod', 'neinfo', 'Modify Network Element', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"netype\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"neid\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"rm_uid\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"Resource management UID\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"rmuid\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ip\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"IP address\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"ip\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"port\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"Port\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"port\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_name\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE name\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"nename\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"pv_flag\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"PV flag\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"pvflag\",\"optional\":\"true\",\"type\":\"string\"}]', 'Active');
|
||||
INSERT INTO `mml_command` VALUES (1597, 'OMC', 'neManagement', 'Network Element Management', 'del', 'neinfo', 'Delete Network Element', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"name\":\"netype\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"name\":\"neid\",\"optional\":\"false\",\"type\":\"string\"}]', 'Active');
|
||||
INSERT INTO `mml_command` VALUES (1598, 'OMC', 'neConfigManagement', 'NE Config Parameter Management', 'dsp', 'neconfig', 'Display NE Config Parameter', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"netype\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"neid\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"top_tag\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Parameter tag\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"tag\",\"optional\":\"true\",\"type\":\"string\"}]', 'Inactive');
|
||||
INSERT INTO `mml_command` VALUES (1598, 'OMC', 'neConfigManagement', 'NE Config Parameter Management', 'dsp', 'neconfig', 'Display NE Config Parameter', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE Type\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"netype\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"param_display\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Parameters Display\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"paramDisplay\",\"optional\":\"true\",\"type\":\"string\"}]', 'Active');
|
||||
INSERT INTO `mml_command` VALUES (1599, 'OMC', 'faultManagement', 'Fault Management', 'dsp', 'alarm', 'Display Alarm Information', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"netype\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE UID\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"neid\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_name\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE name\",\"filter\":\"\",\"name\":\"nename\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"alarm_code\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm code\",\"filter\":\"\",\"name\":\"alarmcode\",\"optional\":\"true\",\"type\":\"int\"},{\"alias\":\"orig_severity\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Original severity\",\"filter\":\"{\\\"Critical\\\":\\\"Critical\\\",\\\"Major\\\":\\\"Major\\\",\\\"Minor\\\":\\\"Minor\\\",\\\"Warning\\\":\\\"Warning\\\",\\\"Event\\\":\\\"Event\\\"}\",\"name\":\"origseverity\",\"optional\":\"true\",\"type\":\"enum\"},{\"alias\":\"pv_flag\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"PV flag\",\"filter\":\"\",\"name\":\"pvflag\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"event_time\\u003e\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm event start time\",\"filter\":\"\",\"name\":\"starttime\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"event_time\\u003c\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm event end time\",\"filter\":\"\",\"name\":\"endtime\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"alarm_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm type\",\"filter\":\"{\\\"CommunicationAlarm\\\":\\\"CommunicationAlarm\\\",\\\"EquipmentAlarm\\\":\\\"EquipmentAlarm\\\",\\\"ProcessingFailure\\\":\\\"ProcessingFailure\\\",\\\"EnvironmentalAlarm\\\":\\\"EnvironmentalAlarm\\\",\\\"QualityOfServiceAlarm\\\":\\\"QualityOfServiceAlarm\\\"}\",\"name\":\"alarmtype\",\"optional\":\"true\",\"type\":\"enum\"},{\"alias\":\"alarm_status\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm status\",\"filter\":\"\",\"name\":\"alarmstatus\",\"optional\":\"true\",\"type\":\"int\"}]', 'Active');
|
||||
INSERT INTO `mml_command` VALUES (1600, 'OMC', 'systemCommand', 'Linux System Command', 'run', 'shell', 'Run Shell Command', '[{\"alias\":\"cmd\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Shell command\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"cmd\",\"optional\":\"false\",\"type\":\"string\"}]', 'Inactive');
|
||||
INSERT INTO `mml_command` VALUES (1601, 'OMC', 'licenseManagement', 'License Management', 'dsp', 'licenseinfo', 'Display NE License Information', '[{\"alias\":\"neType\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"name\":\"netype\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"neId\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"name\":\"neid\",\"optional\":\"true\",\"type\":\"string\"}]', 'Inactive');
|
||||
|
||||
@@ -65,7 +65,7 @@ INSERT INTO `mml_http_map` VALUES (22, 'OMC', 'act', 'measuretask', 'Put', '/api
|
||||
INSERT INTO `mml_http_map` VALUES (23, 'OMC', 'dea', 'measuretask', 'Put', '/api/rest/dataManagement/v1/omc_db/measure_task', NULL, NULL, '?loc=', '{\r\n \"bodyFmt\": \"PutDB\",\r\n \"bodyKey\": \"measure_task\",\r\n \"cols\": [\r\n {\r\n \"name\": \"status\",\r\n \"alias\": \"status\",\r\n \"type\": \"int\",\r\n \"length\": 11,\r\n \"value\": \"Inactive\"\r\n }\r\n ]\r\n}\r\n', '{\r\n \"retFmt\": \"PutDB\",\r\n \"retMsg\": \"RetCode = %d operation succeeded\\n\\n\",\r\n \"errMsg\": \"ErrorCode = %d operation failed: %s\\n\\n\",\r\n \"cols\": [\r\n {\r\n \"name\": \"affectedRows\",\r\n \"display\": \"Affected rows\",\r\n \"length\": 11\r\n }\r\n ]\r\n}');
|
||||
INSERT INTO `mml_http_map` VALUES (24, 'OMC', 'dsp', 'nbicm', 'Get', '/api/rest/dataManagement/v1/omc_db/nbi_cm', NULL, NULL, '?loc=', '{}', '{\r\n \"retFmt\": \"GetDB\",\r\n \"retMsg\": \"RetCode = %d operation succeeded\\n\\n\",\r\n \"errMsg\": \"ErrorCode = %d operation failed: %s\\n\\n\",\r\n \"title\": \"NBI Resources Management\",\r\n \"singleList\": true,\r\n \"sepSpaceNum\": 2,\r\n \"alignmentM\": \"Left\",\r\n \"alignmentSN\": \"Right\",\r\n \"alignmentSV\": \"Left\",\r\n \"cols\": [\r\n {\r\n \"name\": \"ne_type\",\r\n \"display\": \"NE type\",\r\n \"length\": 10\r\n },\r\n {\r\n \"name\": \"ne_id\",\r\n \"display\": \"NE ID\",\r\n \"length\": 20\r\n },\r\n {\r\n \"name\": \"rm_uid\",\r\n \"display\": \"RM UID\",\r\n \"length\": 20\r\n },\r\n {\r\n \"name\": \"user_label\",\r\n \"display\": \"User label\",\r\n \"length\": 20\r\n },\r\n {\r\n \"name\": \"object_type\",\r\n \"display\": \"Object type\",\r\n \"length\": 20\r\n },\r\n {\r\n \"name\": \"pv_flag\",\r\n \"display\": \"PV flag\",\r\n \"length\": 8\r\n },\r\n {\r\n \"name\": \"value_json\",\r\n \"display\": \"NBI resource management\",\r\n \"length\": 200\r\n } \r\n ],\r\n \"end\": \"(Number of results = %d)\\n\\n\"\r\n}\r\n');
|
||||
INSERT INTO `mml_http_map` VALUES (25, 'OMC', 'upg', 'neversion', 'Put', '/api/rest/dataManagement/v1/omc_db/ne_version', NULL, NULL, '?loc=', '{\r\n \"bodyFmt\": \"PutDB\",\r\n \"bodyKey\": \"ne_version\",\r\n \"cols\": [\r\n {\r\n \"name\": \"status\",\r\n \"alias\": \"status\",\r\n \"type\": \"string\",\r\n \"length\": 8,\r\n \"value\": \"Active\"\r\n }\r\n ]\r\n}', '{\r\n \"retFmt\": \"PutDB\",\r\n \"retMsg\": \"RetCode = %d operation succeeded\\n\\n\",\r\n \"errMsg\": \"ErrorCode = %d operation failed: %s\\n\\n\",\r\n \"cols\": [\r\n {\r\n \"name\": \"affectedRows\",\r\n \"display\": \"Affected rows\",\r\n \"length\": 11\r\n }\r\n ]\r\n}');
|
||||
INSERT INTO `mml_http_map` VALUES (26, 'OMC', 'dsp', 'neconfig', 'Get', '/api/rest/dataManagement/v1/omc_db/param_config', NULL, 'SQL', '?SQL=select+ne_type,ne_id,top_tag,json_extract(param_json,\'$.*[*].name\')+AS+param_name,JSON_EXTRACT(param_json,\'$.*[*].value\')+as+param_value+from+param_config', '{}', '{\r\n \"retFmt\": \"GetDB\",\r\n \"retMsg\": \"RetCode = %d operation succeeded\\n\\n\",\r\n \"errMsg\": \"ErrorCode = %d operation failed: %s\\n\\n\",\r\n \"title\": \"NE Config Parameters\",\r\n \"singleList\": true,\r\n \"sepSpaceNum\": 2,\r\n \"alignmentM\": \"Left\",\r\n \"alignmentSN\": \"Right\",\r\n \"alignmentSV\": \"Left\",\r\n \"cols\": [\r\n {\r\n \"name\": \"ne_type\",\r\n \"display\": \"NE type\",\r\n \"length\": 10\r\n },\r\n {\r\n \"name\": \"ne_id\",\r\n \"display\": \"NE ID\",\r\n \"length\": 28\r\n },\r\n {\r\n \"name\": \"top_tag\",\r\n \"display\": \"Parameters tag\",\r\n \"length\": 128\r\n },\r\n {\r\n \"name\": \"param_name\",\r\n \"display\": \"Parameter name list\",\r\n \"length\": 256\r\n },\r\n {\r\n \"name\": \"param_value\",\r\n \"display\": \"Parameter value list\",\r\n \"length\": 256\r\n }\r\n ],\r\n \"end\": \"(Number of results = %d)\\n\\n\"\r\n}');
|
||||
INSERT INTO `mml_http_map` VALUES (26, 'OMC', 'dsp', 'neconfig', 'Get', '/api/rest/dataManagement/v1/omc_db/ne_config', NULL, 'SQL', '?SQL=select+ne_type,param_display,JSON_UNQUOTE(json_extract(param_json,\'$[0].name\'))+as+param_name,JSON_UNQUOTE(json_extract(param_json,\'$[0].value\'))+as+param_value+from+ne_config', '{}', '{\r\n \"retFmt\": \"GetDB\",\r\n \"retMsg\": \"RetCode = %d operation succeeded\\n\\n\",\r\n \"errMsg\": \"ErrorCode = %d operation failed: %s\\n\\n\",\r\n \"title\": \"NE Config Parameters\",\r\n \"singleList\": true,\r\n \"sepSpaceNum\": 2,\r\n \"alignmentM\": \"Left\",\r\n \"alignmentSN\": \"Right\",\r\n \"alignmentSV\": \"Left\",\r\n \"cols\": [\r\n {\r\n \"name\": \"ne_type\",\r\n \"display\": \"NE Type\",\r\n \"length\": 10\r\n },\r\n {\r\n \"name\": \"param_display\",\r\n \"display\": \"Parameter Display\",\r\n \"length\": 128\r\n },\r\n {\r\n \"name\": \"param_name\",\r\n \"display\": \"Parameter Name\",\r\n \"length\": 256\r\n },\r\n {\r\n \"name\": \"param_value\",\r\n \"display\": \"Parameter Value\",\r\n \"length\": 256\r\n }\r\n ],\r\n \"end\": \"(Number of results = %d)\\n\\n\"\r\n}');
|
||||
INSERT INTO `mml_http_map` VALUES (27, 'OMC', 'lst', 'license', 'Get', '/api/rest/dataManagement/v1/omc_db/ne_license', NULL, 'loc', '?loc=', '{}', '{\r\n \"retFmt\": \"GetDB\",\r\n \"retMsg\": \"RetCode = %d operation succeeded\\n\\n\",\r\n \"errMsg\": \"ErrorCode = %d operation failed: %s\\n\\n\",\r\n \"title\": \"NE License Information\",\r\n \"singleList\": true,\r\n \"sepSpaceNum\": 2,\r\n \"alignmentM\": \"Left\",\r\n \"alignmentSN\": \"Right\",\r\n \"alignmentSV\": \"Left\",\r\n \"cols\": [\r\n {\r\n \"name\": \"ne_type\",\r\n \"display\": \"NE type\",\r\n \"length\": 10\r\n },\r\n {\r\n \"name\": \"ne_id\",\r\n \"display\": \"NE ID\",\r\n \"length\": 20\r\n },\r\n {\r\n \"name\": \"serial_no\",\r\n \"display\": \"Serial no\",\r\n \"length\": 12\r\n },\r\n {\r\n \"name\": \"capcity\",\r\n \"display\": \"License capcity\",\r\n \"length\": 11\r\n },\r\n {\r\n \"name\": \"used\",\r\n \"display\": \"License used\",\r\n \"length\": 11\r\n },\r\n {\r\n \"name\": \"feature_enabled\",\r\n \"display\": \"Feature enabled\",\r\n \"length\": 30\r\n },\r\n {\r\n \"name\": \"expiration_date\",\r\n \"display\": \"License expiration date\",\r\n \"length\": 20\r\n }\r\n ],\r\n \"end\": \"(Number of results = %d)\\n\\n\"\r\n}');
|
||||
INSERT INTO `mml_http_map` VALUES (28, 'OMC', 'dep', 'license', 'Put', '/api/rest/dataManagement/v1/omc_db/ne_license', NULL, 'loc', '?loc=', '{\r\n \"bodyFmt\": \"PutDB\",\r\n \"bodyKey\": \"ne_license\",\r\n \"callFunc\": \"DeploymentLicense\"\r\n}', '{\r\n \"retFmt\": \"DeleteDB\",\r\n \"retMsg\": \"RetCode = %d operation succeeded\\n\\n\",\r\n \"errMsg\": \"ErrorCode = %d operation failed: %s\\n\\n\",\r\n \"cols\": [\r\n {\r\n \"name\": \"affectedRows\",\r\n \"display\": \"Affected rows\",\r\n \"length\": 11\r\n }\r\n ]\r\n}');
|
||||
INSERT INTO `mml_http_map` VALUES (29, 'OMC', 'rel', 'license', 'Put', '/api/rest/dataManagement/v1/omc_db/ne_license', NULL, 'loc', '?loc=', '{\r\n \"bodyFmt\": \"PutDB\",\r\n \"bodyKey\": \"ne_license\",\r\n \"callFunc\": \"InstallLicense\"\r\n}', '{\r\n \"retFmt\": \"DeleteDB\",\r\n \"retMsg\": \"RetCode = %d operation succeeded\\n\\n\",\r\n \"errMsg\": \"ErrorCode = %d operation failed: %s\\n\\n\",\r\n \"cols\": [\r\n {\r\n \"name\": \"affectedRows\",\r\n \"display\": \"Affected rows\",\r\n \"length\": 11\r\n }\r\n ]\r\n}');
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -428,68 +428,6 @@ func XormParseResult(body []byte) ([]NeInfo, error) {
|
||||
return neInfo, nil
|
||||
}
|
||||
|
||||
type ParamConfig struct {
|
||||
// Id int `json:"id" xorm:"pk 'id' autoincr"`
|
||||
NeType string `json:"neType"`
|
||||
NeId string `json:"neId"`
|
||||
TopTag string `json:"topTag"`
|
||||
TopDisplay string `json:"topDisplay"`
|
||||
ParamJson string `json:"paramJson"`
|
||||
}
|
||||
|
||||
func XormInsertParamConfig(mapJson *map[string]interface{}) (int64, error) {
|
||||
var affected, a int64
|
||||
var err error
|
||||
paramConfig := new(ParamConfig)
|
||||
for n, d := range *mapJson {
|
||||
if d == nil {
|
||||
break
|
||||
}
|
||||
log.Debugf("n: %s", n)
|
||||
|
||||
for t, p := range d.(map[string]interface{}) {
|
||||
if p == nil {
|
||||
break
|
||||
}
|
||||
log.Debug("t:", t)
|
||||
log.Debug("p:", p)
|
||||
for k, v := range p.(map[string]interface{}) {
|
||||
log.Debug("k, v: ", k, v)
|
||||
if k == "display" {
|
||||
paramConfig.TopDisplay = fmt.Sprintf("%v", v)
|
||||
|
||||
} else {
|
||||
pc, _ := json.Marshal(v)
|
||||
paramConfig.ParamJson = fmt.Sprintf("{\"%v\":%v}", k, string(pc))
|
||||
}
|
||||
}
|
||||
|
||||
paramConfig.NeType = strings.ToUpper(n)
|
||||
paramConfig.NeId = ""
|
||||
paramConfig.TopTag = t
|
||||
// paramConfig.TopDisplay = p["display"]
|
||||
// paramConfig.ParamJson = p.(string)
|
||||
|
||||
log.Debug("paramConfig:", paramConfig)
|
||||
|
||||
xSession := xEngine.NewSession()
|
||||
defer xSession.Close()
|
||||
_, err = xSession.Table("param_config").Where("ne_type = ? and top_tag = ?", paramConfig.NeType, paramConfig.TopTag).Delete()
|
||||
if err != nil {
|
||||
log.Error("Failed to insert param_config:", err)
|
||||
}
|
||||
a, err = xSession.Insert(paramConfig)
|
||||
if err != nil {
|
||||
log.Error("Failed to insert param_config:", err)
|
||||
}
|
||||
affected += a
|
||||
xSession.Commit()
|
||||
}
|
||||
}
|
||||
|
||||
return affected, err
|
||||
}
|
||||
|
||||
func ConstructUpdateSQLArray(tableName string, updateData interface{}, whereCondition string) (string, []string) {
|
||||
log.Debug("ConstructUpdateSQL processing... ")
|
||||
log.Debug("Request updateData:", updateData)
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"strings"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
var xEngine *xorm.Engine
|
||||
|
||||
func XormConnectDatabaseWithUri(sql string) (*xorm.Engine, error) {
|
||||
// sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local", db.User, db.Password, db.Host, db.Port, db.Name)
|
||||
sqlStr := fmt.Sprintf("%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local", sql)
|
||||
// fmt.Printf("sqlStr:%s:******@tcp(%s:%s)/%s?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=true&loc=Local", db.User, db.Host, db.Port, db.Name)
|
||||
var err error
|
||||
xEngine, err = xorm.NewEngine("mysql", sqlStr) //1、Create xorm engine
|
||||
if err != nil {
|
||||
fmt.Println("Failed to connect database:", err)
|
||||
return nil, err
|
||||
}
|
||||
xEngine.ShowSQL(true)
|
||||
return xEngine, nil
|
||||
}
|
||||
|
||||
type ParamConfig struct {
|
||||
// Id int `json:"id" xorm:"pk 'id' autoincr"`
|
||||
NeType string `json:"neType"`
|
||||
NeId string `json:"neId"`
|
||||
TopTag string `json:"topTag"`
|
||||
TopDisplay string `json:"topDisplay"`
|
||||
Method string `json:"method"`
|
||||
ParamJson string `json:"paramJson"`
|
||||
}
|
||||
|
||||
func XormInsertParamConfig(mapJson *map[string]interface{}) (int64, error) {
|
||||
var affected, a int64
|
||||
var err error
|
||||
paramConfig := new(ParamConfig)
|
||||
for n, d := range *mapJson {
|
||||
if d == nil {
|
||||
break
|
||||
}
|
||||
fmt.Printf("n: %s", n)
|
||||
|
||||
session := xEngine.NewSession()
|
||||
defer session.Close()
|
||||
_, err = session.Table("param_config").Where("ne_type = ?", strings.ToUpper(n)).Delete()
|
||||
if err != nil {
|
||||
fmt.Println("Failed to delete param_config:", err)
|
||||
}
|
||||
session.Commit()
|
||||
|
||||
for t, p := range d.(map[string]interface{}) {
|
||||
if p == nil {
|
||||
break
|
||||
}
|
||||
fmt.Println("t:", t)
|
||||
fmt.Println("p:", p)
|
||||
for k, v := range p.(map[string]interface{}) {
|
||||
fmt.Println("k, v: ", k, v)
|
||||
if k == "display" {
|
||||
paramConfig.TopDisplay = fmt.Sprintf("%v", v)
|
||||
|
||||
} else if k == "method" {
|
||||
if v != "" {
|
||||
paramConfig.Method = fmt.Sprintf("%v", v)
|
||||
}
|
||||
} else {
|
||||
pc, _ := json.Marshal(v)
|
||||
paramConfig.ParamJson = fmt.Sprintf("{\"%v\":%v}", k, string(pc))
|
||||
}
|
||||
}
|
||||
|
||||
paramConfig.NeType = strings.ToUpper(n)
|
||||
paramConfig.NeId = ""
|
||||
paramConfig.TopTag = t
|
||||
// paramConfig.TopDisplay = p["display"]
|
||||
// paramConfig.ParamJson = p.(string)
|
||||
|
||||
fmt.Println("paramConfig:", paramConfig)
|
||||
|
||||
session := xEngine.NewSession()
|
||||
defer session.Close()
|
||||
// _, err = session.Table("param_config").Where("ne_type = ? and top_tag = ?", paramConfig.NeType, paramConfig.TopTag).Delete()
|
||||
// if err != nil {
|
||||
// fmt.Println("Failed to delete param_config:", err)
|
||||
// }
|
||||
a, err = session.Insert(paramConfig)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to insert param_config:", err)
|
||||
}
|
||||
session.Commit()
|
||||
affected += a
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
@@ -1,375 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Yaml struct of config
|
||||
type YamlConfig struct {
|
||||
Logger struct {
|
||||
File string `yaml:"file"`
|
||||
Level string `yaml:"level"`
|
||||
}
|
||||
|
||||
Rest struct {
|
||||
Addr string `yaml:"addr"`
|
||||
Port uint16 `yaml:"port"`
|
||||
}
|
||||
|
||||
Database struct {
|
||||
Type string `yaml:"type"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Name string `yaml:"name"`
|
||||
}
|
||||
ParamFileDir string `yaml:"paramfiledir"`
|
||||
}
|
||||
|
||||
var yamlConfig YamlConfig
|
||||
|
||||
func ReadConfig(configFile string) {
|
||||
yamlFile, err := os.ReadFile(configFile)
|
||||
if err != nil {
|
||||
fmt.Printf("ioutil.ReadFile %s err %v", configFile, err)
|
||||
}
|
||||
// fmt.Println("yamlfile:", string(yamlFile))
|
||||
|
||||
err = yaml.Unmarshal(yamlFile, &yamlConfig)
|
||||
if err != nil {
|
||||
fmt.Printf("Unmarshal: %v when to struct", err)
|
||||
}
|
||||
}
|
||||
|
||||
func GetYamlConfig() *YamlConfig {
|
||||
return &yamlConfig
|
||||
}
|
||||
|
||||
//var mapYaml map[string]interface{}
|
||||
|
||||
func ReadParamConfig(fileName string) *map[string]interface{} {
|
||||
file, err := os.ReadFile(fileName)
|
||||
if err != nil {
|
||||
fmt.Println("yamlFile.Get err", err)
|
||||
}
|
||||
|
||||
mapYaml := make(map[string]interface{})
|
||||
|
||||
var node yaml.Node
|
||||
err = yaml.Unmarshal(file, &node)
|
||||
if err != nil {
|
||||
fmt.Printf("yaml.Unmarshal: %v when to struct", err)
|
||||
}
|
||||
err = unmarshalNode(&node, &mapYaml)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to unmarshalNode:", err)
|
||||
}
|
||||
|
||||
// var node yaml.Node
|
||||
// err = yaml.Unmarshal(file, &node)
|
||||
// if err != nil {
|
||||
// fmt.Printf("yaml.Unmarshal: %v when to struct", err)
|
||||
// }
|
||||
|
||||
// err = unmarshalNode(&node, reflect.ValueOf(&mapYaml))
|
||||
// if err != nil {
|
||||
// fmt.Println("Failed to unmarshalNode:", err)
|
||||
// }
|
||||
|
||||
err = yaml.Unmarshal(file, &mapYaml)
|
||||
if err != nil {
|
||||
fmt.Printf("yaml.Unmarshal: %v when to struct", err)
|
||||
}
|
||||
// fmt.Println("mapYaml:", mapYaml)
|
||||
|
||||
return &mapYaml
|
||||
}
|
||||
|
||||
func GetAllFile(dir string, s []string) ([]string, error) {
|
||||
rd, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
fmt.Println("read dir fail:", err)
|
||||
return s, err
|
||||
}
|
||||
|
||||
for _, fi := range rd {
|
||||
if !fi.IsDir() {
|
||||
fullName := dir + "/" + fi.Name()
|
||||
s = append(s, fullName)
|
||||
}
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
const defaultConfigFile = "./loadpconf.yaml"
|
||||
|
||||
var (
|
||||
version string
|
||||
buildTime string
|
||||
goVer string
|
||||
)
|
||||
|
||||
var pfiles []string
|
||||
|
||||
func init() {
|
||||
cfile := flag.String("c", defaultConfigFile, "config file")
|
||||
pfile := flag.String("p", "", "param file")
|
||||
pv := flag.Bool("v", false, "print version")
|
||||
ph := flag.Bool("h", false, "print help")
|
||||
|
||||
flag.Parse()
|
||||
if *pv {
|
||||
fmt.Printf("OMC initems version: %s\n%s\n%s\n\n", version, buildTime, goVer)
|
||||
os.Exit(0)
|
||||
}
|
||||
if *ph {
|
||||
flag.Usage()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
ReadConfig(*cfile)
|
||||
|
||||
fmt.Println("pfile:", *pfile)
|
||||
if *pfile != "" {
|
||||
pfiles = append(pfiles, *pfile)
|
||||
} else {
|
||||
pfiles, _ = GetAllFile(yamlConfig.ParamFileDir, pfiles)
|
||||
}
|
||||
fmt.Println("pfiles:", pfiles)
|
||||
}
|
||||
|
||||
func unmarshalNode(node *yaml.Node, out interface{}) error {
|
||||
switch node.Kind {
|
||||
case yaml.DocumentNode:
|
||||
return unmarshalNode(node.Content[0], out)
|
||||
case yaml.MappingNode:
|
||||
m := nodeToMap(node)
|
||||
return unmarshalMap(m, out)
|
||||
case yaml.SequenceNode:
|
||||
s := nodeToSlice(node)
|
||||
return unmarshalSlice(s, out)
|
||||
case yaml.ScalarNode:
|
||||
return unmarshalScalar(node, out)
|
||||
default:
|
||||
return fmt.Errorf("unknown node kind: %v", node.Kind)
|
||||
}
|
||||
}
|
||||
|
||||
func nodeToMap(node *yaml.Node) map[string]*yaml.Node {
|
||||
m := make(map[string]*yaml.Node)
|
||||
for i := 0; i < len(node.Content); i += 2 {
|
||||
key := node.Content[i].Value
|
||||
value := node.Content[i+1]
|
||||
m[key] = value
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func unmarshalMap(m map[string]*yaml.Node, out interface{}) error {
|
||||
data, ok := out.(*map[string]interface{})
|
||||
if !ok {
|
||||
return fmt.Errorf("out must be a map[string]interface{}")
|
||||
}
|
||||
|
||||
*data = make(map[string]interface{})
|
||||
for key, value := range m {
|
||||
var v interface{}
|
||||
err := unmarshalNode(value, &v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
(*data)[key] = v
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func nodeToSlice(node *yaml.Node) []*yaml.Node {
|
||||
return node.Content
|
||||
}
|
||||
|
||||
func unmarshalSlice(s []*yaml.Node, out interface{}) error {
|
||||
data, ok := out.(*[]interface{})
|
||||
if !ok {
|
||||
return fmt.Errorf("out must be a []interface{}")
|
||||
}
|
||||
|
||||
*data = make([]interface{}, len(s))
|
||||
for i, value := range s {
|
||||
var v interface{}
|
||||
err := unmarshalNode(value, &v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
(*data)[i] = v
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmarshalScalar(node *yaml.Node, out interface{}) error {
|
||||
switch node.Tag {
|
||||
case "!!str":
|
||||
val := reflect.ValueOf(node.Value)
|
||||
val.Elem().Set(reflect.ValueOf(out))
|
||||
//*out = node.Value
|
||||
case "!!int":
|
||||
val := reflect.ValueOf(node.Value)
|
||||
val.Elem().Set(reflect.ValueOf(out))
|
||||
//*out = node.Value
|
||||
case "!!float":
|
||||
val := reflect.ValueOf(node.Value)
|
||||
val.Elem().Set(reflect.ValueOf(out))
|
||||
//*out = node.Value
|
||||
case "!!bool":
|
||||
val := reflect.ValueOf(node.Value == "true")
|
||||
val.Elem().Set(reflect.ValueOf(out))
|
||||
//*out = node.Value == "true"
|
||||
case "!!null":
|
||||
val := reflect.ValueOf(node.Value)
|
||||
val.Elem().Set(reflect.ValueOf(out))
|
||||
//*out = nil
|
||||
default:
|
||||
return fmt.Errorf("unknown scalar tag: %v", node.Tag)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
func unmarshalNode(node *yaml.Node, out reflect.Value) error {
|
||||
switch node.Kind {
|
||||
case yaml.DocumentNode:
|
||||
return unmarshalNode(node.Content[0], out)
|
||||
case yaml.MappingNode:
|
||||
m := nodeToMap(node)
|
||||
return unmarshalMap(m, out)
|
||||
case yaml.SequenceNode:
|
||||
s := nodeToSlice(node)
|
||||
return unmarshalSlice(s, out)
|
||||
case yaml.ScalarNode:
|
||||
return unmarshalScalar(node, out)
|
||||
default:
|
||||
return fmt.Errorf("unknown node kind: %v", node.Kind)
|
||||
}
|
||||
}
|
||||
|
||||
func nodeToMap(node *yaml.Node) map[string]*yaml.Node {
|
||||
m := make(map[string]*yaml.Node)
|
||||
for i := 0; i < len(node.Content); i += 2 {
|
||||
key := node.Content[i].Value
|
||||
value := node.Content[i+1]
|
||||
m[key] = value
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func unmarshalMap(m map[string]*yaml.Node, out reflect.Value) error {
|
||||
if out.Kind() != reflect.Ptr || out.IsNil() {
|
||||
return fmt.Errorf("out must be a non-nil pointer")
|
||||
}
|
||||
|
||||
outType := out.Type().Elem()
|
||||
if outType.Kind() != reflect.Map {
|
||||
return fmt.Errorf("out must be a pointer to a map")
|
||||
}
|
||||
|
||||
mapType := outType.Elem()
|
||||
if mapType.Kind() != reflect.Interface && mapType.Kind() != reflect.Map {
|
||||
return fmt.Errorf("out must be a pointer to a map of interface{}")
|
||||
}
|
||||
|
||||
out.Set(reflect.MakeMap(outType))
|
||||
|
||||
for key, value := range m {
|
||||
var v reflect.Value
|
||||
if mapType.Kind() == reflect.Interface {
|
||||
v = reflect.New(reflect.TypeOf((*interface{})(nil)).Elem())
|
||||
} else {
|
||||
v = reflect.New(mapType)
|
||||
}
|
||||
|
||||
err := unmarshalNode(value, v.Elem())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Elem().SetMapIndex(reflect.ValueOf(key), v.Elem())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func nodeToSlice(node *yaml.Node) []*yaml.Node {
|
||||
return node.Content
|
||||
}
|
||||
|
||||
func unmarshalSlice(s []*yaml.Node, out reflect.Value) error {
|
||||
if out.Kind() != reflect.Ptr || out.IsNil() {
|
||||
return fmt.Errorf("out must be a non-nil pointer")
|
||||
}
|
||||
|
||||
outType := out.Type().Elem()
|
||||
if outType.Kind() != reflect.Slice {
|
||||
return fmt.Errorf("out must be a pointer to a slice")
|
||||
}
|
||||
|
||||
sliceType := outType.Elem()
|
||||
if sliceType.Kind() != reflect.Interface && sliceType.Kind() != reflect.Slice {
|
||||
return fmt.Errorf("out must be a pointer to a slice of interface{}")
|
||||
}
|
||||
|
||||
out.Set(reflect.MakeSlice(outType, len(s), len(s)))
|
||||
|
||||
for i, value := range s {
|
||||
var v reflect.Value
|
||||
if sliceType.Kind() == reflect.Interface {
|
||||
v = reflect.New(reflect.TypeOf((*interface{})(nil)).Elem())
|
||||
} else {
|
||||
v = reflect.New(sliceType)
|
||||
}
|
||||
|
||||
err := unmarshalNode(value, v.Elem())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.Elem().Index(i).Set(v.Elem())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmarshalScalar(node *yaml.Node, out reflect.Value) error {
|
||||
switch node.Tag {
|
||||
case "!!str":
|
||||
out.SetString(node.Value)
|
||||
case "!!int":
|
||||
i, err := strconv.ParseInt(node.Value, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.SetInt(i)
|
||||
case "!!float":
|
||||
f, err := strconv.ParseFloat(node.Value, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.SetFloat(f)
|
||||
case "!!bool":
|
||||
b, err := strconv.ParseBool(node.Value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.SetBool(b)
|
||||
case "!!null":
|
||||
out.Set(reflect.Zero(out.Type()))
|
||||
default:
|
||||
return fmt.Errorf("unknown scalar tag: %v", node.Tag)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
@@ -1,21 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("========================= OMC loadpconf startup =========================")
|
||||
fmt.Printf("OMC loadpconf version: %s %s %s", version, buildTime, goVer)
|
||||
|
||||
for _, f := range pfiles {
|
||||
fmt.Println("f:", f)
|
||||
paramMap := ReadParamConfig(f)
|
||||
fmt.Println("paramMap:", paramMap)
|
||||
db := yamlConfig.Database
|
||||
sqlStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", db.User, db.Password, db.Host, db.Port, db.Name)
|
||||
XormConnectDatabaseWithUri(sqlStr)
|
||||
XormInsertParamConfig(paramMap)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
logger:
|
||||
file: ./initems.log
|
||||
level: trace
|
||||
|
||||
rest:
|
||||
addr: 0.0.0.0
|
||||
port: 3040
|
||||
|
||||
database:
|
||||
type: mysql
|
||||
user: root
|
||||
password: 1000omc@kp!
|
||||
host: 127.0.0.1
|
||||
port: 33066
|
||||
name: omc_db
|
||||
|
||||
paramfiledir: ../../config/param
|
||||
@@ -1,22 +0,0 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 5GC16.1.1
|
||||
PLATFORM = amd64
|
||||
DEBDIR = ../../../deb
|
||||
ETCDIR = ../../../etc
|
||||
RELEASEDIR = ../../../release
|
||||
LIBDIR = ../lib
|
||||
BINNAME = loadpconf
|
||||
|
||||
.PHONY: build $(BINNAME)
|
||||
build $(BINNAME):
|
||||
go build -o $(BINNAME) -v -ldflags "-X 'main.version=$(VERSION)' \
|
||||
-X 'main.buildTime=`date`' \
|
||||
-X 'main.goVer=`go version`'"
|
||||
|
||||
run: $(BINNAME)
|
||||
./$(BINNAME)
|
||||
|
||||
clean:
|
||||
rm ./$(BINNAME)
|
||||
@@ -9,7 +9,7 @@ mml_command
|
||||
mml_http_map
|
||||
mml_subscriber
|
||||
mml_system
|
||||
param_config
|
||||
ne_config
|
||||
pm_custom_title
|
||||
title_info
|
||||
trace_info
|
||||
|
||||
Reference in New Issue
Block a user