fix: 实训参数配置修改功能接口支持array层级
This commit is contained in:
@@ -93,10 +93,11 @@ func (r *PtNeConfigDataService) SaveAsDefaultByType(neInfo neModel.NeInfo, stubT
|
||||
continue
|
||||
}
|
||||
// 将json数据转字符串存储 data:[{},{}]
|
||||
if _, ok := resData["data"]; !ok {
|
||||
data, ok := resData["data"]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
paramDataByte, err := json.Marshal(resData)
|
||||
paramDataByte, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -129,6 +130,7 @@ func (r *PtNeConfigDataService) ResetAsDefaultByType(neType, stubType, operaUser
|
||||
for _, v := range ptConfs {
|
||||
// 查询是否存在记录
|
||||
hasItems := r.SelectList(model.PtNeConfigData{
|
||||
CreateBy: operaUserName,
|
||||
NeType: v.NeType,
|
||||
StubType: stubType,
|
||||
ParamName: v.ParamName,
|
||||
@@ -175,8 +177,42 @@ func (r *PtNeConfigDataService) SelectByStubType(param model.PtNeConfigData) mod
|
||||
if len(list) > 0 {
|
||||
paraData = list[0]
|
||||
if err := json.Unmarshal([]byte(paraData.ParamJson), ¶Data.ParamData); err != nil {
|
||||
paraData.ParamData = map[string]any{}
|
||||
paraData.ParamData = []map[string]any{}
|
||||
}
|
||||
}
|
||||
return paraData
|
||||
}
|
||||
|
||||
// ApplyToNe 参数应用到网元
|
||||
func (r *PtNeConfigDataService) ApplyToNe(paramUser, neType string) error {
|
||||
ptConfs := r.SelectList(model.PtNeConfigData{CreateBy: paramUser, StubType: "2", NeType: neType})
|
||||
if len(ptConfs) == 0 {
|
||||
return fmt.Errorf("NeConfigData Not Found")
|
||||
}
|
||||
|
||||
// 找网元,只有一套就固定001
|
||||
neInfo := r.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, "001")
|
||||
if neInfo.NeType != neType || neInfo.ID == "" {
|
||||
return fmt.Errorf("NeInfo Not Found")
|
||||
}
|
||||
|
||||
// 遍历去设置参数
|
||||
for _, ptConf := range ptConfs {
|
||||
if err := json.Unmarshal([]byte(ptConf.ParamJson), &ptConf.ParamData); err != nil {
|
||||
ptConf.ParamData = []map[string]any{}
|
||||
}
|
||||
// 将json数据转字符串存储 [{},{}]
|
||||
if len(ptConf.ParamData) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if ptConf.ParamType == "list" {
|
||||
dataMap := ptConf.ParamData[0]
|
||||
for k, v := range dataMap {
|
||||
fmt.Println(k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user