You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
package dao |
|
|
|
import ( |
|
"context" |
|
"net/url" |
|
"strconv" |
|
|
|
"go-common/library/ecode" |
|
"go-common/library/log" |
|
) |
|
|
|
var _notify = "4" |
|
|
|
// SendMessage . |
|
func (d *Dao) SendMessage(c context.Context, tid, mid, aid int64, title, msg string) (err error) { |
|
params := url.Values{} |
|
params.Set("mid_list", strconv.FormatInt(mid, 10)) |
|
params.Set("title", title) |
|
params.Set("mc", d.c.Message.MC) |
|
params.Set("data_type", _notify) |
|
params.Set("context", msg) |
|
params.Set("notify_type", strconv.FormatInt(tid, 10)) |
|
params.Set("res_id", strconv.FormatInt(aid, 10)) |
|
var res struct { |
|
Code int `json:"code"` |
|
} |
|
err = d.messageHTTPClient.Post(c, d.c.Message.URL, "", params, &res) |
|
if err != nil { |
|
PromError("message:send接口") |
|
log.Error("d.client.Post(%s) error(%+v)", d.c.Message.URL+"?"+params.Encode(), err) |
|
return |
|
} |
|
if res.Code != 0 { |
|
PromError("message:send接口") |
|
log.Error("url(%s) res code(%d)", d.c.Message.URL+"?"+params.Encode(), res.Code) |
|
err = ecode.Int(res.Code) |
|
return |
|
} |
|
log.Info("发送点赞消息通知 (%s) error(%+v)", d.c.Message.URL+"?"+params.Encode(), err) |
|
return |
|
}
|
|
|