From 31ade9a30177b64f6dda6002ad857767b69e6854 Mon Sep 17 00:00:00 2001 From: listen <494177603@qq.com> Date: Thu, 9 Sep 2021 17:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=8E=B7=E5=8F=96code=5Fbank?= =?UTF-8?q?=E4=B8=80=E6=9D=A1=E5=8F=AF=E7=94=A8=E8=AE=B0=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code_bank.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++- code_bank_test.go | 9 +++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 code_bank_test.go diff --git a/code_bank.go b/code_bank.go index 6f2c9a3..f10cf0d 100644 --- a/code_bank.go +++ b/code_bank.go @@ -1 +1,49 @@ -package siterpc \ No newline at end of file +package siterpc + +import ( + "errors" +) + +/** + * 获取code_bank一条可用记录 + * 2021/09/09 + * linsen + */ +func GetOneCode(site_id, dbname string, url ...string) (string, error) { + + if dbname == "" { + return "", errors.New("参数错误") + } + + conn, err := rpc_server_conn(url...) + + if err != nil { + return "", err + } + defer conn.Close() + + arg := SiteConfigItemReqArg{site_id, dbname, ""} + + req, err := SetReqData(arg) + if err != nil { + return "", err + } + res := &Response{} + + err = conn.GetOneCode(req, res) + + if err != nil { + return "", err + } + + res_data_de, err := GetResData(res) + if err != nil { + return "", err + } + + if res_data_de == "" { + return "", nil + } + + return res_data_de, nil +} \ No newline at end of file diff --git a/code_bank_test.go b/code_bank_test.go new file mode 100644 index 0000000..70c85cd --- /dev/null +++ b/code_bank_test.go @@ -0,0 +1,9 @@ +package siterpc + +import "testing" + +func Test_getcode(t *testing.T){ + res,err := GetOneCode("1058278","shop_v2") + t.Log(res) + t.Log(err) +} \ No newline at end of file