@@ -7,12 +7,14 @@ import (
77 "strconv"
88
99 fmt2 "github.com/ArtisanCloud/PowerLibs/v3/fmt"
10+
1011 "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
1112 "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"
1213 "github.com/ArtisanCloud/PowerWeChat/v3/src/miniProgram"
1314 "github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount"
1415 "github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount/templateMessage/request"
1516 "github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform"
17+ "github.com/ArtisanCloud/PowerWeChat/v3/src/openWork"
1618 "github.com/ArtisanCloud/PowerWeChat/v3/src/payment"
1719 "github.com/ArtisanCloud/PowerWeChat/v3/src/work"
1820 "go.opentelemetry.io/otel"
@@ -29,6 +31,8 @@ func GetOfficialConfig() *officialAccount.UserConfig {
2931 Log : officialAccount.Log {
3032 Level : "debug" ,
3133 Stdout : false ,
34+ File : "/Users/michaelhu/wechat/official-account/info.log" ,
35+ Error : "/Users/michaelhu/wechat/official-account/error.log" ,
3236 },
3337 Http : officialAccount.Http {
3438 ProxyURI : "" ,
@@ -40,7 +44,7 @@ func GetOfficialConfig() *officialAccount.UserConfig {
4044 Password : "" ,
4145 DB : 1 ,
4246 }),
43- HttpDebug : false ,
47+ HttpDebug : true ,
4448 Debug : false ,
4549 }
4650}
@@ -55,8 +59,10 @@ func GetWorkConfig() *work.UserConfig {
5559 ResponseType : os .Getenv ("array" ),
5660 Log : work.Log {
5761 Level : "debug" ,
58- File : "./wechat/info.log" ,
59- Error : "./wechat/error.log" ,
62+ //File: "./wechat/info.log",
63+ //Error: "./wechat/error.log",
64+ File : "/Users/michaelhu/wechat/work/info.log" ,
65+ Error : "/Users/michaelhu/wechat/work/error.log" ,
6066 ENV : os .Getenv ("work.env" ),
6167 },
6268
@@ -101,8 +107,10 @@ func GetPaymentConfig() *payment.UserConfig {
101107 ResponseType : os .Getenv ("array" ),
102108 Log : payment.Log {
103109 Level : "debug" ,
104- File : "./wechat/info.log" ,
105- Error : "./wechat/error.log" ,
110+ //File: "./wechat/info.log",
111+ //Error: "./wechat/error.log",
112+ File : "/Users/michaelhu/wechat/payment/info.log" ,
113+ Error : "/Users/michaelhu/wechat/payment/error.log" ,
106114 },
107115 Http : payment.Http {
108116 Timeout : 30.0 ,
@@ -135,8 +143,8 @@ func GetMiniProgramConfig() *miniProgram.UserConfig {
135143 ResponseType : os .Getenv ("array" ),
136144 Log : miniProgram.Log {
137145 Level : "debug" ,
138- File : "./ wechat/info.log" ,
139- Error : "./ wechat/error.log" ,
146+ File : "/Users/michaelhu/ wechat/mini-program /info.log" ,
147+ Error : "/Users/michaelhu/ wechat/mini-program /error.log" ,
140148 },
141149 Cache : kernel .NewRedisClient (& kernel.UniversalOptions {
142150 Addrs : []string {"127.0.0.1:6379" },
@@ -162,8 +170,10 @@ func GetOpenPlatformConfig() *openPlatform.UserConfig {
162170 ResponseType : os .Getenv ("array" ),
163171 Log : openPlatform.Log {
164172 Level : "debug" ,
165- File : "./wechat/info.log" ,
166- Error : "./wechat/error.log" ,
173+ //File: "./wechat/info.log",
174+ //Error: "./wechat/error.log",
175+ File : "/Users/michaelhu/wechat/platform/info.log" ,
176+ Error : "/Users/michaelhu/wechat/platform/error.log" ,
167177 },
168178 Cache : kernel .NewRedisClient (& kernel.UniversalOptions {
169179 Addrs : []string {"127.0.0.1:6379" },
@@ -181,6 +191,28 @@ func GetOpenPlatformConfig() *openPlatform.UserConfig {
181191 }
182192}
183193
194+ func GetOpenWorkConfig () * openWork.UserConfig {
195+ return & openWork.UserConfig {
196+ AppID : "123" ,
197+ Secret : "321" ,
198+ AuthCode : "123" ,
199+ AESKey : "321" ,
200+ ResponseType : os .Getenv ("array" ),
201+
202+ Cache : kernel .NewRedisClient (& kernel.UniversalOptions {
203+ Addrs : []string {"127.0.0.1:6379" },
204+ Password : "" ,
205+ DB : 1 ,
206+ }),
207+
208+ // OAuth: "",
209+ // HttpDebug: "",
210+ // Debug: "",
211+ // NotifyURL: "",
212+ // Sandbox: "",
213+ }
214+ }
215+
184216func initTracer () {
185217 tp := trace .NewTracerProvider ()
186218 // Set Global Tracer Provider
@@ -252,11 +284,20 @@ func main() {
252284 }
253285 fmt2 .Dump ("miniprogram config:" , miniProgramApp .GetConfig ().All ())
254286
255- // init miniProgram app
287+ // init openplatform app
256288 configOpenPlatform := GetOpenPlatformConfig ()
257289 openPlatform , err := openPlatform .NewOpenPlatform (configOpenPlatform )
258290 if err != nil {
259291 fmt .Println (err .Error ())
260292 }
261293 fmt2 .Dump ("openPlatform config:" , openPlatform .GetConfig ().All ())
294+
295+ // init openwork app
296+ configOpenWork := GetOpenWorkConfig ()
297+ openWork , err := openWork .NewOpenWork (configOpenWork )
298+ if err != nil {
299+ fmt .Println (err .Error ())
300+ }
301+ fmt2 .Dump ("openPlatform config:" , openWork .GetConfig ().All ())
302+
262303}
0 commit comments