mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-23 13:42:25 +08:00
Compare commits
2 Commits
c1f622453d
...
feature/au
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1cee8868e | ||
|
|
aa1afc5a35 |
9
.github/workflows/go.yml
vendored
9
.github/workflows/go.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
golangci:
|
golangci:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
|
go-version: [ '1.16','1.17','1.18','1.19','1.20' ]
|
||||||
name: golangci-lint
|
name: golangci-lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -29,6 +29,11 @@ jobs:
|
|||||||
name: Test
|
name: Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
|
options: --entrypoint redis-server
|
||||||
memcached:
|
memcached:
|
||||||
image: memcached
|
image: memcached
|
||||||
ports:
|
ports:
|
||||||
@@ -37,7 +42,7 @@ jobs:
|
|||||||
# strategy set
|
# strategy set
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
|
go: [ '1.16','1.17','1.18','1.19','1.20' ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|||||||
29
.github/workflows/release.yml
vendored
Normal file
29
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: goreleaser
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
goreleaser:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
-
|
||||||
|
name: Set up Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: 1.16
|
||||||
|
-
|
||||||
|
name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v4
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
args: release --rm-dist
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
29
.goreleaser.yml
Normal file
29
.goreleaser.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# This is an example goreleaser.yaml file with some sane defaults.
|
||||||
|
# Make sure to check the documentation at http://goreleaser.com
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
# You may remove this if you don't use go modules.
|
||||||
|
- go mod download
|
||||||
|
# you may remove this if you don't need go generate
|
||||||
|
- go generate ./...
|
||||||
|
builds:
|
||||||
|
- skip: true
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- replacements:
|
||||||
|
darwin: Darwin
|
||||||
|
linux: Linux
|
||||||
|
windows: Windows
|
||||||
|
386: i386
|
||||||
|
amd64: x86_64
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
name_template: 'checksums.txt'
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{ .Tag }}-next"
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^docs:'
|
||||||
|
- '^test:'
|
||||||
92
cache/redis.go
vendored
Normal file
92
cache/redis.go
vendored
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Redis .redis cache
|
||||||
|
type Redis struct {
|
||||||
|
ctx context.Context
|
||||||
|
conn redis.UniversalClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// RedisOpts redis 连接属性
|
||||||
|
type RedisOpts struct {
|
||||||
|
Host string `yml:"host" json:"host"`
|
||||||
|
Password string `yml:"password" json:"password"`
|
||||||
|
Database int `yml:"database" json:"database"`
|
||||||
|
MaxIdle int `yml:"max_idle" json:"max_idle"`
|
||||||
|
MaxActive int `yml:"max_active" json:"max_active"`
|
||||||
|
IdleTimeout int `yml:"idle_timeout" json:"idle_timeout"` // second
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRedis 实例化
|
||||||
|
func NewRedis(ctx context.Context, opts *RedisOpts) *Redis {
|
||||||
|
conn := redis.NewUniversalClient(&redis.UniversalOptions{
|
||||||
|
Addrs: []string{opts.Host},
|
||||||
|
DB: opts.Database,
|
||||||
|
Password: opts.Password,
|
||||||
|
IdleTimeout: time.Second * time.Duration(opts.IdleTimeout),
|
||||||
|
MinIdleConns: opts.MaxIdle,
|
||||||
|
})
|
||||||
|
return &Redis{ctx: ctx, conn: conn}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConn 设置conn
|
||||||
|
func (r *Redis) SetConn(conn redis.UniversalClient) {
|
||||||
|
r.conn = conn
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRedisCtx 设置redis ctx 参数
|
||||||
|
func (r *Redis) SetRedisCtx(ctx context.Context) {
|
||||||
|
r.ctx = ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get 获取一个值
|
||||||
|
func (r *Redis) Get(key string) interface{} {
|
||||||
|
return r.GetContext(r.ctx, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetContext 获取一个值
|
||||||
|
func (r *Redis) GetContext(ctx context.Context, key string) interface{} {
|
||||||
|
result, err := r.conn.Do(ctx, "GET", key).Result()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set 设置一个值
|
||||||
|
func (r *Redis) Set(key string, val interface{}, timeout time.Duration) error {
|
||||||
|
return r.SetContext(r.ctx, key, val, timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetContext 设置一个值
|
||||||
|
func (r *Redis) SetContext(ctx context.Context, key string, val interface{}, timeout time.Duration) error {
|
||||||
|
return r.conn.SetEX(ctx, key, val, timeout).Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsExist 判断key是否存在
|
||||||
|
func (r *Redis) IsExist(key string) bool {
|
||||||
|
return r.IsExistContext(r.ctx, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsExistContext 判断key是否存在
|
||||||
|
func (r *Redis) IsExistContext(ctx context.Context, key string) bool {
|
||||||
|
result, _ := r.conn.Exists(ctx, key).Result()
|
||||||
|
|
||||||
|
return result > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete 删除
|
||||||
|
func (r *Redis) Delete(key string) error {
|
||||||
|
return r.DeleteContext(r.ctx, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteContext 删除
|
||||||
|
func (r *Redis) DeleteContext(ctx context.Context, key string) error {
|
||||||
|
return r.conn.Del(ctx, key).Err()
|
||||||
|
}
|
||||||
46
cache/redis_test.go
vendored
Normal file
46
cache/redis_test.go
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/alicebob/miniredis/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRedis(t *testing.T) {
|
||||||
|
server, err := miniredis.Run()
|
||||||
|
if err != nil {
|
||||||
|
t.Error("miniredis.Run Error", err)
|
||||||
|
}
|
||||||
|
t.Cleanup(server.Close)
|
||||||
|
var (
|
||||||
|
timeoutDuration = time.Second
|
||||||
|
ctx = context.Background()
|
||||||
|
opts = &RedisOpts{
|
||||||
|
Host: server.Addr(),
|
||||||
|
}
|
||||||
|
redis = NewRedis(ctx, opts)
|
||||||
|
val = "silenceper"
|
||||||
|
key = "username"
|
||||||
|
)
|
||||||
|
redis.SetConn(redis.conn)
|
||||||
|
redis.SetRedisCtx(ctx)
|
||||||
|
|
||||||
|
if err = redis.Set(key, val, timeoutDuration); err != nil {
|
||||||
|
t.Error("set Error", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !redis.IsExist(key) {
|
||||||
|
t.Error("IsExist Error")
|
||||||
|
}
|
||||||
|
|
||||||
|
name := redis.Get(key).(string)
|
||||||
|
if name != val {
|
||||||
|
t.Error("get Error")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = redis.Delete(key); err != nil {
|
||||||
|
t.Errorf("delete Error , err=%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,9 +66,8 @@ func (ak *DefaultAccessToken) GetAccessToken() (accessToken string, err error) {
|
|||||||
func (ak *DefaultAccessToken) GetAccessTokenContext(ctx context.Context) (accessToken string, err error) {
|
func (ak *DefaultAccessToken) GetAccessTokenContext(ctx context.Context) (accessToken string, err error) {
|
||||||
// 先从cache中取
|
// 先从cache中取
|
||||||
accessTokenCacheKey := fmt.Sprintf("%s_access_token_%s", ak.cacheKeyPrefix, ak.appID)
|
accessTokenCacheKey := fmt.Sprintf("%s_access_token_%s", ak.cacheKeyPrefix, ak.appID)
|
||||||
val := ak.cache.Get(accessTokenCacheKey)
|
if val := ak.cache.Get(accessTokenCacheKey); val != nil {
|
||||||
if accessToken = val.(string); accessToken != "" {
|
return val.(string), nil
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加上lock,是为了防止在并发获取token时,cache刚好失效,导致从微信服务器上获取到不同token
|
// 加上lock,是为了防止在并发获取token时,cache刚好失效,导致从微信服务器上获取到不同token
|
||||||
@@ -76,9 +75,8 @@ func (ak *DefaultAccessToken) GetAccessTokenContext(ctx context.Context) (access
|
|||||||
defer ak.accessTokenLock.Unlock()
|
defer ak.accessTokenLock.Unlock()
|
||||||
|
|
||||||
// 双检,防止重复从微信服务器获取
|
// 双检,防止重复从微信服务器获取
|
||||||
val = ak.cache.Get(accessTokenCacheKey)
|
if val := ak.cache.Get(accessTokenCacheKey); val != nil {
|
||||||
if accessToken = val.(string); accessToken != "" {
|
return val.(string), nil
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cache失效,从微信服务器获取
|
// cache失效,从微信服务器获取
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -3,8 +3,10 @@ module github.com/silenceper/wechat/v2
|
|||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/alicebob/miniredis/v2 v2.30.0
|
||||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d
|
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d
|
||||||
github.com/fatih/structs v1.1.0
|
github.com/fatih/structs v1.1.0
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
github.com/spf13/cast v1.4.1
|
github.com/spf13/cast v1.4.1
|
||||||
github.com/stretchr/testify v1.7.1
|
github.com/stretchr/testify v1.7.1
|
||||||
|
|||||||
102
go.sum
102
go.sum
@@ -1,14 +1,61 @@
|
|||||||
|
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk=
|
||||||
|
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
||||||
|
github.com/alicebob/miniredis/v2 v2.30.0 h1:uA3uhDbCxfO9+DI/DuGeAMr9qI+noVWwGPNTFuKID5M=
|
||||||
|
github.com/alicebob/miniredis/v2 v2.30.0/go.mod h1:84TWKZlxYkfgMucPBf5SOQBYJceZeQRFIaQgNMiCX6Q=
|
||||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d h1:pVrfxiGfwelyab6n21ZBkbkmbevaf+WvMIiR7sr97hw=
|
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d h1:pVrfxiGfwelyab6n21ZBkbkmbevaf+WvMIiR7sr97hw=
|
||||||
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||||
|
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
||||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
|
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
|
||||||
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
|
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
|
||||||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
|
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
|
||||||
|
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||||
|
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||||
|
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||||
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||||
|
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||||
|
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||||
|
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||||
|
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||||
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||||
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
|
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||||
|
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||||
|
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||||
@@ -17,6 +64,7 @@ github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
|
|||||||
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
@@ -26,20 +74,74 @@ github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
|||||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64 h1:5mLPGnFdSsevFRFc9q3yYbBkB6tsm4aCwwQV/j1JQAQ=
|
||||||
|
github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||||
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
|
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
|
||||||
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
|
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ miniprogram := wc.GetMiniProgram(&miniConfig.Config{
|
|||||||
AppSecret: "xxx",
|
AppSecret: "xxx",
|
||||||
AppKey: "xxx",
|
AppKey: "xxx",
|
||||||
OfferID: "xxx",
|
OfferID: "xxx",
|
||||||
Cache: cache.NewMemory(),
|
Cache: cache.NewRedis(&redis.Options{
|
||||||
|
Addr: "",
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
virtualPayment := miniprogram.GetVirtualPayment()
|
virtualPayment := miniprogram.GetVirtualPayment()
|
||||||
virtualPayment.SetSessionKey("xxx")
|
virtualPayment.SetSessionKey("xxx")
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ const (
|
|||||||
checkEncryptedDataURL = "https://api.weixin.qq.com/wxa/business/checkencryptedmsg?access_token=%s"
|
checkEncryptedDataURL = "https://api.weixin.qq.com/wxa/business/checkencryptedmsg?access_token=%s"
|
||||||
|
|
||||||
getPhoneNumber = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s"
|
getPhoneNumber = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s"
|
||||||
|
|
||||||
|
checkSessionURL = "https://api.weixin.qq.com/wxa/checksession?access_token=%s&openid=%s&signature=%s&sig_method=hmac_sha256"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Auth 登录/用户信息
|
// Auth 登录/用户信息
|
||||||
@@ -33,7 +35,7 @@ type ResCode2Session struct {
|
|||||||
|
|
||||||
OpenID string `json:"openid"` // 用户唯一标识
|
OpenID string `json:"openid"` // 用户唯一标识
|
||||||
SessionKey string `json:"session_key"` // 会话密钥
|
SessionKey string `json:"session_key"` // 会话密钥
|
||||||
UnionID string `json:"unionid"` // 用户在开放平台的唯一标识符,在满足UnionID下发条件的情况下会返回
|
UnionID string `json:"unionid"` // 用户在开放平台的唯一标识符,在满足 UnionID 下发条件的情况下会返回
|
||||||
}
|
}
|
||||||
|
|
||||||
// RspCheckEncryptedData .
|
// RspCheckEncryptedData .
|
||||||
@@ -70,12 +72,12 @@ func (auth *Auth) GetPaidUnionID() {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckEncryptedData .检查加密信息是否由微信生成(当前只支持手机号加密数据),只能检测最近3天生成的加密数据
|
// CheckEncryptedData .检查加密信息是否由微信生成(当前只支持手机号加密数据),只能检测最近 3 天生成的加密数据
|
||||||
func (auth *Auth) CheckEncryptedData(encryptedMsgHash string) (result RspCheckEncryptedData, err error) {
|
func (auth *Auth) CheckEncryptedData(encryptedMsgHash string) (result RspCheckEncryptedData, err error) {
|
||||||
return auth.CheckEncryptedDataContext(context2.Background(), encryptedMsgHash)
|
return auth.CheckEncryptedDataContext(context2.Background(), encryptedMsgHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckEncryptedDataContext .检查加密信息是否由微信生成(当前只支持手机号加密数据),只能检测最近3天生成的加密数据
|
// CheckEncryptedDataContext .检查加密信息是否由微信生成(当前只支持手机号加密数据),只能检测最近 3 天生成的加密数据
|
||||||
func (auth *Auth) CheckEncryptedDataContext(ctx context2.Context, encryptedMsgHash string) (result RspCheckEncryptedData, err error) {
|
func (auth *Auth) CheckEncryptedDataContext(ctx context2.Context, encryptedMsgHash string) (result RspCheckEncryptedData, err error) {
|
||||||
var response []byte
|
var response []byte
|
||||||
var (
|
var (
|
||||||
@@ -85,7 +87,7 @@ func (auth *Auth) CheckEncryptedDataContext(ctx context2.Context, encryptedMsgHa
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 由于GetPhoneNumberContext需要传入JSON,所以HTTPPostContext入参改为[]byte
|
// 由于 GetPhoneNumberContext 需要传入 JSON,所以 HTTPPostContext 入参改为 []byte
|
||||||
if response, err = util.HTTPPostContext(ctx, fmt.Sprintf(checkEncryptedDataURL, at), []byte("encrypted_msg_hash="+encryptedMsgHash), nil); err != nil {
|
if response, err = util.HTTPPostContext(ctx, fmt.Sprintf(checkEncryptedDataURL, at), []byte("encrypted_msg_hash="+encryptedMsgHash), nil); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -113,38 +115,62 @@ type PhoneInfo struct {
|
|||||||
} `json:"watermark"` // 数据水印
|
} `json:"watermark"` // 数据水印
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPhoneNumberContext 小程序通过code获取用户手机号
|
// GetPhoneNumberContext 小程序通过 code 获取用户手机号
|
||||||
func (auth *Auth) GetPhoneNumberContext(ctx context2.Context, code string) (*GetPhoneNumberResponse, error) {
|
func (auth *Auth) GetPhoneNumberContext(ctx context2.Context, code string) (result *GetPhoneNumberResponse, err error) {
|
||||||
var response []byte
|
var accessToken string
|
||||||
var (
|
if accessToken, err = auth.GetAccessToken(); err != nil {
|
||||||
at string
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
if at, err = auth.GetAccessToken(); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
body := map[string]interface{}{
|
|
||||||
"code": code,
|
|
||||||
}
|
|
||||||
|
|
||||||
bodyBytes, err := json.Marshal(body)
|
bodyBytes, err := json.Marshal(map[string]interface{}{
|
||||||
|
"code": code,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
header := map[string]string{"Content-Type": "application/json;charset=utf-8"}
|
var (
|
||||||
if response, err = util.HTTPPostContext(ctx, fmt.Sprintf(getPhoneNumber, at), bodyBytes, header); err != nil {
|
header = map[string]string{"Content-Type": "application/json;charset=utf-8"}
|
||||||
|
response []byte
|
||||||
|
)
|
||||||
|
|
||||||
|
if response, err = util.HTTPPostContext(ctx, fmt.Sprintf(getPhoneNumber, accessToken), bodyBytes, header); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var result GetPhoneNumberResponse
|
err = util.DecodeWithError(response, &result, "phonenumber.getPhoneNumber")
|
||||||
if err = util.DecodeWithError(response, &result, "phonenumber.getPhoneNumber"); err != nil {
|
return
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPhoneNumber 小程序通过code获取用户手机号
|
// GetPhoneNumber 小程序通过 code 获取用户手机号
|
||||||
func (auth *Auth) GetPhoneNumber(code string) (*GetPhoneNumberResponse, error) {
|
func (auth *Auth) GetPhoneNumber(code string) (*GetPhoneNumberResponse, error) {
|
||||||
return auth.GetPhoneNumberContext(context2.Background(), code)
|
return auth.GetPhoneNumberContext(context2.Background(), code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // CheckSession 检验登录态是否过期。
|
||||||
|
// func (auth *Auth) CheckSession(sessionKey, openID string) (result *CheckSessionResponse, err error) {
|
||||||
|
// return auth.CheckSessionContext(context2.Background(), sessionKey, openID)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // CheckSessionContext 检验登录态是否过期。
|
||||||
|
// func (auth *Auth) CheckSessionContext(ctx context2.Context, sessionKey, openID string) (result *CheckSessionResponse, err error) {
|
||||||
|
// var accessToken string
|
||||||
|
// if accessToken, err = auth.GetAccessToken(); err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// var (
|
||||||
|
// response []byte
|
||||||
|
// signature string = sessionKey
|
||||||
|
// )
|
||||||
|
// if response, err = util.HTTPGetContext(ctx, fmt.Sprintf(checkSessionURL, accessToken, openID, signature)); err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// err = util.DecodeWithError(response, &result, "CheckSessionContext")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // CheckSessionResponse 检验登录态是否过期。
|
||||||
|
// type CheckSessionResponse struct {
|
||||||
|
// util.CommonError
|
||||||
|
// }
|
||||||
|
|||||||
@@ -117,6 +117,24 @@ const (
|
|||||||
|
|
||||||
// queryPublishGoods 查询批量发布道具任务状态
|
// queryPublishGoods 查询批量发布道具任务状态
|
||||||
queryPublishGoods = "/xpay/query_publish_goods"
|
queryPublishGoods = "/xpay/query_publish_goods"
|
||||||
|
|
||||||
|
// queryBizBalance 查询商家账户里的可提现余额
|
||||||
|
queryBizBalance = "/xpay/query_biz_balance"
|
||||||
|
|
||||||
|
// queryTransferAccount 查询广告金充值账户
|
||||||
|
queryTransferAccount = "/xpay/query_transfer_account"
|
||||||
|
|
||||||
|
// queryAdverFunds 查询广告金发放记录
|
||||||
|
queryAdverFunds = "/xpay/query_adver_funds"
|
||||||
|
|
||||||
|
// createFundsBill 充值广告金
|
||||||
|
createFundsBill = "/xpay/create_funds_bill"
|
||||||
|
|
||||||
|
// bindTransferAccount 绑定广告金充值账户
|
||||||
|
bindTransferAccount = "/xpay/bind_transfer_accout"
|
||||||
|
|
||||||
|
// defaultUnifiedOrderURL default unified order url
|
||||||
|
defaultUnifiedOrderURL = "requestVirtualPayment"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ type OrderItem struct {
|
|||||||
WxOrderID string `json:"wx_order_id"` // 微信内部单号
|
WxOrderID string `json:"wx_order_id"` // 微信内部单号
|
||||||
ChannelOrderID string `json:"channel_order_id"` // 渠道订单号,为用户微信支付详情页面上的商户单号
|
ChannelOrderID string `json:"channel_order_id"` // 渠道订单号,为用户微信支付详情页面上的商户单号
|
||||||
WxPayOrderID string `json:"wxpay_order_id"` // 微信支付交易单号,为用户微信支付详情页面上的交易单号
|
WxPayOrderID string `json:"wxpay_order_id"` // 微信支付交易单号,为用户微信支付详情页面上的交易单号
|
||||||
|
SettTime int64 `json:"sett_time"` // 结算时间,unix 秒级时间戳,结算时间的秒级时间戳,大于 0 表示结算成功
|
||||||
|
SettState uint `json:"sett_state"` // 结算状态 0-未开始结算 1-结算中 2-结算成功
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryOrderResponse 查询创建的订单(现金单,非代币单)响应参数
|
// QueryOrderResponse 查询创建的订单(现金单,非代币单)响应参数
|
||||||
|
|||||||
@@ -479,6 +479,7 @@ func (s *VirtualPayment) requestAddress(params URLParams) (url string, err error
|
|||||||
case queryUserBalance:
|
case queryUserBalance:
|
||||||
case currencyPay:
|
case currencyPay:
|
||||||
case cancelCurrencyPay:
|
case cancelCurrencyPay:
|
||||||
|
case defaultUnifiedOrderURL:
|
||||||
if params.PaySign, params.Signature, err = s.PaySignature(params.Path, params.Content); err != nil {
|
if params.PaySign, params.Signature, err = s.PaySignature(params.Path, params.Content); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/silenceper/wechat/v2/pay/config"
|
"github.com/silenceper/wechat/v2/pay/config"
|
||||||
"github.com/silenceper/wechat/v2/pay/notify"
|
"github.com/silenceper/wechat/v2/pay/notify"
|
||||||
"github.com/silenceper/wechat/v2/pay/order"
|
"github.com/silenceper/wechat/v2/pay/order"
|
||||||
"github.com/silenceper/wechat/v2/pay/redpacket"
|
|
||||||
"github.com/silenceper/wechat/v2/pay/refund"
|
"github.com/silenceper/wechat/v2/pay/refund"
|
||||||
"github.com/silenceper/wechat/v2/pay/transfer"
|
"github.com/silenceper/wechat/v2/pay/transfer"
|
||||||
)
|
)
|
||||||
@@ -38,8 +37,3 @@ func (pay *Pay) GetRefund() *refund.Refund {
|
|||||||
func (pay *Pay) GetTransfer() *transfer.Transfer {
|
func (pay *Pay) GetTransfer() *transfer.Transfer {
|
||||||
return transfer.NewTransfer(pay.cfg)
|
return transfer.NewTransfer(pay.cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRedpacket 红包
|
|
||||||
func (pay *Pay) GetRedpacket() *redpacket.Redpacket {
|
|
||||||
return redpacket.NewRedpacket(pay.cfg)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,131 +0,0 @@
|
|||||||
package redpacket
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/xml"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/silenceper/wechat/v2/pay/config"
|
|
||||||
"github.com/silenceper/wechat/v2/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
// redpacketGateway 发放红包接口
|
|
||||||
// https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3
|
|
||||||
var redpacketGateway = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack"
|
|
||||||
|
|
||||||
// Redpacket struct extends context
|
|
||||||
type Redpacket struct {
|
|
||||||
*config.Config
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRedpacket return an instance of Redpacket package
|
|
||||||
func NewRedpacket(cfg *config.Config) *Redpacket {
|
|
||||||
return &Redpacket{cfg}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Params 调用参数
|
|
||||||
type Params struct {
|
|
||||||
MchBillno string // 商户订单号
|
|
||||||
SendName string // 商户名称
|
|
||||||
ReOpenID string
|
|
||||||
TotalAmount int
|
|
||||||
TotalNum int
|
|
||||||
Wishing string
|
|
||||||
ClientIP string
|
|
||||||
ActName string
|
|
||||||
Remark string
|
|
||||||
|
|
||||||
RootCa string // ca证书
|
|
||||||
}
|
|
||||||
|
|
||||||
// request 接口请求参数
|
|
||||||
type request struct {
|
|
||||||
NonceStr string `xml:"nonce_str"`
|
|
||||||
Sign string `xml:"sign"`
|
|
||||||
MchID string `xml:"mch_id"`
|
|
||||||
MchBillno string `xml:"mch_billno"`
|
|
||||||
Wxappid string `xml:"wxappid"`
|
|
||||||
SendName string `xml:"send_name"`
|
|
||||||
ReOpenID string `xml:"re_openid"`
|
|
||||||
TotalAmount int `xml:"total_amount"`
|
|
||||||
TotalNum int `xml:"total_num"`
|
|
||||||
Wishing string `xml:"wishing"`
|
|
||||||
ClientIP string `xml:"client_ip"`
|
|
||||||
ActName string `xml:"act_name"`
|
|
||||||
Remark string `xml:"remark"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response 接口返回
|
|
||||||
type Response struct {
|
|
||||||
ReturnCode string `xml:"return_code"`
|
|
||||||
ReturnMsg string `xml:"return_msg"`
|
|
||||||
ResultCode string `xml:"result_code,omitempty"`
|
|
||||||
ErrCode string `xml:"err_code,omitempty"`
|
|
||||||
ErrCodeDes string `xml:"err_code_des,omitempty"`
|
|
||||||
MchBillno string `xml:"mch_billno,omitempty"`
|
|
||||||
MchID string `xml:"mch_id,omitempty"`
|
|
||||||
Wxappid string `xml:"wxappid"`
|
|
||||||
ReOpenID string `xml:"re_openid"`
|
|
||||||
TotalAmount int `xml:"total_amount"`
|
|
||||||
SendListid string `xml:"send_listid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SendRedpacket 发放红包
|
|
||||||
func (redpacket *Redpacket) SendRedpacket(p *Params) (rsp *Response, err error) {
|
|
||||||
nonceStr := util.RandomStr(32)
|
|
||||||
param := make(map[string]string)
|
|
||||||
|
|
||||||
param["nonce_str"] = nonceStr
|
|
||||||
param["mch_id"] = redpacket.MchID
|
|
||||||
param["wxappid"] = redpacket.AppID
|
|
||||||
param["mch_billno"] = p.MchBillno
|
|
||||||
param["send_name"] = p.SendName
|
|
||||||
param["re_openid"] = p.ReOpenID
|
|
||||||
param["total_amount"] = strconv.Itoa(p.TotalAmount)
|
|
||||||
param["total_num"] = strconv.Itoa(p.TotalNum)
|
|
||||||
param["wishing"] = p.Wishing
|
|
||||||
param["client_ip"] = p.ClientIP
|
|
||||||
param["act_name"] = p.ActName
|
|
||||||
param["remark"] = p.Remark
|
|
||||||
//param["scene_id"] = "PRODUCT_2"
|
|
||||||
|
|
||||||
sign, err := util.ParamSign(param, redpacket.Key)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
req := request{
|
|
||||||
NonceStr: nonceStr,
|
|
||||||
Sign: sign,
|
|
||||||
MchID: redpacket.MchID,
|
|
||||||
Wxappid: redpacket.AppID,
|
|
||||||
MchBillno: p.MchBillno,
|
|
||||||
SendName: p.SendName,
|
|
||||||
ReOpenID: p.ReOpenID,
|
|
||||||
TotalAmount: p.TotalAmount,
|
|
||||||
TotalNum: p.TotalNum,
|
|
||||||
Wishing: p.Wishing,
|
|
||||||
ClientIP: p.ClientIP,
|
|
||||||
ActName: p.ActName,
|
|
||||||
Remark: p.Remark,
|
|
||||||
}
|
|
||||||
|
|
||||||
rawRet, err := util.PostXMLWithTLS(redpacketGateway, req, p.RootCa, redpacket.MchID)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = xml.Unmarshal(rawRet, &rsp)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if rsp.ReturnCode == "SUCCESS" {
|
|
||||||
if rsp.ResultCode == "SUCCESS" {
|
|
||||||
err = nil
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = fmt.Errorf("send redpacket error, errcode=%s,errmsg=%s", rsp.ErrCode, rsp.ErrCodeDes)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = fmt.Errorf("[msg : xmlUnmarshalError] [rawReturn : %s] [sign : %s]", string(rawRet), sign)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
@@ -13,8 +13,6 @@ const (
|
|||||||
departmentSimpleListURL = "https://qyapi.weixin.qq.com/cgi-bin/department/simplelist?access_token=%s&id=%d"
|
departmentSimpleListURL = "https://qyapi.weixin.qq.com/cgi-bin/department/simplelist?access_token=%s&id=%d"
|
||||||
// departmentListURL 获取部门列表
|
// departmentListURL 获取部门列表
|
||||||
departmentListURL = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=%s"
|
departmentListURL = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=%s"
|
||||||
// departmentGetURL 获取单个部门详情 https://qyapi.weixin.qq.com/cgi-bin/department/get?access_token=ACCESS_TOKEN&id=ID
|
|
||||||
departmentGetURL = "https://qyapi.weixin.qq.com/cgi-bin/department/get?access_token=%s&id=%d"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -58,11 +56,6 @@ type (
|
|||||||
ParentID int `json:"parentid"` // 父部门id。根部门为1
|
ParentID int `json:"parentid"` // 父部门id。根部门为1
|
||||||
Order int `json:"order"` // 在父部门中的次序值。order值大的排序靠前
|
Order int `json:"order"` // 在父部门中的次序值。order值大的排序靠前
|
||||||
}
|
}
|
||||||
// DepartmentGetResponse 获取单个部门详情
|
|
||||||
DepartmentGetResponse struct {
|
|
||||||
util.CommonError
|
|
||||||
Department Department `json:"department"`
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DepartmentCreate 创建部门
|
// DepartmentCreate 创建部门
|
||||||
@@ -128,24 +121,3 @@ func (r *Client) DepartmentList() ([]*Department, error) {
|
|||||||
// 返回数据
|
// 返回数据
|
||||||
return result.Department, err
|
return result.Department, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DepartmentGet 获取单个部门详情
|
|
||||||
// see https://developer.work.weixin.qq.com/document/path/95351
|
|
||||||
func (r *Client) DepartmentGet(departmentID int) (*Department, error) {
|
|
||||||
var (
|
|
||||||
accessToken string
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var response []byte
|
|
||||||
if response, err = util.HTTPGet(fmt.Sprintf(departmentGetURL, accessToken, departmentID)); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
result := &DepartmentGetResponse{}
|
|
||||||
if err = util.DecodeWithError(response, result, "DepartmentGet"); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &result.Department, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ type UserGetResponse struct {
|
|||||||
} `json:"external_profile"` // 成员对外属性,字段详情见对外属性;代开发自建应用需要管理员授权才返回;第三方仅通讯录应用可获取;对于非第三方创建的成员,第三方通讯录应用也不可获取;上游企业不可获取下游企业成员该字段
|
} `json:"external_profile"` // 成员对外属性,字段详情见对外属性;代开发自建应用需要管理员授权才返回;第三方仅通讯录应用可获取;对于非第三方创建的成员,第三方通讯录应用也不可获取;上游企业不可获取下游企业成员该字段
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserGet 读取成员
|
// UserGet 获取部门成员
|
||||||
// @see https://developer.work.weixin.qq.com/document/path/90196
|
// @see https://developer.work.weixin.qq.com/document/path/90196
|
||||||
func (r *Client) UserGet(UserID string) (*UserGetResponse, error) {
|
func (r *Client) UserGet(UserID string) (*UserGetResponse, error) {
|
||||||
var (
|
var (
|
||||||
@@ -237,8 +237,8 @@ func (r *Client) UserGet(UserID string) (*UserGetResponse, error) {
|
|||||||
strings.Join([]string{
|
strings.Join([]string{
|
||||||
userGetURL,
|
userGetURL,
|
||||||
util.Query(map[string]interface{}{
|
util.Query(map[string]interface{}{
|
||||||
"access_token": accessToken,
|
"access_token": accessToken,
|
||||||
"userid": UserID,
|
"department_id": UserID,
|
||||||
}),
|
}),
|
||||||
}, "?")); err != nil {
|
}, "?")); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
package checkin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/silenceper/wechat/v2/util"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// getCheckinDataURL 获取打卡记录数据
|
|
||||||
getCheckinDataURL = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token=%s"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
// GetCheckinDataRequest 获取打卡记录数据请求
|
|
||||||
GetCheckinDataRequest struct {
|
|
||||||
OpenCheckinDataType int64 `json:"opencheckindatatype"`
|
|
||||||
StartTime int64 `json:"starttime"`
|
|
||||||
EndTime int64 `json:"endtime"`
|
|
||||||
UserIDList []string `json:"useridlist"`
|
|
||||||
}
|
|
||||||
// GetCheckinDataResponse 获取打卡记录数据响应
|
|
||||||
GetCheckinDataResponse struct {
|
|
||||||
util.CommonError
|
|
||||||
CheckinData []*GetCheckinDataItem `json:"checkindata"`
|
|
||||||
}
|
|
||||||
// GetCheckinDataItem 打卡记录数据
|
|
||||||
GetCheckinDataItem struct {
|
|
||||||
UserID string `json:"userid"`
|
|
||||||
GroupName string `json:"groupname"`
|
|
||||||
CheckinType string `json:"checkin_type"`
|
|
||||||
ExceptionType string `json:"exception_type"`
|
|
||||||
CheckinTime int64 `json:"checkin_time"`
|
|
||||||
LocationTitle string `json:"location_title"`
|
|
||||||
LocationDetail string `json:"location_detail"`
|
|
||||||
WifiName string `json:"wifiname"`
|
|
||||||
Notes string `json:"notes"`
|
|
||||||
WifiMac string `json:"wifimac"`
|
|
||||||
MediaIDs []string `json:"mediaids"`
|
|
||||||
SchCheckinTime int64 `json:"sch_checkin_time"`
|
|
||||||
GroupID int64 `json:"groupid"`
|
|
||||||
ScheduleID int64 `json:"schedule_id"`
|
|
||||||
TimelineID int64 `json:"timeline_id"`
|
|
||||||
Lat int64 `json:"lat,omitempty"`
|
|
||||||
Lng int64 `json:"lng,omitempty"`
|
|
||||||
DeviceID string `json:"deviceid,omitempty"`
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetCheckinData 获取打卡记录数据
|
|
||||||
// @see https://developer.work.weixin.qq.com/document/path/90262
|
|
||||||
func (r *Client) GetCheckinData(req *GetCheckinDataRequest) (*GetCheckinDataResponse, error) {
|
|
||||||
var (
|
|
||||||
accessToken string
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var response []byte
|
|
||||||
if response, err = util.PostJSON(fmt.Sprintf(getCheckinDataURL, accessToken), req); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
result := &GetCheckinDataResponse{}
|
|
||||||
if err = util.DecodeWithError(response, result, "GetCheckinData"); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package checkin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/silenceper/wechat/v2/work/context"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Client 打卡接口实例
|
|
||||||
type Client struct {
|
|
||||||
*context.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewClient 初始化实例
|
|
||||||
func NewClient(ctx *context.Context) *Client {
|
|
||||||
return &Client{
|
|
||||||
ctx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -70,7 +70,6 @@ type (
|
|||||||
GroupNickname string `json:"group_nickname"` //在群里的昵称
|
GroupNickname string `json:"group_nickname"` //在群里的昵称
|
||||||
Name string `json:"name"` //名字。仅当 need_name = 1 时返回 如果是微信用户,则返回其在微信中设置的名字 如果是企业微信联系人,则返回其设置对外展示的别名或实名
|
Name string `json:"name"` //名字。仅当 need_name = 1 时返回 如果是微信用户,则返回其在微信中设置的名字 如果是企业微信联系人,则返回其设置对外展示的别名或实名
|
||||||
UnionID string `json:"unionid,omitempty"` //外部联系人在微信开放平台的唯一身份标识(微信unionid),通过此字段企业可将外部联系人与公众号/小程序用户关联起来。仅当群成员类型是微信用户(包括企业成员未添加好友),且企业绑定了微信开发者ID有此字段(查看绑定方法)。第三方不可获取,上游企业不可获取下游企业客户的unionid字段
|
UnionID string `json:"unionid,omitempty"` //外部联系人在微信开放平台的唯一身份标识(微信unionid),通过此字段企业可将外部联系人与公众号/小程序用户关联起来。仅当群成员类型是微信用户(包括企业成员未添加好友),且企业绑定了微信开发者ID有此字段(查看绑定方法)。第三方不可获取,上游企业不可获取下游企业客户的unionid字段
|
||||||
State string `json:"state,omitempty"` //如果在配置入群方式时,配置了state参数,那么在获取客户群详情时,通过该方式入群的成员,会额外获取到相应的state参数
|
|
||||||
}
|
}
|
||||||
//GroupChatAdmin 群管理员
|
//GroupChatAdmin 群管理员
|
||||||
GroupChatAdmin struct {
|
GroupChatAdmin struct {
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ const (
|
|||||||
uploadImgURL = "https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=%s"
|
uploadImgURL = "https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=%s"
|
||||||
// uploadTempFile 上传临时素材
|
// uploadTempFile 上传临时素材
|
||||||
uploadTempFile = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=%s&type=%s"
|
uploadTempFile = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=%s&type=%s"
|
||||||
// uploadAttachment 上传附件资源
|
|
||||||
uploadAttachment = "https://qyapi.weixin.qq.com/cgi-bin/media/upload_attachment?access_token=%s&media_type=%s&attachment_type=%d"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// UploadImgResponse 上传图片响应
|
// UploadImgResponse 上传图片响应
|
||||||
@@ -29,14 +27,6 @@ type UploadTempFileResponse struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UploadAttachmentResponse 上传资源附件响应
|
|
||||||
type UploadAttachmentResponse struct {
|
|
||||||
util.CommonError
|
|
||||||
MediaID string `json:"media_id"`
|
|
||||||
CreateAt int64 `json:"created_at"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// UploadImg 上传图片
|
// UploadImg 上传图片
|
||||||
// @see https://developer.work.weixin.qq.com/document/path/90256
|
// @see https://developer.work.weixin.qq.com/document/path/90256
|
||||||
func (r *Client) UploadImg(filename string) (*UploadImgResponse, error) {
|
func (r *Client) UploadImg(filename string) (*UploadImgResponse, error) {
|
||||||
@@ -79,26 +69,3 @@ func (r *Client) UploadTempFile(filename string, mediaType string) (*UploadTempF
|
|||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UploadAttachment 上传附件资源
|
|
||||||
// @see https://developer.work.weixin.qq.com/document/path/95098
|
|
||||||
// @mediaType 媒体文件类型,分别有图片(image)、视频(video)、普通文件(file)
|
|
||||||
// @attachment_type 附件类型,不同的附件类型用于不同的场景。1:朋友圈;2:商品图册
|
|
||||||
func (r *Client) UploadAttachment(filename string, mediaType string, attachmentType int) (*UploadAttachmentResponse, error) {
|
|
||||||
var (
|
|
||||||
accessToken string
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var response []byte
|
|
||||||
if response, err = util.PostFile("media", filename, fmt.Sprintf(uploadAttachment, accessToken, mediaType, attachmentType)); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
result := &UploadAttachmentResponse{}
|
|
||||||
if err = util.DecodeWithError(response, result, "UploadAttachment"); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/silenceper/wechat/v2/credential"
|
"github.com/silenceper/wechat/v2/credential"
|
||||||
"github.com/silenceper/wechat/v2/work/addresslist"
|
"github.com/silenceper/wechat/v2/work/addresslist"
|
||||||
"github.com/silenceper/wechat/v2/work/appchat"
|
"github.com/silenceper/wechat/v2/work/appchat"
|
||||||
"github.com/silenceper/wechat/v2/work/checkin"
|
|
||||||
"github.com/silenceper/wechat/v2/work/config"
|
"github.com/silenceper/wechat/v2/work/config"
|
||||||
"github.com/silenceper/wechat/v2/work/context"
|
"github.com/silenceper/wechat/v2/work/context"
|
||||||
"github.com/silenceper/wechat/v2/work/externalcontact"
|
"github.com/silenceper/wechat/v2/work/externalcontact"
|
||||||
@@ -86,8 +85,3 @@ func (wk *Work) GetAppChat() *appchat.Client {
|
|||||||
func (wk *Work) GetInvoice() *invoice.Client {
|
func (wk *Work) GetInvoice() *invoice.Client {
|
||||||
return invoice.NewClient(wk.ctx)
|
return invoice.NewClient(wk.ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCheckin 获取打卡接口实例
|
|
||||||
func (wk *Work) GetCheckin() *checkin.Client {
|
|
||||||
return checkin.NewClient(wk.ctx)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user