Browse Source

加入获取code_bank一条可用记录的方法

master v0.7.4
listen 3 years ago
parent
commit
31ade9a301
2 changed files with 58 additions and 1 deletions
  1. +49
    -1
      code_bank.go
  2. +9
    -0
      code_bank_test.go

+ 49
- 1
code_bank.go View File

@ -1 +1,49 @@
package siterpc
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
}

+ 9
- 0
code_bank_test.go View File

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

Loading…
Cancel
Save