sqlite的api,便于内部使用
liuxiaolong
2019-08-01 cb1b69b2d943111f9ef37cd99cfb48d824820395
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
package dbapi
 
import (
    "encoding/json"
    "fmt"
)
 
type DicApi struct {
 
}
 
func (api DicApi) FindByType(dicType string) (bool,interface{}) {
    url := BASIC_URL + DATA_URL_PREFIX + "/dictionary/findByType"
    client := NewClient()
    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 {
        fmt.Println(err)
        return false,nil
    }
    return res.Success,res.Data
}
 
func (api DicApi) FindByParentId(parentId string) (bool,interface{}){
    url := BASIC_URL + DATA_URL_PREFIX + "/dictionary/findByParentId"
    client := NewClient()
    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 {
        fmt.Println(err)
        return false,nil
    }
    return res.Success,res.Data
}