Browse Source

修改数据类型

master v0.1.7
guzeng 3 years ago
parent
commit
70e5cc16c8
7 changed files with 77 additions and 3 deletions
  1. +4
    -0
      access_token.client.go
  2. +11
    -0
      access_token.client_test.go
  3. +1
    -2
      common.go
  4. +10
    -0
      go.mod
  5. +17
    -0
      go.sum
  6. +1
    -1
      send_uniform_message.client.go
  7. +33
    -0
      send_uniform_message.client_test.go

+ 4
- 0
access_token.client.go View File

@ -13,6 +13,10 @@ import (
func GetAccessToken(dbname, site_id string, appid, secret string, url ...string) (*AccessTokenRes, error) { func GetAccessToken(dbname, site_id string, appid, secret string, url ...string) (*AccessTokenRes, error) {
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)
if err != nil {
return nil, err
}
defer conn.Close()
data := AccessTokenReq{} data := AccessTokenReq{}
data.SiteId = site_id data.SiteId = site_id


+ 11
- 0
access_token.client_test.go View File

@ -0,0 +1,11 @@
package weixinrpc
import (
"testing"
)
func Test_GetAccessToken(t *testing.T) {
ret, err := GetAccessToken("test", "100005", "wx303b0cec4a8d1bc1", "90ddb8da4bc4e96e600532dd24be8c7b")
t.Log(ret, err)
}

+ 1
- 2
common.go View File

@ -31,7 +31,7 @@ type UniformMessageReq struct {
TemplateId string TemplateId string
Url string Url string
MiniProgram string MiniProgram string
Data string
Data interface{}
} }
func rpc_server_conn(url ...string) (*WeixinRpcServiceClient, error) { func rpc_server_conn(url ...string) (*WeixinRpcServiceClient, error) {
@ -44,7 +44,6 @@ func rpc_server_conn(url ...string) (*WeixinRpcServiceClient, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer conn.Close()
return conn, nil return conn, nil
} }

+ 10
- 0
go.mod View File

@ -0,0 +1,10 @@
module git.tetele.net/tgo/weixinrpc
go 1.14
require (
git.tetele.net/tgo/crypter v0.2.2 // indirect
github.com/chai2010/protorpc v1.0.0 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
)

+ 17
- 0
go.sum View File

@ -0,0 +1,17 @@
git.tetele.net/tgo/crypter v0.2.2 h1:YMQJh2Gj5Po4ZfelJUmXBKi01UbmtiSy3bmqRfnYQMo=
git.tetele.net/tgo/crypter v0.2.2/go.mod h1:vfvRLZA8+lHNgNXneOcgvVhDyuv25ZRb+C6xHOmXNx0=
github.com/chai2010/protorpc v1.0.0 h1:aJ45G9sl1utSKo35EqnBSTs5jqTpdJDJAuZMMYPAtFo=
github.com/chai2010/protorpc v1.0.0/go.mod h1:woR3WwjaQDqFjlzdVsFEKiK5Ur12QL8mYxVPjfr5z54=
github.com/golang/protobuf v1.0.0 h1:lsek0oXi8iFE9L+EXARyHIjU5rlWIhhTkjDz3vHhWWQ=
github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/snappy v0.0.0-20170215233205-553a64147049 h1:K9KHZbXKpGydfDN0aZrsoHpLJlZsBrGMFWbgLDGnPZk=
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

+ 1
- 1
send_uniform_message.client.go View File

@ -21,7 +21,7 @@ import (
* data 公众号模板消息的数据 * data 公众号模板消息的数据
*/ */
func SendUniformMessage(dbname, site_id string, appid, secret, touser, mp_appid, temp_id, redirect_url, mini_program, data string, url ...string) (*WxApiRes, error) {
func SendUniformMessage(dbname, site_id string, appid, secret, touser, mp_appid, temp_id, redirect_url, mini_program string, data interface{}, url ...string) (*WxApiRes, error) {
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)


+ 33
- 0
send_uniform_message.client_test.go View File

@ -0,0 +1,33 @@
package weixinrpc
import (
"encoding/json"
"testing"
)
func Test_SendUniformMessage(t *testing.T) {
db := "gkxy_tetele_net"
site_id := "1101832"
appid := "wx7be627d0325135f4"
secret := "984c6d213c60419c4f30c159fbbe1ce9"
touser := "osxVD5S0PAh82gyIXSiXCJzM_k6s"
mp_appid := "wx056995d61ca222f5"
temp_id := "6xgj_65KivigMvwdJgiveR4wLXJLDpzsT2-hShczLmU"
url := ""
mini_program := "wx7be627d0325135f4"
data := map[string]map[string]string{
"first": map[string]string{"value": "来新订单了"},
"keyword1": map[string]string{"value": "订单号是。。。"},
"keyword2": map[string]string{"value": "取货位置"},
"keyword3": map[string]string{"value": "收货人"},
"keyword4": map[string]string{"value": "联系电话"},
"keyword5": map[string]string{"value": "收货地址"},
"remark": map[string]string{"value": "这是备注"},
}
data_json, _ := json.Marshal(data)
ret, err := SendUniformMessage(db, site_id, appid, secret, touser, mp_appid, temp_id, url, mini_program, data)
t.Log(ret, err)
}

Loading…
Cancel
Save