package supplierrpc
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
)
|
|
|
|
type GetParam struct {
|
|
SiteId string `json:"site_id"`
|
|
Dbname string `json:"database"`
|
|
Id string `json:"id"`
|
|
}
|
|
|
|
type GetUuidParam struct {
|
|
SiteId string `json:"site_id"`
|
|
Dbname string `json:"database"`
|
|
Uuid string `json:"uuid"`
|
|
}
|
|
|
|
func Get(site_id, dbname, id string, url ...string) (map[string]string, error) {
|
|
|
|
if dbname == "" || id == "" {
|
|
return nil, errors.New("参数错误")
|
|
}
|
|
|
|
conn, err := rpc_server_conn(url...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer conn.Close()
|
|
|
|
arg := GetParam{site_id, dbname, id}
|
|
|
|
req, err := SetReqData(arg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res := &Params{}
|
|
|
|
err = conn.Get(req, res)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
res_data_de, err := GetData(res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if res_data_de == "" {
|
|
return nil, nil
|
|
}
|
|
var res_arr map[string]string
|
|
|
|
err = json.Unmarshal([]byte(res_data_de), &res_arr)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return res_arr, nil
|
|
|
|
}
|