zhangmeng
2024-01-19 01dfd9dc8de7b19f9dfa4284722e01bbd5837801
dicApi.go
@@ -2,70 +2,73 @@
import (
   "basic.com/pubsub/protomsg.git"
   json "github.com/json-iterator/go"
   jsoniter "github.com/json-iterator/go"
)
type DicApi struct {
}
func (api DicApi) FindByType(dicType string) (bool,interface{}) {
func (api DicApi) FindByType(dicType string) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/dictionary/findByType"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
   paramMap := make(map[string]string)
   paramMap["type"] = dicType
   respBody, err := client.DoGetRequest(url, paramMap, nil)
   if err !=nil {
      return false,nil
   if err != nil {
      return false, nil
   }
   var res Result
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   if err = json.Unmarshal(respBody, &res); err != nil {
      logPrint(err)
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api DicApi) FindByParentId(parentId string) (bool,interface{}){
func (api DicApi) FindByParentId(parentId string) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/dictionary/findByParentId"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
   paramMap := make(map[string]string)
   paramMap["parentId"] = parentId
   respBody, err := client.DoGetRequest(url, paramMap, nil)
   if err !=nil {
      return false,nil
   if err != nil {
      return false, nil
   }
   var res Result
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   if err = json.Unmarshal(respBody, &res); err != nil {
      logPrint(err)
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api DicApi) ListByType(typ string) (flag bool,list []protomsg.Dic){
func (api DicApi) ListByType(typ string) (flag bool, list []protomsg.Dic) {
   url := DATA_URL_PREFIX + "/dictionary/listByType"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   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
   if err != nil {
      return false, nil
   }
   var res Result
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   if err = json.Unmarshal(respBody, &res); err != nil {
      logPrint(err)
      return false,nil
      return false, nil
   }
   if res.Success {
      dataBytes, _ := json.Marshal(res.Data)
      if err = json.Unmarshal(dataBytes, &list);err !=nil {
         return false,nil
      var json = jsoniter.ConfigCompatibleWithStandardLibrary
      if err = json.Unmarshal(dataBytes, &list); err != nil {
         return false, nil
      }
      return true, list
   }
   return false, nil
}
}