From 82750124cd1fcf27c6e40ddc8a4c8dc63eda4f55 Mon Sep 17 00:00:00 2001 From: guzeng Date: Tue, 17 Aug 2021 23:13:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0uuid=E5=8F=96=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- getinfo.go | 33 +++++++++++++++++++++++++++++++++ getinfo_test.go | 4 ++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/getinfo.go b/getinfo.go index 300403e..7af3399 100644 --- a/getinfo.go +++ b/getinfo.go @@ -39,3 +39,36 @@ func Get(dbname, id string, url ...string) (map[string]string, error) { return data, err } + +/** + * uuid获取商品sku信息 + * 2021/08/20 + * GZ + */ +func GetByUuid(dbname, uuid string, url ...string) (map[string]string, error) { + + conn, err := rpc_server_conn(url...) + if err != nil { + return nil, err + } + defer conn.Close() + + req := &GetUuidRequest{proto.String(dbname), proto.String(uuid), nil} + + res := &GetResponse{} + + err = conn.GetByUuid(req, res) + + if err != nil { + return nil, err + } + + value := res.GetValue() + + var data map[string]string + + err = json.Unmarshal(value, &data) + + return data, err + +} diff --git a/getinfo_test.go b/getinfo_test.go index d005066..de4ffc5 100644 --- a/getinfo_test.go +++ b/getinfo_test.go @@ -6,9 +6,9 @@ import ( func Test_Get(t *testing.T) { dbname := "shop_v2" - id := "1" + id := "10248" - ret, err := Get(dbname, id) + ret, err := GetByUuid(dbname, id) t.Log(ret) t.Log(err)