-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
71 lines (66 loc) · 1.47 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package test
import (
"encoding/json"
"fmt"
"github.com/EricJSanchez/wecom"
"github.com/EricJSanchez/wecom/cache"
"github.com/EricJSanchez/wecom/config"
)
func Wework(names ...string) *wecom.Wecom {
if len(names) > 0 {
var name = ""
var agentId = ""
name = names[0]
if len(names) > 1 {
agentId = names[1]
}
return NewInstance(name, agentId)
} else {
fmt.Sprintf("企业微信查询出错!")
return nil
}
}
func NewInstance(name, agentId string) *wecom.Wecom {
redisCache := cache.NewRedis(&cache.RedisOpts{
Host: "192.168.100.107:6379",
Password: "t[]******#[p",
Database: 0,
MaxIdle: 40,
MaxActive: 100,
IdleTimeout: 240,
})
// TODO 读取数据库
wk := wecom.NewWecom(&config.Config{
CorpID: name,
CorpSecret: "",
AgentID: agentId,
AgentSecret: "",
Cache: redisCache,
RasVersion: 0,
RasPrivateKey: "",
Token: "",
EncodingAESKey: "",
ContactSecret: "zhAK******yFgHarM",
CustomerSecret: "Zdf3ur****7d5Vp4M",
Cookie: "",
})
return wk
}
func Pr(val ...interface{}) {
if len(val) > 1 {
for _, v := range val {
switch v.(type) {
case []uint8:
fmt.Println("[]uint8 ori: ", v)
fmt.Printf("[]uint8 str: %s-\n\n", v)
continue
default:
bytes, _ := json.MarshalIndent(v, "", " ")
fmt.Printf("%T : %s-\n", v, bytes)
}
}
} else {
bytes, _ := json.MarshalIndent(val, "", " ")
fmt.Printf("%T : %s-\n", val, bytes)
}
}