liuxiaolong
2021-01-07 f6f3c4df0fbf70bed9a94aaeb6b7f246766a6196
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
}