46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package uinapp
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/globals"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
type SendMsgRes struct {
|
|
Code int64 `json:"code"`
|
|
Msg string `json:"msg"`
|
|
Data struct {
|
|
TaskId struct {
|
|
Cid string `json:"cid"`
|
|
}
|
|
} `json:"data"`
|
|
}
|
|
|
|
func (a *API) SendMsgByUinApp(parma map[string]interface{}) error {
|
|
if _, err := a.CheckTokenIsExpire(); err != nil {
|
|
return err
|
|
}
|
|
|
|
data, _ := json.Marshal(parma)
|
|
fmt.Println(string(data))
|
|
result, err := a.AccessAPI(BaseUrl+a.appId, PushMsgByCid, http.MethodPost, parma)
|
|
globals.SugarLogger.Debugf("SendMsgByUinApp result=%s", utils.Format4Output(result, false))
|
|
if err != nil && !strings.Contains(err.Error(), "success") {
|
|
return err
|
|
}
|
|
|
|
var sendMsgRes *SendMsgRes
|
|
if err := utils.Map2StructByJson(result, &sendMsgRes, false); err != nil {
|
|
return err
|
|
}
|
|
globals.SugarLogger.Debugf("SendMsgByUinApp sendMsgRes=%s", utils.Format4Output(sendMsgRes, false))
|
|
if sendMsgRes.Code != 0 {
|
|
return errors.New(sendMsgRes.Msg)
|
|
}
|
|
return nil
|
|
}
|