Browse Source

增加查询方法

master v0.3.5
guzeng 3 years ago
parent
commit
9d598a9833
2 changed files with 54 additions and 1 deletions
  1. +53
    -0
      client.getinfo.go
  2. +1
    -1
      client.getinfo_test.go

+ 53
- 0
client.getinfo.go View File

@ -23,6 +23,59 @@ func GetInfo(site_id, dbname string, order_id string, field string, url ...strin
data["site_id"] = site_id
data["order_id"] = order_id
data["field"] = field
data["condition"] = "order_id"
req, err := SetReqData(data)
if err != nil {
return nil, err
}
res := &Response{}
err = conn.Get(req, res)
if err != nil {
return nil, err
}
res_data_de, err := GetResData(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
}
func GetInfoByOrderSn(site_id, dbname string, order_sn string, field string, url ...string) (map[string]string, error) {
if dbname == "" || order_sn == "" {
return nil, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return nil, err
}
defer conn.Close()
var data map[string]string = make(map[string]string)
data["dbname"] = dbname
data["site_id"] = site_id
data["order_sn"] = order_sn
data["field"] = field
data["condition"] = "order_sn"
req, err := SetReqData(data)
if err != nil {


+ 1
- 1
client.getinfo_test.go View File

@ -6,7 +6,7 @@ import (
func Test_GetInfo(t *testing.T) {
ret, err := GetInfo("100064", "shop_v2", "1", "id,order_sn")
ret, err := GetInfoByOrderSn("100064", "shop_v2", "2021000121222", "id,order_sn")
t.Log(ret)
t.Log(err)


Loading…
Cancel
Save