mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-23 13:42:25 +08:00
Compare commits
5 Commits
v2.1.6-rc.
...
23c3f29db2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23c3f29db2 | ||
|
|
9bfebc8a27 | ||
|
|
4f6cbc3d59 | ||
|
|
e7ff8d90ed | ||
|
|
5467bc6245 |
4
.github/workflows/go.yml
vendored
4
.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' ]
|
go-version: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
|
||||||
name: golangci-lint
|
name: golangci-lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
# strategy set
|
# strategy set
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [ '1.16','1.17','1.18','1.19','1.20' ]
|
go: [ '1.16','1.17','1.18','1.19','1.20','1.21' ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|||||||
29
.github/workflows/release.yml
vendored
29
.github/workflows/release.yml
vendored
@@ -1,29 +0,0 @@
|
|||||||
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 }}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# 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:'
|
|
||||||
10
cache/redis.go
vendored
10
cache/redis.go
vendored
@@ -8,6 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Redis .redis cache
|
// Redis .redis cache
|
||||||
|
// Deprecated: user defined implementation cache、ContextCache interface
|
||||||
|
// The implementation was officially removed in v2.1.6
|
||||||
type Redis struct {
|
type Redis struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
conn redis.UniversalClient
|
conn redis.UniversalClient
|
||||||
@@ -35,12 +37,12 @@ func NewRedis(ctx context.Context, opts *RedisOpts) *Redis {
|
|||||||
return &Redis{ctx: ctx, conn: conn}
|
return &Redis{ctx: ctx, conn: conn}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConn 设置conn
|
// SetConn 设置 conn
|
||||||
func (r *Redis) SetConn(conn redis.UniversalClient) {
|
func (r *Redis) SetConn(conn redis.UniversalClient) {
|
||||||
r.conn = conn
|
r.conn = conn
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRedisCtx 设置redis ctx 参数
|
// SetRedisCtx 设置 redis ctx 参数
|
||||||
func (r *Redis) SetRedisCtx(ctx context.Context) {
|
func (r *Redis) SetRedisCtx(ctx context.Context) {
|
||||||
r.ctx = ctx
|
r.ctx = ctx
|
||||||
}
|
}
|
||||||
@@ -69,12 +71,12 @@ func (r *Redis) SetContext(ctx context.Context, key string, val interface{}, tim
|
|||||||
return r.conn.SetEX(ctx, key, val, timeout).Err()
|
return r.conn.SetEX(ctx, key, val, timeout).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsExist 判断key是否存在
|
// IsExist 判断 key 是否存在
|
||||||
func (r *Redis) IsExist(key string) bool {
|
func (r *Redis) IsExist(key string) bool {
|
||||||
return r.IsExistContext(r.ctx, key)
|
return r.IsExistContext(r.ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsExistContext 判断key是否存在
|
// IsExistContext 判断 key 是否存在
|
||||||
func (r *Redis) IsExistContext(ctx context.Context, key string) bool {
|
func (r *Redis) IsExistContext(ctx context.Context, key string) bool {
|
||||||
result, _ := r.conn.Exists(ctx, key).Result()
|
result, _ := r.conn.Exists(ctx, key).Result()
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ 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 创建部门
|
||||||
@@ -138,9 +143,9 @@ func (r *Client) DepartmentGet(departmentID int) (*Department, error) {
|
|||||||
if response, err = util.HTTPGet(fmt.Sprintf(departmentGetURL, accessToken, departmentID)); err != nil {
|
if response, err = util.HTTPGet(fmt.Sprintf(departmentGetURL, accessToken, departmentID)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result := &Department{}
|
result := &DepartmentGetResponse{}
|
||||||
if err = util.DecodeWithError(response, result, "DepartmentGet"); err != nil {
|
if err = util.DecodeWithError(response, result, "DepartmentGet"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return result, nil
|
return &result.Department, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user