package bhomedbapi
|
|
import (
|
"encoding/json"
|
)
|
|
type DicApi struct {
|
|
}
|
|
func (api DicApi) FindByType(dicType string) (bool,interface{}) {
|
url := DATA_URL_PREFIX + "/dictionary/findByType"
|
netNode := getNetNode(url2Topic(Topic_System_Service, url))
|
if netNode == nil {
|
return false,nil
|
}
|
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
|
}
|
var res Result
|
if err = json.Unmarshal(respBody, &res); err != nil {
|
logPrint(err)
|
return false,nil
|
}
|
return res.Success,res.Data
|
}
|
|
func (api DicApi) FindByParentId(parentId string) (bool,interface{}){
|
url := DATA_URL_PREFIX + "/dictionary/findByParentId"
|
netNode := getNetNode(url2Topic(Topic_System_Service, url))
|
if netNode == nil {
|
return false,nil
|
}
|
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
|
}
|
var res Result
|
if err = json.Unmarshal(respBody, &res); err != nil {
|
logPrint(err)
|
return false,nil
|
}
|
return res.Success,res.Data
|
}
|