From 763913d2636e3005edb27f32188c12e1757bb7eb Mon Sep 17 00:00:00 2001 From: guzeng Date: Thu, 14 Oct 2021 14:04:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=94=B6=E8=97=8F=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=85=AC=E5=85=B1=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- favorite.go | 43 +++++++++++++++++++++++++++++++++++++++++++ favorite_test.go | 18 ++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 favorite.go create mode 100644 favorite_test.go diff --git a/favorite.go b/favorite.go new file mode 100644 index 0000000..33af033 --- /dev/null +++ b/favorite.go @@ -0,0 +1,43 @@ +package productrpc + +import ( + "strconv" +) + +/** + * 获取商品进行中活动 + * 2021/10/06 + * GZ + */ +func Favorite(site_id, dbname, product_id string, user_id string, url ...string) (int64, error) { + + conn, err := rpc_server_conn(url...) + if err != nil { + return 0, err + } + defer conn.Close() + + arg := FavoriteParam{site_id, dbname, product_id, user_id} + + req, err := SetReqData(arg) + if err != nil { + return 0, err + } + + res := &Response{} + + err = conn.FavoriteProduct(req, res) + + if err != nil { + return 0, err + } + + res_data_de, err := GetResData(res) + if err != nil { + return 0, err + } + if res_data_de == "" { + return 0, nil + } + return strconv.ParseInt(res_data_de, 10, 64) +} diff --git a/favorite_test.go b/favorite_test.go new file mode 100644 index 0000000..656076c --- /dev/null +++ b/favorite_test.go @@ -0,0 +1,18 @@ +package productrpc + +import ( + "testing" +) + +func Test_Favorite(t *testing.T) { + dbname := "shop_v2" + product_id := "1024800" + site_id := "102480" + user_id := "10248" + + ret, err := Favorite(site_id, dbname, product_id, user_id) + + t.Log(ret) + t.Log(err) + +}