Browse Source

debug

master v0.2.4
guzeng 3 years ago
parent
commit
bf3dace594
4 changed files with 0 additions and 111 deletions
  1. +0
    -62
      client.info.go
  2. +0
    -16
      client.info_test.go
  3. +0
    -6
      client.is_open.go
  4. +0
    -27
      conn.go

+ 0
- 62
client.info.go View File

@ -1,62 +0,0 @@
package supplierrpc
import (
"encoding/json"
"errors"
)
type GetParam struct {
SiteId string `json:"site_id"`
Dbname string `json:"database"`
Id string `json:"id"`
}
type GetUuidParam struct {
SiteId string `json:"site_id"`
Dbname string `json:"database"`
Uuid string `json:"uuid"`
}
func Get(site_id, dbname, id string, url ...string) (map[string]string, error) {
if dbname == "" || id == "" {
return nil, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return nil, err
}
defer conn.Close()
arg := GetParam{site_id, dbname, id}
req, err := SetReqData(arg)
if err != nil {
return nil, err
}
res := &Params{}
err = conn.Get(req, res)
if err != nil {
return nil, err
}
res_data_de, err := GetData(res)
if err != nil {
return nil, err
}
if res_data_de == "" {
return nil, nil
}
var res_arr map[string]string
err = json.Unmarshal([]byte(res_data_de), &res_arr)
if err != nil {
return nil, err
}
return res_arr, nil
}

+ 0
- 16
client.info_test.go View File

@ -1,16 +0,0 @@
package supplierrpc
import (
"testing"
)
func Test_Get(t *testing.T) {
siteid := "1056475"
dbname := "shop_v2"
key := "1"
res, err := Get(siteid, dbname, key)
t.Log(res)
t.Log(err)
}

+ 0
- 6
client.is_open.go View File

@ -1,6 +0,0 @@
package supplierrpc
type BoolRet struct {
Value bool `json:"value"`
Msg string `json:"msg"`
}

+ 0
- 27
conn.go View File

@ -1,27 +0,0 @@
package supplierrpc
import (
"git.tetele.net/tgo/conf"
)
var DES_KEY = "suppli22"
func rpc_server_conn(url ...string) (*SupplierServiceClient, error) {
var rpc_url string
if len(url) > 0 && url[0] != "" {
rpc_url = url[0]
} else if conf.SUPPLIER_RPC_URL != "" {
rpc_url = conf.SUPPLIER_RPC_URL
} else {
rpc_url = "127.0.0.1:" + conf.SUPPLIER_RPC_PORT
}
conn, _, err := DialSupplierService("tcp", rpc_url)
if err != nil {
return nil, err
}
return conn, nil
}

Loading…
Cancel
Save