123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package WorkPhone
- import (
- "context"
- "fmt"
- "github.com/imroc/req/v3"
- "time"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type QwRefreshLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewQwRefreshLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QwRefreshLogic {
- return &QwRefreshLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *QwRefreshLogic) QwRefresh() (resp *types.BaseMsgResp, err error) {
- var result types.WorkPhoneGetWeChatsResp
- client := req.C().DevMode()
- client.SetCommonRetryCount(2).
- SetCommonRetryBackoffInterval(1*time.Second, 5*time.Second).
- SetCommonRetryFixedInterval(2 * time.Second).SetTimeout(30 * time.Second)
- res, err := client.R().SetSuccessResult(&result).Post("http://wecom.gkscrm.com:15086/pc/GetWeChatsReq?id=19")
- if err != nil {
- return nil, err
- }
- if !res.IsSuccessState() {
- err = fmt.Errorf("GetWeChats failed with status code %d", res.StatusCode)
- return nil, err
- }
- return resp, nil
- }
|