liuxiaolong
2021-03-05 11a04ff41abe8e84925249c7118e7b47150fb0ff
dicApi.go
@@ -1,6 +1,7 @@
package dbapi
package bhomedbapi
import (
   "basic.com/pubsub/protomsg.git"
   "encoding/json"
)
@@ -48,4 +49,32 @@
      return false,nil
   }
   return res.Success,res.Data
}
func (api DicApi) ListByType(typ string) (flag bool,list []protomsg.Dic){
   url := DATA_URL_PREFIX + "/dictionary/listByType"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   if netNode == nil {
      return false,nil
   }
   client := NewClient(WithNodes(netNode))
   paramMap := make(map[string]string)
   paramMap["type"] = typ
   respBody, err := client.DoGetRequest(url, paramMap, nil)
   if err !=nil {
      return false,nil
   }
   var res Result
   if err = json.Unmarshal(respBody, &res); err != nil {
      logPrint(err)
      return false,nil
   }
   if res.Success {
      dataBytes, _ := json.Marshal(res.Data)
      if err = json.Unmarshal(dataBytes, &list);err !=nil {
         return false,nil
      }
      return true, list
   }
   return false, nil
}