Browse Source

增加sendNotice函数

master v0.1.4
lijianbin 3 years ago
parent
commit
cde3148781
1 changed files with 64 additions and 0 deletions
  1. +64
    -0
      client.go

+ 64
- 0
client.go View File

@ -2,6 +2,7 @@ package msgrpc
import (
"encoding/json"
"errors"
"log"
"strconv"
"time"
@ -69,3 +70,66 @@ func SendMsg(site_id, dbname, business_id, domainname, msg_type, order_sn, memo
return &res_arr, nil
}
func SendNotcie(site_id, dbname, manager_id string, template_Data map[string]string, url ...string) (bool, error) {
if dbname == "" || dbname == "" || manager_id == ""{
return false, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return false, err
}
defer conn.Close()
arg := NoticeSend{}
arg.SiteId = site_id
arg.Dbname = dbname
arg.ManagerId = manager_id
arg.TemplateData = template_Data
data_json, err := json.Marshal(arg)
if err != nil {
return false, err
}
now_int64 := time.Now().Unix()
encryData := crypter.DesEn(string(data_json), DES_KEY)
now := strconv.FormatInt(now_int64, 10)
sign := Sign(encryData, now)
req := &Request{proto.String(encryData), proto.String(now), proto.String(sign), nil}
res := &Response{}
err = conn.SendNotcie(req, res)
if err != nil {
log.Println("msgrpc SendNotcie error:", err)
return false, err
}
res_data, err := GetOrgData(res)
if err != nil {
return false, err
}
if res_data == "" {
return false, nil
}
var notice_res bool
err = json.Unmarshal([]byte(res_data), &notice_res)
if err != nil {
return false, err
}
return notice_res, nil
}

Loading…
Cancel
Save