mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[FIX] fix can't unmarshal of response with list
This commit is contained in:
parent
3a46b8868f
commit
fc0dd4e97d
@ -134,9 +134,11 @@ func (n *node) Get(node string) (*model.HostNode,*util.APIHandleError) {
|
||||
var res utilhttp.ResponseBody
|
||||
var gc model.HostNode
|
||||
res.Bean = &gc
|
||||
logrus.Infof("res is %v",res)
|
||||
if err := ffjson.Unmarshal(body, &res); err != nil {
|
||||
return nil, util.CreateAPIHandleError(code,err)
|
||||
}
|
||||
logrus.Infof("res is %v",res)
|
||||
if gc, ok := res.Bean.(*model.HostNode); ok {
|
||||
return gc, nil
|
||||
}
|
||||
@ -152,12 +154,12 @@ func (n *node) Rule(rule string) ([]*model.HostNode,*util.APIHandleError) {
|
||||
}
|
||||
var res utilhttp.ResponseBody
|
||||
var gc []*model.HostNode
|
||||
res.List = gc
|
||||
res.List = &gc
|
||||
if err := ffjson.Unmarshal(body, &res); err != nil {
|
||||
return nil, util.CreateAPIHandleError(code,err)
|
||||
}
|
||||
if gc, ok := res.List.([]*model.HostNode); ok {
|
||||
return gc, nil
|
||||
if gc, ok := res.List.(*[]*model.HostNode); ok {
|
||||
return *gc, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@ -171,12 +173,12 @@ func (n *node) List() ([]*model.HostNode,*util.APIHandleError) {
|
||||
}
|
||||
var res utilhttp.ResponseBody
|
||||
var gc []*model.HostNode
|
||||
res.List = gc
|
||||
res.List = &gc
|
||||
if err := ffjson.Unmarshal(body, &res); err != nil {
|
||||
return nil, util.CreateAPIHandleError(code,err)
|
||||
}
|
||||
if gc, ok := res.List.([]*model.HostNode); ok {
|
||||
return gc, nil
|
||||
if gc, ok := res.List.(*[]*model.HostNode); ok {
|
||||
return *gc, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@ -258,12 +260,12 @@ func (t *task) List() ([]*model.Task, *util.APIHandleError) {
|
||||
}
|
||||
var res utilhttp.ResponseBody
|
||||
var gc []*model.Task
|
||||
res.List = gc
|
||||
res.List = &gc
|
||||
if err := ffjson.Unmarshal(body, &res); err != nil {
|
||||
return nil, util.CreateAPIHandleError(code,err)
|
||||
}
|
||||
if gc, ok := res.List.([]*model.Task); ok {
|
||||
return gc, nil
|
||||
if gc, ok := res.List.(*[]*model.Task); ok {
|
||||
return *gc, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -99,12 +99,12 @@ func (s *services) Pods(serviceAlisa string) ([]*dbmodel.K8sPod, *util.APIHandle
|
||||
}
|
||||
var res utilhttp.ResponseBody
|
||||
var gc []*dbmodel.K8sPod
|
||||
res.List = gc
|
||||
res.List = &gc
|
||||
if err := ffjson.Unmarshal(body, &res); err != nil {
|
||||
return nil, util.CreateAPIHandleError(code,err)
|
||||
}
|
||||
if gc, ok := res.List.([]*dbmodel.K8sPod); ok {
|
||||
return gc, nil
|
||||
if gc, ok := res.List.(*[]*dbmodel.K8sPod); ok {
|
||||
return *gc, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@ -143,12 +143,12 @@ func (s *services) EventLog(serviceAlisa, eventID, level string) ([]*model.Messa
|
||||
}
|
||||
var res utilhttp.ResponseBody
|
||||
var gc []*model.MessageData
|
||||
res.List = gc
|
||||
res.List = &gc
|
||||
if err := ffjson.Unmarshal(body, &res); err != nil {
|
||||
return nil, util.CreateAPIHandleError(code,err)
|
||||
}
|
||||
if gc, ok := res.List.([]*model.MessageData); ok {
|
||||
return gc, nil
|
||||
if gc, ok := res.List.(*[]*model.MessageData); ok {
|
||||
return *gc, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@ -164,17 +164,13 @@ func (s *services) List() ([]*model.ServiceStruct,*util.APIHandleError) {
|
||||
}
|
||||
var res utilhttp.ResponseBody
|
||||
var gc []*model.ServiceStruct
|
||||
res.List = gc
|
||||
logrus.Infof("res is %v",res)
|
||||
res.List = &gc
|
||||
|
||||
if err := ffjson.Unmarshal(body, &res); err != nil {
|
||||
return nil, util.CreateAPIHandleError(code,err)
|
||||
}
|
||||
logrus.Infof("after unmarshal res is %v",res)
|
||||
if gc, ok := res.List.([]*model.ServiceStruct); ok {
|
||||
return gc, nil
|
||||
}else{
|
||||
c:=res.List.([]*model.ServiceStruct)
|
||||
logrus.Infof("response is %v",c)
|
||||
if gc, ok := res.List.(*[]*model.ServiceStruct); ok {
|
||||
return *gc, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user