Browse Source

增加uuid取信息方法

master v0.2.2
guzeng 3 years ago
parent
commit
82750124cd
2 changed files with 35 additions and 2 deletions
  1. +33
    -0
      getinfo.go
  2. +2
    -2
      getinfo_test.go

+ 33
- 0
getinfo.go View File

@ -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
}

+ 2
- 2
getinfo_test.go View File

@ -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)


Loading…
Cancel
Save