Compare commits
13 Commits
Author | SHA1 | Date |
---|---|---|
|
ca173e57c6 | |
|
a8520b547a | |
|
5b12078be4 | |
|
9bd21cf288 | |
|
761b8371d8 | |
|
f0afe45aad | |
|
877a9e10d3 | |
|
84ae733098 | |
|
cc5b1464a4 | |
|
5c982fb266 | |
|
89c9eeb4c4 | |
|
a96aa0e640 | |
|
ca74ab6f86 |
185
config.go
185
config.go
|
@ -2,84 +2,78 @@ package l_msg_api
|
||||||
|
|
||||||
// 业务系统和模板配置
|
// 业务系统和模板配置
|
||||||
type (
|
type (
|
||||||
Base struct {
|
base struct {
|
||||||
ServerIndex string `json:"server_index"` // 业务系统
|
ServerIndex string `json:"server_index"` // 业务系统
|
||||||
TempIndex string `json:"temp_index"` // 配置模板
|
TempIndex string `json:"temp_index"` // 配置模板
|
||||||
}
|
}
|
||||||
|
|
||||||
accessTokenResponse struct {
|
responseBody struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
Data struct {
|
Data interface{} `json:"data"`
|
||||||
AccessToken string `json:"accessToken"` // 授权token
|
|
||||||
AccessExpire int `json:"accessExpire"` // 过期时间
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OACreatePurchaseResponse struct {
|
accessTokenResponse struct {
|
||||||
Code int `json:"code"`
|
AccessToken string `json:"accessToken"` // 授权token
|
||||||
Msg string `json:"msg"`
|
AccessExpire int `json:"accessExpire"` // 过期时间
|
||||||
Data struct {
|
}
|
||||||
|
|
||||||
|
OAResponse struct {
|
||||||
IsSuccess bool `json:"is_success"` // 是否成功 true 成功 false 失败
|
IsSuccess bool `json:"is_success"` // 是否成功 true 成功 false 失败
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
InstanceId string `json:"instance_id"` // 审批实例id
|
InstanceId string `json:"instance_id"` // 审批实例id
|
||||||
} `json:"data"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 封装上游采购审批表单数据
|
// 封装上游采购审批表单数据
|
||||||
formDataRequest struct {
|
formDataRequest struct {
|
||||||
Base Base `json:"base"`
|
Base base `json:"base"`
|
||||||
formsData
|
FormsData
|
||||||
}
|
}
|
||||||
formsData struct {
|
|
||||||
FormBase
|
FormsData struct {
|
||||||
FormComponentValues []formComponentValues `json:"form_component_values"` // 审批表单数据
|
formBase
|
||||||
|
FormComponentValues []FormComponentValues `json:"form_component_values"` // 审批表单数据
|
||||||
|
Finance *Finance `json:"finance"` // 财务模块调用
|
||||||
}
|
}
|
||||||
formComponentValues struct { // 审批表单数据
|
|
||||||
|
FormComponentValues struct { // 审批表单数据
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
ComponentType string `json:"component_type,omitempty"`
|
ComponentType string `json:"component_type,omitempty"`
|
||||||
ExtValue string `json:"extValue,omitempty"`
|
ExtValue string `json:"extValue,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Finance struct {
|
||||||
|
CheckUserId string `json:"checkUserId"` //审核人
|
||||||
|
Sync int64 `json:"sync"` //是否是异步,如果为异步,付款申请和业务申请是同时进行
|
||||||
|
Amount string `json:"amount"` //金额
|
||||||
|
GoodsInfo string `json:"goodsInfo"` //商品信息
|
||||||
|
PaymentAccount string `json:"paymentAccount"` //付款方账户
|
||||||
|
TaxAmount string `json:"taxAmount"` //税率
|
||||||
|
CallbackUrl string `json:"callbackUrl"` //回调地址
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
Purpose string `json:"purpose"`
|
||||||
|
SystemName string `json:"systemName"` //业务系统名称
|
||||||
|
SubjectName string `json:"subjectName"` //户名
|
||||||
|
BankInfo BankInfo `json:"bankInfo"`
|
||||||
|
}
|
||||||
|
BankInfo struct {
|
||||||
|
ResellerName string `json:"resellerName"` //供应商名称
|
||||||
|
BankName string `json:"bankName"` //银行名称
|
||||||
|
AccountBankName string `json:"accountBankName"` //开户行名称
|
||||||
|
SubjectName string `json:"subjectName"` //户名
|
||||||
|
BankAccount string `json:"bankAccount"` //银行卡号
|
||||||
|
}
|
||||||
|
|
||||||
// 创建OA基础数据
|
// 创建OA基础数据
|
||||||
FormBase struct {
|
formBase struct {
|
||||||
OutTradeNo string `json:"out_trade_no"` // 流水号
|
OutTradeNo string `json:"out_trade_no"` // 流水号
|
||||||
OriginatorUserId string `json:"originator_user_id"` // 钉钉申请人id
|
OriginatorUserId string `json:"originator_user_id"` // 钉钉申请人id
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建采购审批表单数据
|
|
||||||
CreatePurchaseForm struct {
|
|
||||||
FormBase
|
|
||||||
PurchaseNum string // 采购单号
|
|
||||||
SupplierName string //供应商名称
|
|
||||||
TotalCount string //采购总数量
|
|
||||||
TotalAmount string //采购总金额
|
|
||||||
WarehouseName string //入库仓库
|
|
||||||
ExpectArrivalTime string //预计到货时间
|
|
||||||
|
|
||||||
Remark string //采购备注
|
|
||||||
PurchaseType string //采购类型
|
|
||||||
PayType string //支付类型
|
|
||||||
TotalAmountUpperCase string //总金额大写
|
|
||||||
SupplierSettlementBank string //结算账户开户行
|
|
||||||
SupplierSettlementAccount string //结算账户
|
|
||||||
|
|
||||||
PurchaseInGoodsList []PurchaseInGoods
|
|
||||||
}
|
|
||||||
|
|
||||||
// 采购单商品列表
|
|
||||||
PurchaseInGoods struct {
|
|
||||||
GoodsCode string `json:"goods_code"` // 商品编码
|
|
||||||
GoodsName string `json:"goods_name"` // 商品名称
|
|
||||||
Count string `json:"count"` // 数量
|
|
||||||
Price string `json:"price"` // 单价
|
|
||||||
Total string `json:"total"` // 总价
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取审批实列详情 请求数据
|
// 获取审批实列详情 请求数据
|
||||||
oAGetDetailRequest struct {
|
oAGetDetailRequest struct {
|
||||||
Base Base `json:"base"`
|
Base base `json:"base"`
|
||||||
OutTradeNo string `json:"out_trade_no"` // 流水号
|
OutTradeNo string `json:"out_trade_no"` // 流水号
|
||||||
ProcessInstanceId string `json:"process_instance_id"` // 审批实例id
|
ProcessInstanceId string `json:"process_instance_id"` // 审批实例id
|
||||||
}
|
}
|
||||||
|
@ -95,93 +89,56 @@ type (
|
||||||
CreateTime string `json:"createTime"` // 审批创建时间
|
CreateTime string `json:"createTime"` // 审批创建时间
|
||||||
UpdateTime string `json:"updateTime"` // 审批更新时间
|
UpdateTime string `json:"updateTime"` // 审批更新时间
|
||||||
}
|
}
|
||||||
OAGetDetailResponse struct {
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data OAGetDetailData `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建客户充值审批表单数据
|
smsRequest struct {
|
||||||
CreateCustomerRechargeForm struct {
|
Base base `json:"base"`
|
||||||
FormBase
|
|
||||||
Initiator string //发起人
|
|
||||||
CustomerName string //客户名称
|
|
||||||
RecipientAccountName string //收款账户名称
|
|
||||||
RechargeType string //充值类型
|
|
||||||
RechargeAmount string //充值金额
|
|
||||||
Voucher string //充值凭证
|
|
||||||
Remark string //备注
|
|
||||||
CreatedAt string //创建时间
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建供应商充值审批表单数据
|
|
||||||
CreateSupplierRechargeForm struct {
|
|
||||||
FormBase
|
|
||||||
Initiator string //发起人
|
|
||||||
SupplierName string //供应商名称
|
|
||||||
RecipientAccountName string //收款账户名称
|
|
||||||
RechargeType string //充值类型
|
|
||||||
RechargeAmount string //充值金额
|
|
||||||
Voucher string //充值凭证
|
|
||||||
Remark string //备注
|
|
||||||
CreatedAt string //创建时间
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
OaNotifyData 回调通知数据
|
|
||||||
Method: POST
|
|
||||||
{"content-type": "application/json; charset=utf-8"},
|
|
||||||
*/
|
|
||||||
OaNotifyData struct {
|
|
||||||
OutTradeNo string `json:"out_trade_no"` // 下游流水号
|
|
||||||
ProcessInstanceId string `json:"process_instance_id"` // 创建审批任务返回的 审批实例id
|
|
||||||
Title string `json:"title"` // 实例标题
|
|
||||||
StaffId string `json:"staff_id"` // 当前任务的审批人userId,操作转交动作的用户userId
|
|
||||||
Result int32 `json:"result"` // 审批结果,(1:同意,2:拒绝)
|
|
||||||
Type string `json:"type"` // 任务状态变更类型,start:审批任务开始,finish:审批任务正常结束(完成或转交),comment:审批任务评论,cancel:说明当前节点有多个审批人并且是或签,其中一个人执行了审批,其他审批人会推送cancel类型事件
|
|
||||||
Remark string `json:"remark"` // 操作时写的评论内容
|
|
||||||
CreatedAt string `json:"created_at"` // 创建时间
|
|
||||||
UpdatedAt string `json:"updated_at"` // 结束时间
|
|
||||||
}
|
|
||||||
|
|
||||||
SmsRequest struct {
|
|
||||||
Base Base `json:"base"`
|
|
||||||
Param string `json:"param"` // 短信模板变量对应的实际值
|
Param string `json:"param"` // 短信模板变量对应的实际值
|
||||||
Tels string `json:"tels"`
|
Tels string `json:"tels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
SmsSendRes struct {
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data SmsSend `json:"data"`
|
|
||||||
}
|
|
||||||
SmsSend struct {
|
SmsSend struct {
|
||||||
SendList []SmsSendResView `json:"send_list"`
|
SendList []smsSendResView `json:"send_list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
SmsSendResView struct {
|
smsSendResView struct {
|
||||||
Tel string `json:"tel"`
|
Tel string `json:"tel"`
|
||||||
IsSuccess uint32 `json:"is_success"`
|
IsSuccess uint32 `json:"is_success"`
|
||||||
}
|
}
|
||||||
|
|
||||||
DingTalkBlackBoardSendReq struct {
|
dingTalkBlackBoardSendReq struct {
|
||||||
Base Base `json:"base"`
|
Base base `json:"base"`
|
||||||
BlackboardReceiver BlackboardReceiverView `json:"blackboard_receiver"` //公告接收人。
|
BlackboardReceiver blackboardReceiverView `json:"blackboard_receiver"` //公告接收人。
|
||||||
Title string `json:"title,default=公告"` //公告标题
|
Title string `json:"title,default=公告"` //公告标题
|
||||||
Content string `json:"content,default=大家好"` //公告内容
|
Content string `json:"content,default=大家好"` //公告内容
|
||||||
}
|
}
|
||||||
BlackboardReceiverView struct {
|
blackboardReceiverView struct {
|
||||||
DeptidList []int `json:"deptid_list"` //接收部门ID列表,最大的列表长度为20。
|
DeptidList []int `json:"deptid_list"` //接收部门ID列表,最大的列表长度为20。
|
||||||
UseridList []string `json:"userid_list"` //接收部用户ID列表,最大的列表长度为20。
|
UseridList []string `json:"userid_list"` //接收部用户ID列表,最大的列表长度为20。
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultRes struct {
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data Default `json:"data"`
|
|
||||||
}
|
|
||||||
Default struct {
|
Default struct {
|
||||||
IsSuccess bool `json:"is_success,default=false"`
|
IsSuccess bool `json:"is_success,default=false"`
|
||||||
Msg string `json:"msg,default=ok"`
|
Msg string `json:"msg,default=ok"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oACommentRequest struct {
|
||||||
|
Base base `json:"base"`
|
||||||
|
OutTradeNo string `json:"out_trade_no"` // 流水号
|
||||||
|
Text string `json:"text"` //评论的内容
|
||||||
|
CommentUserId string `json:"commentUserId,optional"` //评论的内容
|
||||||
|
File DingOACommentReqFile `json:"file,optional"` //文件
|
||||||
|
}
|
||||||
|
|
||||||
|
DingOACommentReqFile struct {
|
||||||
|
Photos []string `json:"photos,optional"` //图片URL地址
|
||||||
|
Attachments []DingOACommentReqFileAttachments `json:"attachments,optional"` //图片URL地址
|
||||||
|
}
|
||||||
|
|
||||||
|
DingOACommentReqFileAttachments struct {
|
||||||
|
SpaceId string `json:"spaceId,optional"` //钉盘空间ID。
|
||||||
|
FileSize string `json:"fileSize,optional"` //文件大小。
|
||||||
|
FileId string `json:"fileId,optional"` //文件ID。
|
||||||
|
FileName string `json:"fileName,optional"` //文件名称。
|
||||||
|
FileType string `json:"fileType,optional"` //文件类型。
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
46
const.go
46
const.go
|
@ -1,8 +1,10 @@
|
||||||
package l_msg_api
|
package l_msg_api
|
||||||
|
|
||||||
|
import "gitea.cdlsxd.cn/self-tools/l_msg_api/protoc/msg"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ServerHost = "http://121.199.38.107:8000"
|
serverHost = "http://127.0.0.1:8001"
|
||||||
TimeOut = 60
|
timeOut = 60
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -13,9 +15,41 @@ const (
|
||||||
DDDateField = "DDDateField"
|
DDDateField = "DDDateField"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type requestPathIndex int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PathAccessToken = "/oauth/v1/accesstoken"
|
accessToken requestPathIndex = iota + 1
|
||||||
PathOaCreat = "/msg/v1/dingtalk/oa/create"
|
oaCreat
|
||||||
PathOaGet = "/msg/v1/dingtalk/oa/create"
|
oaGet
|
||||||
SendSms = "/msg/v1//sms/send"
|
oaComment
|
||||||
|
sendSms
|
||||||
|
sendSmsHs
|
||||||
|
)
|
||||||
|
|
||||||
|
var requestPath = map[requestPathIndex]map[RequestWay]string{
|
||||||
|
accessToken: {Http: "/oauth/v1/accesstoken", Rpc: msg.Msg_Oauth_FullMethodName},
|
||||||
|
oaCreat: {Http: "/msg/v1/dingtalk/oa/create", Rpc: msg.Msg_DingOACreate_FullMethodName},
|
||||||
|
oaGet: {Http: "/msg/v1/dingtalk/oa/get", Rpc: msg.Msg_DingOAGet_FullMethodName},
|
||||||
|
oaComment: {Http: "/msg/v1/dingtalk/oa/comment", Rpc: msg.Msg_DingOAComment_FullMethodName},
|
||||||
|
sendSms: {Http: "/msg/v1/sms/send", Rpc: msg.Msg_SmsSend_FullMethodName},
|
||||||
|
sendSmsHs: {Http: "/msg/v1/sms/send/hs", Rpc: msg.Msg_HsSmsSend_FullMethodName},
|
||||||
|
}
|
||||||
|
|
||||||
|
type SmsBusiness string
|
||||||
|
|
||||||
|
const (
|
||||||
|
SmsBusinessHs SmsBusiness = "hs"
|
||||||
|
SmsBusinessDefault SmsBusiness = "aliyun"
|
||||||
|
)
|
||||||
|
|
||||||
|
var smsBusinessWithRequestPath = map[SmsBusiness]requestPathIndex{
|
||||||
|
SmsBusinessHs: sendSms,
|
||||||
|
SmsBusinessDefault: sendSmsHs,
|
||||||
|
}
|
||||||
|
|
||||||
|
type RequestWay int8
|
||||||
|
|
||||||
|
const (
|
||||||
|
Http RequestWay = iota + 1
|
||||||
|
Rpc
|
||||||
)
|
)
|
||||||
|
|
15
go.mod
15
go.mod
|
@ -1,8 +1,19 @@
|
||||||
module gitea.cdlsxd.cn/self-tools/l_msg_api
|
module gitea.cdlsxd.cn/self-tools/l_msg_api
|
||||||
|
|
||||||
go 1.23.6
|
go 1.22.2
|
||||||
|
|
||||||
require github.com/valyala/fasthttp v1.59.0
|
require (
|
||||||
|
github.com/valyala/fasthttp v1.59.0
|
||||||
|
google.golang.org/grpc v1.71.1
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
golang.org/x/net v0.35.0 // indirect
|
||||||
|
golang.org/x/sys v0.30.0 // indirect
|
||||||
|
golang.org/x/text v0.22.0 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
|
||||||
|
google.golang.org/protobuf v1.36.4 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||||
|
|
|
@ -7,14 +7,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func FastHttpPost(url string, header map[string]string, body []byte, timeout int) ([]byte, error) {
|
func FastHttpPost(url string, header map[string]string, body []byte, timeout int) ([]byte, error) {
|
||||||
|
|
||||||
req := fasthttp.AcquireRequest()
|
req := fasthttp.AcquireRequest()
|
||||||
defer fasthttp.ReleaseRequest(req) // 用完需要释放资源
|
defer fasthttp.ReleaseRequest(req) // 用完需要释放资源
|
||||||
// 默认是application/x-www-form-urlencoded
|
|
||||||
req.Header.SetMethod("POST")
|
req.Header.SetMethod("POST")
|
||||||
for k, v := range header {
|
for k, v := range header {
|
||||||
req.Header.Set(k, v)
|
req.Header.Set(k, v)
|
||||||
}
|
}
|
||||||
req.SetRequestURI(url)
|
req.SetRequestURI(url)
|
||||||
|
req.SetTimeout(time.Duration(timeout) * time.Second)
|
||||||
req.SetBody(body)
|
req.SetBody(body)
|
||||||
resp := fasthttp.AcquireResponse()
|
resp := fasthttp.AcquireResponse()
|
||||||
defer fasthttp.ReleaseResponse(resp) // 用完需要释放资源
|
defer fasthttp.ReleaseResponse(resp) // 用完需要释放资源
|
||||||
|
@ -29,7 +31,6 @@ func FastHttpPost(url string, header map[string]string, body []byte, timeout int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b := resp.Body()
|
b := resp.Body()
|
||||||
//fmt.Println(string(b),"http请求")
|
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
170
msg.go
170
msg.go
|
@ -1,12 +1,9 @@
|
||||||
package l_msg_api
|
package l_msg_api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"gitea.cdlsxd.cn/self-tools/l_msg_api/cache"
|
|
||||||
"gitea.cdlsxd.cn/self-tools/l_msg_api/httpclient"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MessageCenter struct {
|
type MessageCenter struct {
|
||||||
|
@ -14,139 +11,118 @@ type MessageCenter struct {
|
||||||
ClientKey string // 客户端id,获取授权token需要
|
ClientKey string // 客户端id,获取授权token需要
|
||||||
ClientSecret string
|
ClientSecret string
|
||||||
header map[string]string
|
header map[string]string
|
||||||
Base
|
option *mesOptionData
|
||||||
|
base
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMessageCenter(clientKey, clientSecret, serverIndex, tempIndex string) (*MessageCenter, error) {
|
func NewMessageCenter(host, clientKey, clientSecret, serverIndex, tempIndex string, args ...MesOption) (*MessageCenter, error) {
|
||||||
msg := &MessageCenter{
|
msg := &MessageCenter{
|
||||||
Host: ServerHost,
|
Host: host,
|
||||||
ClientKey: clientKey,
|
ClientKey: clientKey,
|
||||||
ClientSecret: clientSecret,
|
ClientSecret: clientSecret,
|
||||||
Base: Base{
|
base: base{
|
||||||
ServerIndex: serverIndex,
|
ServerIndex: serverIndex,
|
||||||
TempIndex: tempIndex,
|
TempIndex: tempIndex,
|
||||||
},
|
},
|
||||||
|
option: new(mesOptionData),
|
||||||
|
}
|
||||||
|
err := msg.setHeader()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, arg := range args {
|
||||||
|
arg(msg.option)
|
||||||
}
|
}
|
||||||
accessToken, err := msg.getAccessToken()
|
|
||||||
msg.header = map[string]string{"Authorization": accessToken, "content-type": "application/json; charset=utf-8"}
|
|
||||||
return msg, err
|
return msg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// OACreate 发起OA审批
|
||||||
获取授权token
|
func (m *MessageCenter) OACreate(ctx context.Context, dTalkUserId, treadNo string, formModel *FormsData) (data OAResponse, err error) {
|
||||||
AccessExpire 有效期内可缓存起来使用
|
formModel.formBase = formBase{
|
||||||
*/
|
|
||||||
func (m *MessageCenter) getAccessToken() (string, error) {
|
|
||||||
if tokenInterface, exist := cache.InstanceCacheMap().Get(m.ClientKey); exist {
|
|
||||||
return tokenInterface.(string), nil
|
|
||||||
}
|
|
||||||
var data accessTokenResponse
|
|
||||||
url := fmt.Sprintf("%s%s", m.Host, PathAccessToken)
|
|
||||||
var authParam, _ = json.Marshal(map[string]string{"client_key": m.ClientKey, "client_secret": m.ClientSecret})
|
|
||||||
res, err := httpclient.FastHttpPost(url, map[string]string{"content-type": "application/json; charset=utf-8"}, authParam, TimeOut)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
err = json.Unmarshal(res, &data)
|
|
||||||
if data.Code != 0 {
|
|
||||||
return "", errors.New(data.Msg)
|
|
||||||
}
|
|
||||||
cache.InstanceCacheMap().Put(m.ClientKey, data.Data.AccessToken)
|
|
||||||
return data.Data.AccessToken, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// 采购单OA审批
|
|
||||||
func (m *MessageCenter) OACreate(dTalkUserId, treadNo string, checkForm []formComponentValues) (data OACreatePurchaseResponse, err error) {
|
|
||||||
res, err := httpclient.FastHttpPost(
|
|
||||||
fmt.Sprintf("%s%s", m.Host, PathOaCreat),
|
|
||||||
m.header,
|
|
||||||
m.parseOACreateParam(dTalkUserId, treadNo, checkForm),
|
|
||||||
TimeOut)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = json.Unmarshal(res, &data)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MessageCenter) parseOACreateParam(dTalkUserId, treadNo string, checkForm []formComponentValues) (out []byte) {
|
|
||||||
req := formDataRequest{
|
|
||||||
Base: m.Base,
|
|
||||||
}
|
|
||||||
req.FormBase = FormBase{
|
|
||||||
OutTradeNo: treadNo,
|
OutTradeNo: treadNo,
|
||||||
OriginatorUserId: dTalkUserId,
|
OriginatorUserId: dTalkUserId,
|
||||||
}
|
}
|
||||||
req.FormComponentValues = checkForm
|
err = m.send(ctx, oaCreat, m.parseOACreateParam(formModel), &data)
|
||||||
out, _ = json.Marshal(req)
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageCenter) OAGetDetail(outTradeNo string) (data OAGetDetailData, err error) {
|
// OAGetDetail OA详情
|
||||||
|
func (m *MessageCenter) OAGetDetail(ctx context.Context, outTradeNo string) (data OAGetDetailData, err error) {
|
||||||
param, _ := json.Marshal(oAGetDetailRequest{
|
param, _ := json.Marshal(oAGetDetailRequest{
|
||||||
Base: m.Base,
|
Base: m.base,
|
||||||
OutTradeNo: outTradeNo,
|
OutTradeNo: outTradeNo,
|
||||||
})
|
})
|
||||||
res, err := httpclient.FastHttpPost(fmt.Sprintf("%s%s", m.Host, PathOaGet), m.header, param, TimeOut)
|
err = m.send(ctx, oaGet, param, &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 解析响应参数
|
|
||||||
body := OAGetDetailResponse{}
|
|
||||||
err = json.Unmarshal(res, &body)
|
|
||||||
if err != nil {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if body.Code != 0 {
|
|
||||||
err = errors.New(body.Msg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return body.Data, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 采购单OA审批
|
// SendSms 短信
|
||||||
func (m *MessageCenter) SendSms(tels []string, jsonParam string) (data SmsSendRes, err error) {
|
// business SmsBusiness
|
||||||
|
func (m *MessageCenter) SendSms(ctx context.Context, tels []string, jsonParam string, args ...SmsOption) (data SmsSend, err error) {
|
||||||
|
var (
|
||||||
|
e = new(smsOptionData)
|
||||||
|
)
|
||||||
|
if len(tels) == 0 {
|
||||||
|
err = errors.New("手机号不能为空")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, arg := range args {
|
||||||
|
arg(e)
|
||||||
|
}
|
||||||
|
if e.Business != "" {
|
||||||
|
if _, ex := smsBusinessWithRequestPath[e.Business]; !ex {
|
||||||
|
err = errors.New("business参数错误")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
e.Business = SmsBusinessDefault
|
||||||
|
}
|
||||||
|
path := smsBusinessWithRequestPath[e.Business]
|
||||||
|
|
||||||
param := m.parseSmsSendParam(tels, jsonParam)
|
param := m.parseSmsSendParam(tels, jsonParam)
|
||||||
res, err := httpclient.FastHttpPost(
|
err = m.send(ctx, path, param, &data)
|
||||||
fmt.Sprintf("%s%s", m.Host, SendSms),
|
|
||||||
m.header,
|
|
||||||
param,
|
|
||||||
TimeOut)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(res, &data)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageCenter) parseSmsSendParam(tels []string, jsonParam string) (out []byte) {
|
// SendBlackBoard 钉钉公告
|
||||||
out, _ = json.Marshal(SmsRequest{
|
// deptidList //接收部门ID列表,最大的列表长度为20。
|
||||||
Base: m.Base,
|
// UseridList //接收部用户ID列表,最大的列表长度为20。
|
||||||
Tels: strings.Join(tels, ","),
|
func (m *MessageCenter) SendBlackBoard(ctx context.Context, title, content string, deptidList []int, useridList []string) (data Default, err error) {
|
||||||
Param: jsonParam,
|
receiver := blackboardReceiverView{
|
||||||
})
|
deptidList, useridList,
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
err = m.send(ctx, sendSms, m.parseSendBlackBoardParam(title, content, receiver), &data)
|
||||||
func (m *MessageCenter) SendBlackBoard(title, content string, receiver BlackboardReceiverView) (data DefaultRes, err error) {
|
|
||||||
res, err := httpclient.FastHttpPost(
|
|
||||||
fmt.Sprintf("%s%s", m.Host, SendSms),
|
|
||||||
m.header,
|
|
||||||
m.parseSendBlackBoardParam(title, content, receiver),
|
|
||||||
TimeOut)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(res, &data)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageCenter) parseSendBlackBoardParam(title, content string, receiver BlackboardReceiverView) (out []byte) {
|
// OAComment OA评论,CommentUserId为空则默认审核发起人评论
|
||||||
out, _ = json.Marshal(DingTalkBlackBoardSendReq{
|
func (m *MessageCenter) OAComment(ctx context.Context, outTradeNo, text, commentUserId string, file *DingOACommentReqFile) (data OAResponse, err error) {
|
||||||
Base: m.Base,
|
req := &oACommentRequest{
|
||||||
Content: content,
|
Base: m.base,
|
||||||
Title: title,
|
OutTradeNo: outTradeNo,
|
||||||
BlackboardReceiver: receiver,
|
Text: text,
|
||||||
})
|
CommentUserId: commentUserId,
|
||||||
|
}
|
||||||
|
if file != nil {
|
||||||
|
req.File = *file
|
||||||
|
}
|
||||||
|
param, _ := json.Marshal(req)
|
||||||
|
|
||||||
|
err = m.send(ctx, oaComment, param, &data)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package l_msg_api
|
||||||
|
|
||||||
|
type (
|
||||||
|
SmsOption func(*smsOptionData)
|
||||||
|
smsOptionData struct {
|
||||||
|
Business SmsBusiness
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func WithBusiness(business SmsBusiness) SmsOption {
|
||||||
|
|
||||||
|
return func(OptionData *smsOptionData) {
|
||||||
|
OptionData.Business = business
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
MesOption func(*mesOptionData)
|
||||||
|
mesOptionData struct {
|
||||||
|
RequestWay RequestWay
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func WithRequestWay(RequestWay RequestWay) MesOption {
|
||||||
|
return func(OptionData *mesOptionData) {
|
||||||
|
OptionData.RequestWay = RequestWay
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
package l_msg_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"gitea.cdlsxd.cn/self-tools/l_msg_api/cache"
|
||||||
|
"gitea.cdlsxd.cn/self-tools/l_msg_api/httpclient"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (m *MessageCenter) parseOACreateParam(formModel *FormsData) (out []byte) {
|
||||||
|
req := formDataRequest{
|
||||||
|
Base: m.base,
|
||||||
|
}
|
||||||
|
req.FormComponentValues = formModel.FormComponentValues
|
||||||
|
req.Finance = formModel.Finance
|
||||||
|
req.formBase = formModel.formBase
|
||||||
|
out, _ = json.Marshal(req)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MessageCenter) parseSmsSendParam(tels []string, jsonParam string) (out []byte) {
|
||||||
|
out, _ = json.Marshal(smsRequest{
|
||||||
|
Base: m.base,
|
||||||
|
Tels: strings.Join(tels, ","),
|
||||||
|
Param: jsonParam,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (m *MessageCenter) parseSendBlackBoardParam(title, content string, receiver blackboardReceiverView) (out []byte) {
|
||||||
|
out, _ = json.Marshal(dingTalkBlackBoardSendReq{
|
||||||
|
Base: m.base,
|
||||||
|
Content: content,
|
||||||
|
Title: title,
|
||||||
|
BlackboardReceiver: receiver,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MessageCenter) getAccessToken() (string, error) {
|
||||||
|
if tokenInterface, exist := cache.InstanceCacheMap().Get(m.ClientKey); exist {
|
||||||
|
return tokenInterface.(string), nil
|
||||||
|
}
|
||||||
|
var data accessTokenResponse
|
||||||
|
|
||||||
|
var authParam, _ = json.Marshal(map[string]string{"client_key": m.ClientKey, "client_secret": m.ClientSecret})
|
||||||
|
err := m.accessPost(accessToken, authParam, &data)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
cache.InstanceCacheMap().Put(m.ClientKey, data.AccessToken)
|
||||||
|
return data.AccessToken, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MessageCenter) send(ctx context.Context, path requestPathIndex, data []byte, resReflect interface{}) (err error) {
|
||||||
|
switch m.option.RequestWay {
|
||||||
|
case Rpc:
|
||||||
|
//return m.rpc(ctx, requestAddr, data, resReflect)
|
||||||
|
default:
|
||||||
|
requestAddr := requestPath[path][Http]
|
||||||
|
return m.post(ctx, requestAddr, data, resReflect)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//func (m *MessageCenter) rpc(ctx context.Context, path string, data []byte, resReflect interface{}) (err error) {
|
||||||
|
//
|
||||||
|
// client := protoc.InstanceMsgClient(m.Host)
|
||||||
|
// client.FinanceNotify(ctx, a)
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
|
||||||
|
func (m *MessageCenter) post(ctx context.Context, path string, data []byte, resReflect interface{}) (err error) {
|
||||||
|
var body responseBody
|
||||||
|
res, err := httpclient.FastHttpPost(fmt.Sprintf("%s%s", m.Host, path), m.header, data, timeOut)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(res, &body); err != nil {
|
||||||
|
return fmt.Errorf("请求失败:%s", string(res))
|
||||||
|
}
|
||||||
|
if body.Code != 0 {
|
||||||
|
return fmt.Errorf("请求失败:%s", body.Msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
dataByte, err := json.Marshal(body.Data)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("未知的返回格式:%s", string(dataByte))
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(dataByte, resReflect); err != nil {
|
||||||
|
return fmt.Errorf("未知的返回格式:%s", string(dataByte))
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MessageCenter) accessPost(path requestPathIndex, data []byte, resReflect interface{}) (err error) {
|
||||||
|
pathStr := requestPath[path][Http]
|
||||||
|
var body responseBody
|
||||||
|
res, err := httpclient.FastHttpPost(fmt.Sprintf("%s%s", m.Host, pathStr), m.header, data, timeOut)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(res, &body); err != nil {
|
||||||
|
return fmt.Errorf("请求失败:%s", string(res))
|
||||||
|
}
|
||||||
|
if body.Code != 0 {
|
||||||
|
return fmt.Errorf("请求失败:%s", body.Msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
dataByte, err := json.Marshal(body.Data)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("未知的返回格式:%s", string(dataByte))
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(dataByte, &resReflect); err != nil {
|
||||||
|
return fmt.Errorf("未知的返回格式:%s", string(dataByte))
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MessageCenter) setHeader() (err error) {
|
||||||
|
m.header = map[string]string{"content-type": "application/json; charset=utf-8"}
|
||||||
|
token, err := m.getAccessToken()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.header = map[string]string{"Authorization": token, "content-type": "application/json; charset=utf-8"}
|
||||||
|
return
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,274 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package msg;
|
||||||
|
option go_package = "/msg;msg";
|
||||||
|
|
||||||
|
|
||||||
|
message Empty{}
|
||||||
|
|
||||||
|
message BaseRes{
|
||||||
|
bool isSuccess = 1;
|
||||||
|
string Msg = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message MsgCenterResp{
|
||||||
|
oneof Resp{
|
||||||
|
SmsSendRes smsSendRes = 1;
|
||||||
|
HsSmsSendRes HsSmsSendRes = 2;
|
||||||
|
BaseRes baseRes = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message OauthReq {
|
||||||
|
string clientKey = 1;
|
||||||
|
string clientSecret = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message OauthResp {
|
||||||
|
string accessToken = 2;
|
||||||
|
int64 AccessExpire = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message CenterSendReq{
|
||||||
|
string severType = 1;
|
||||||
|
string msgType = 2;
|
||||||
|
BaseReq base = 3;
|
||||||
|
string config = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BaseReq{
|
||||||
|
string serverIndex = 1;
|
||||||
|
string tempIndex = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SmsSendReq{
|
||||||
|
BaseReq base = 1;
|
||||||
|
string param = 2;
|
||||||
|
string tels = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message SmsSendRes{
|
||||||
|
repeated SmsSendResItem sendList = 1;
|
||||||
|
message SmsSendResItem{
|
||||||
|
string tel = 1;
|
||||||
|
uint32 isSuccess = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message DingdingOASendReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
string originatorUserId = 2; //审批实例发起人的userId
|
||||||
|
FormComponentValuesView formComponentValues = 3;
|
||||||
|
message FormComponentValuesView {
|
||||||
|
string id = 1;
|
||||||
|
string bizAlias = 2;
|
||||||
|
string name = 3;
|
||||||
|
string value = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
message DingTalkBlackBoardSendReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
BlackboardReceiverView blackboardReceiver = 3;
|
||||||
|
message BlackboardReceiverView {
|
||||||
|
repeated int32 deptidList = 1;
|
||||||
|
repeated string useridList = 2;
|
||||||
|
}
|
||||||
|
string title = 4;
|
||||||
|
string content = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message wxBizSendReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
string page = 2;//跳转页面
|
||||||
|
string touser = 3; //用户open_id
|
||||||
|
string data = 4; //模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }的object
|
||||||
|
string miniprogram = 5; //跳转小程序时填写,格式如{ "appid": ,"pagepath": { "value": any } }
|
||||||
|
}
|
||||||
|
|
||||||
|
message callInfoReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
string calledNumber = 3; //接收语音通知的被叫号码
|
||||||
|
int32 playTimes = 4; //播放次数1->3
|
||||||
|
int32 volume = 5; //音量1->100
|
||||||
|
int32 speed = 6; //语速,-500->500
|
||||||
|
string outId = 8; //预留给调用方的 ID,最终会通过回执消息将此 ID 带回给调用方。
|
||||||
|
}
|
||||||
|
|
||||||
|
message callCaptchaReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
string calledNumber = 3; //接收语音通知的被叫号码
|
||||||
|
string ttsParam = 4; //{"AckNum":"123456"}
|
||||||
|
int32 playTimes = 5; //播放次数1->3
|
||||||
|
int32 volume = 6; //音量1->100
|
||||||
|
int32 speed = 7; //语速,-500->500
|
||||||
|
string outId = 8; //预留给调用方的 ID,最终会通过回执消息将此 ID 带回给调用方。
|
||||||
|
}
|
||||||
|
|
||||||
|
// DingTalk OA 审批创建
|
||||||
|
message DingOACreateReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
string outTradeNo = 2; //下游流水号
|
||||||
|
string originatorUserId = 3; //审批实例发起人的userId
|
||||||
|
|
||||||
|
repeated FormComponentValuesView formComponentValues = 5; //审批表单的参数
|
||||||
|
message FormComponentValuesView {
|
||||||
|
string name = 1; //表单参数的名称
|
||||||
|
string value = 2; //表单参数的值
|
||||||
|
string ComponentType = 3; //表单参数的类型
|
||||||
|
string extValue = 5; //表单扩展值
|
||||||
|
string Id = 4; //控件的id
|
||||||
|
}
|
||||||
|
Finance finance = 6; //财务组件
|
||||||
|
message Finance {
|
||||||
|
string checkUserId = 1; //审核人
|
||||||
|
int64 sync =2;//是否是异步,如果为异步,付款申请和业务申请是同时进行
|
||||||
|
string amount = 3; //金额
|
||||||
|
string systemName = 13; //业务系统名称
|
||||||
|
string goodsInfo = 4; //商品信息
|
||||||
|
string paymentAccount=5; //付款方账户
|
||||||
|
string taxAmount=6 ;//税率
|
||||||
|
string callbackUrl=7; //回调地址
|
||||||
|
string orderNo=8; //订单号
|
||||||
|
string remark=9; //备注
|
||||||
|
string purpose=12;//用途
|
||||||
|
string subjectName=11; //户名
|
||||||
|
BankInfo bankInfo=10;
|
||||||
|
message BankInfo {
|
||||||
|
string resellerName = 1; //供应商名称
|
||||||
|
string bankName = 2; //银行名称
|
||||||
|
string accountBankName = 3; //开户行名称
|
||||||
|
string subjectName = 4; //户名
|
||||||
|
string bankAccount = 5; //银行卡号
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message DingOACreateResp {
|
||||||
|
bool isSuccess = 1;
|
||||||
|
string Msg = 2;
|
||||||
|
string instanceId = 3; // 审批实例的id
|
||||||
|
}
|
||||||
|
|
||||||
|
// DingTalk OA 审批实例修改
|
||||||
|
message DingOAUpdateReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
string outTradeNo = 2; //下游流水号
|
||||||
|
repeated FormComponentValuesView formComponentValues = 5; //审批表单的参数
|
||||||
|
message FormComponentValuesView {
|
||||||
|
string name = 1; //表单参数的名称
|
||||||
|
string value = 2; //表单参数的值
|
||||||
|
string ComponentType = 3; //表单参数的类型
|
||||||
|
string extValue = 5; //表单扩展值
|
||||||
|
string Id = 4; //控件的id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message DingOAUpdateResp {
|
||||||
|
bool isSuccess = 1;
|
||||||
|
string Msg = 2;
|
||||||
|
string instanceId = 3; // 审批实例的id
|
||||||
|
}
|
||||||
|
|
||||||
|
// DingTalk OA 审批实例修改
|
||||||
|
message DingOACommentReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
string outTradeNo = 2; //下游流水号
|
||||||
|
string text = 3; //评论的内容
|
||||||
|
string commentUserId = 4; //评论的内容
|
||||||
|
File file = 5; //文件
|
||||||
|
message File{ //文件名
|
||||||
|
repeated string photos = 1; //图片URL地址
|
||||||
|
repeated Attachments attachments = 2; //图片URL地址
|
||||||
|
message Attachments{ //文件名
|
||||||
|
string spaceId =1; //钉盘空间ID。
|
||||||
|
string fileSize =2; //文件大小。
|
||||||
|
string fileId =3; //文件ID。
|
||||||
|
string fileName =4; //文件名称。
|
||||||
|
string fileType =5; //文件类型。
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message DingOACommentResp {
|
||||||
|
bool isSuccess = 1;
|
||||||
|
string Msg = 2;
|
||||||
|
string instanceId = 3; // 审批实例的id
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
message DingOAGetReq {
|
||||||
|
BaseReq base = 1;
|
||||||
|
string processInstanceId = 2; //审批实例的id
|
||||||
|
string outTradeNo = 3; //下游流水号
|
||||||
|
}
|
||||||
|
|
||||||
|
message DingOAGetResp {
|
||||||
|
string OutTradeNo = 1; //下游流水号
|
||||||
|
string processInstanceId = 2; //审批实例的id
|
||||||
|
string Title = 3; //审批实例的标题
|
||||||
|
int64 Result = 4; //审批结果 0 进行中 1:同意 2:拒绝
|
||||||
|
string Type = 5; //审批任务状态变更类型
|
||||||
|
string Remarks = 6; //审批备注
|
||||||
|
string CreateTime = 7; //审批任务创建时间
|
||||||
|
string UpdateTime = 8; //审批任务更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
message PaymentCallbackData {
|
||||||
|
string sign=1;
|
||||||
|
string instanceId=2;
|
||||||
|
string corpId=3;
|
||||||
|
string failReason =4;
|
||||||
|
string paymentTime=5; //付款时间
|
||||||
|
string userId=6;
|
||||||
|
string paymentStatus=7;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message PaymentCallbackRes {
|
||||||
|
bool isSuccess=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message HsSmsSendReq{
|
||||||
|
BaseReq base = 1;
|
||||||
|
string param = 2;
|
||||||
|
string tels = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message HsSmsSendRes{
|
||||||
|
repeated SmsSendResItem sendList = 1;
|
||||||
|
message SmsSendResItem{
|
||||||
|
string tel = 1;
|
||||||
|
uint32 isSuccess = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
service Msg {
|
||||||
|
rpc oauth(OauthReq) returns(OauthResp);
|
||||||
|
rpc centerSend(CenterSendReq) returns(MsgCenterResp);
|
||||||
|
rpc smsSend(SmsSendReq) returns(SmsSendRes);
|
||||||
|
rpc dingTalkBlackBoardSend(DingTalkBlackBoardSendReq) returns(BaseRes);
|
||||||
|
rpc wxBizSend(wxBizSendReq) returns(BaseRes);
|
||||||
|
rpc callInfo(callInfoReq) returns(BaseRes);
|
||||||
|
rpc callCaptcha(callCaptchaReq) returns(BaseRes);
|
||||||
|
rpc dingOACreate(DingOACreateReq) returns(DingOACreateResp);
|
||||||
|
rpc dingOAUpdate(DingOAUpdateReq) returns(DingOAUpdateResp);
|
||||||
|
rpc dingOAComment(DingOACommentReq) returns(DingOACommentResp);
|
||||||
|
rpc dingOAGet(DingOAGetReq) returns(DingOAGetResp);
|
||||||
|
rpc FinanceNotify(PaymentCallbackData) returns(PaymentCallbackRes);
|
||||||
|
rpc hsSmsSend(HsSmsSendReq) returns(HsSmsSendRes);
|
||||||
|
}
|
|
@ -0,0 +1,577 @@
|
||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-grpc v1.5.1
|
||||||
|
// - protoc v3.6.1
|
||||||
|
// source: msg/msg.proto
|
||||||
|
|
||||||
|
package msg
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.64.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
|
const (
|
||||||
|
Msg_Oauth_FullMethodName = "/msg.Msg/oauth"
|
||||||
|
Msg_CenterSend_FullMethodName = "/msg.Msg/centerSend"
|
||||||
|
Msg_SmsSend_FullMethodName = "/msg.Msg/smsSend"
|
||||||
|
Msg_DingTalkBlackBoardSend_FullMethodName = "/msg.Msg/dingTalkBlackBoardSend"
|
||||||
|
Msg_WxBizSend_FullMethodName = "/msg.Msg/wxBizSend"
|
||||||
|
Msg_CallInfo_FullMethodName = "/msg.Msg/callInfo"
|
||||||
|
Msg_CallCaptcha_FullMethodName = "/msg.Msg/callCaptcha"
|
||||||
|
Msg_DingOACreate_FullMethodName = "/msg.Msg/dingOACreate"
|
||||||
|
Msg_DingOAUpdate_FullMethodName = "/msg.Msg/dingOAUpdate"
|
||||||
|
Msg_DingOAComment_FullMethodName = "/msg.Msg/dingOAComment"
|
||||||
|
Msg_DingOAGet_FullMethodName = "/msg.Msg/dingOAGet"
|
||||||
|
Msg_FinanceNotify_FullMethodName = "/msg.Msg/FinanceNotify"
|
||||||
|
Msg_HsSmsSend_FullMethodName = "/msg.Msg/hsSmsSend"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MsgClient is the client API for Msg service.
|
||||||
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
|
type MsgClient interface {
|
||||||
|
Oauth(ctx context.Context, in *OauthReq, opts ...grpc.CallOption) (*OauthResp, error)
|
||||||
|
CenterSend(ctx context.Context, in *CenterSendReq, opts ...grpc.CallOption) (*MsgCenterResp, error)
|
||||||
|
SmsSend(ctx context.Context, in *SmsSendReq, opts ...grpc.CallOption) (*SmsSendRes, error)
|
||||||
|
DingTalkBlackBoardSend(ctx context.Context, in *DingTalkBlackBoardSendReq, opts ...grpc.CallOption) (*BaseRes, error)
|
||||||
|
WxBizSend(ctx context.Context, in *WxBizSendReq, opts ...grpc.CallOption) (*BaseRes, error)
|
||||||
|
CallInfo(ctx context.Context, in *CallInfoReq, opts ...grpc.CallOption) (*BaseRes, error)
|
||||||
|
CallCaptcha(ctx context.Context, in *CallCaptchaReq, opts ...grpc.CallOption) (*BaseRes, error)
|
||||||
|
DingOACreate(ctx context.Context, in *DingOACreateReq, opts ...grpc.CallOption) (*DingOACreateResp, error)
|
||||||
|
DingOAUpdate(ctx context.Context, in *DingOAUpdateReq, opts ...grpc.CallOption) (*DingOAUpdateResp, error)
|
||||||
|
DingOAComment(ctx context.Context, in *DingOACommentReq, opts ...grpc.CallOption) (*DingOACommentResp, error)
|
||||||
|
DingOAGet(ctx context.Context, in *DingOAGetReq, opts ...grpc.CallOption) (*DingOAGetResp, error)
|
||||||
|
FinanceNotify(ctx context.Context, in *PaymentCallbackData, opts ...grpc.CallOption) (*PaymentCallbackRes, error)
|
||||||
|
HsSmsSend(ctx context.Context, in *HsSmsSendReq, opts ...grpc.CallOption) (*HsSmsSendRes, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type msgClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMsgClient(cc grpc.ClientConnInterface) MsgClient {
|
||||||
|
return &msgClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) Oauth(ctx context.Context, in *OauthReq, opts ...grpc.CallOption) (*OauthResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(OauthResp)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_Oauth_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) CenterSend(ctx context.Context, in *CenterSendReq, opts ...grpc.CallOption) (*MsgCenterResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(MsgCenterResp)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_CenterSend_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) SmsSend(ctx context.Context, in *SmsSendReq, opts ...grpc.CallOption) (*SmsSendRes, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(SmsSendRes)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_SmsSend_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) DingTalkBlackBoardSend(ctx context.Context, in *DingTalkBlackBoardSendReq, opts ...grpc.CallOption) (*BaseRes, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(BaseRes)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_DingTalkBlackBoardSend_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) WxBizSend(ctx context.Context, in *WxBizSendReq, opts ...grpc.CallOption) (*BaseRes, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(BaseRes)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_WxBizSend_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) CallInfo(ctx context.Context, in *CallInfoReq, opts ...grpc.CallOption) (*BaseRes, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(BaseRes)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_CallInfo_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) CallCaptcha(ctx context.Context, in *CallCaptchaReq, opts ...grpc.CallOption) (*BaseRes, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(BaseRes)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_CallCaptcha_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) DingOACreate(ctx context.Context, in *DingOACreateReq, opts ...grpc.CallOption) (*DingOACreateResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(DingOACreateResp)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_DingOACreate_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) DingOAUpdate(ctx context.Context, in *DingOAUpdateReq, opts ...grpc.CallOption) (*DingOAUpdateResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(DingOAUpdateResp)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_DingOAUpdate_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) DingOAComment(ctx context.Context, in *DingOACommentReq, opts ...grpc.CallOption) (*DingOACommentResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(DingOACommentResp)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_DingOAComment_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) DingOAGet(ctx context.Context, in *DingOAGetReq, opts ...grpc.CallOption) (*DingOAGetResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(DingOAGetResp)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_DingOAGet_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) FinanceNotify(ctx context.Context, in *PaymentCallbackData, opts ...grpc.CallOption) (*PaymentCallbackRes, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(PaymentCallbackRes)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_FinanceNotify_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *msgClient) HsSmsSend(ctx context.Context, in *HsSmsSendReq, opts ...grpc.CallOption) (*HsSmsSendRes, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(HsSmsSendRes)
|
||||||
|
err := c.cc.Invoke(ctx, Msg_HsSmsSend_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgServer is the server API for Msg service.
|
||||||
|
// All implementations must embed UnimplementedMsgServer
|
||||||
|
// for forward compatibility.
|
||||||
|
type MsgServer interface {
|
||||||
|
Oauth(context.Context, *OauthReq) (*OauthResp, error)
|
||||||
|
CenterSend(context.Context, *CenterSendReq) (*MsgCenterResp, error)
|
||||||
|
SmsSend(context.Context, *SmsSendReq) (*SmsSendRes, error)
|
||||||
|
DingTalkBlackBoardSend(context.Context, *DingTalkBlackBoardSendReq) (*BaseRes, error)
|
||||||
|
WxBizSend(context.Context, *WxBizSendReq) (*BaseRes, error)
|
||||||
|
CallInfo(context.Context, *CallInfoReq) (*BaseRes, error)
|
||||||
|
CallCaptcha(context.Context, *CallCaptchaReq) (*BaseRes, error)
|
||||||
|
DingOACreate(context.Context, *DingOACreateReq) (*DingOACreateResp, error)
|
||||||
|
DingOAUpdate(context.Context, *DingOAUpdateReq) (*DingOAUpdateResp, error)
|
||||||
|
DingOAComment(context.Context, *DingOACommentReq) (*DingOACommentResp, error)
|
||||||
|
DingOAGet(context.Context, *DingOAGetReq) (*DingOAGetResp, error)
|
||||||
|
FinanceNotify(context.Context, *PaymentCallbackData) (*PaymentCallbackRes, error)
|
||||||
|
HsSmsSend(context.Context, *HsSmsSendReq) (*HsSmsSendRes, error)
|
||||||
|
mustEmbedUnimplementedMsgServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedMsgServer must be embedded to have
|
||||||
|
// forward compatible implementations.
|
||||||
|
//
|
||||||
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||||
|
// pointer dereference when methods are called.
|
||||||
|
type UnimplementedMsgServer struct{}
|
||||||
|
|
||||||
|
func (UnimplementedMsgServer) Oauth(context.Context, *OauthReq) (*OauthResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Oauth not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) CenterSend(context.Context, *CenterSendReq) (*MsgCenterResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CenterSend not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) SmsSend(context.Context, *SmsSendReq) (*SmsSendRes, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method SmsSend not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) DingTalkBlackBoardSend(context.Context, *DingTalkBlackBoardSendReq) (*BaseRes, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method DingTalkBlackBoardSend not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) WxBizSend(context.Context, *WxBizSendReq) (*BaseRes, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method WxBizSend not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) CallInfo(context.Context, *CallInfoReq) (*BaseRes, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CallInfo not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) CallCaptcha(context.Context, *CallCaptchaReq) (*BaseRes, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CallCaptcha not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) DingOACreate(context.Context, *DingOACreateReq) (*DingOACreateResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method DingOACreate not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) DingOAUpdate(context.Context, *DingOAUpdateReq) (*DingOAUpdateResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method DingOAUpdate not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) DingOAComment(context.Context, *DingOACommentReq) (*DingOACommentResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method DingOAComment not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) DingOAGet(context.Context, *DingOAGetReq) (*DingOAGetResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method DingOAGet not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) FinanceNotify(context.Context, *PaymentCallbackData) (*PaymentCallbackRes, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method FinanceNotify not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) HsSmsSend(context.Context, *HsSmsSendReq) (*HsSmsSendRes, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method HsSmsSend not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
|
||||||
|
func (UnimplementedMsgServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
|
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to MsgServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeMsgServer interface {
|
||||||
|
mustEmbedUnimplementedMsgServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) {
|
||||||
|
// If the following call pancis, it indicates UnimplementedMsgServer was
|
||||||
|
// embedded by pointer and is nil. This will cause panics if an
|
||||||
|
// unimplemented method is ever invoked, so we test this at initialization
|
||||||
|
// time to prevent it from happening at runtime later due to I/O.
|
||||||
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||||
|
t.testEmbeddedByValue()
|
||||||
|
}
|
||||||
|
s.RegisterService(&Msg_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_Oauth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(OauthReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).Oauth(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_Oauth_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).Oauth(ctx, req.(*OauthReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_CenterSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CenterSendReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).CenterSend(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_CenterSend_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).CenterSend(ctx, req.(*CenterSendReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_SmsSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(SmsSendReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).SmsSend(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_SmsSend_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).SmsSend(ctx, req.(*SmsSendReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_DingTalkBlackBoardSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(DingTalkBlackBoardSendReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).DingTalkBlackBoardSend(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_DingTalkBlackBoardSend_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).DingTalkBlackBoardSend(ctx, req.(*DingTalkBlackBoardSendReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_WxBizSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(WxBizSendReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).WxBizSend(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_WxBizSend_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).WxBizSend(ctx, req.(*WxBizSendReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_CallInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CallInfoReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).CallInfo(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_CallInfo_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).CallInfo(ctx, req.(*CallInfoReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_CallCaptcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CallCaptchaReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).CallCaptcha(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_CallCaptcha_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).CallCaptcha(ctx, req.(*CallCaptchaReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_DingOACreate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(DingOACreateReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).DingOACreate(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_DingOACreate_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).DingOACreate(ctx, req.(*DingOACreateReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_DingOAUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(DingOAUpdateReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).DingOAUpdate(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_DingOAUpdate_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).DingOAUpdate(ctx, req.(*DingOAUpdateReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_DingOAComment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(DingOACommentReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).DingOAComment(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_DingOAComment_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).DingOAComment(ctx, req.(*DingOACommentReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_DingOAGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(DingOAGetReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).DingOAGet(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_DingOAGet_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).DingOAGet(ctx, req.(*DingOAGetReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_FinanceNotify_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(PaymentCallbackData)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).FinanceNotify(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_FinanceNotify_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).FinanceNotify(ctx, req.(*PaymentCallbackData))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Msg_HsSmsSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(HsSmsSendReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MsgServer).HsSmsSend(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: Msg_HsSmsSend_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MsgServer).HsSmsSend(ctx, req.(*HsSmsSendReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "msg.Msg",
|
||||||
|
HandlerType: (*MsgServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "oauth",
|
||||||
|
Handler: _Msg_Oauth_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "centerSend",
|
||||||
|
Handler: _Msg_CenterSend_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "smsSend",
|
||||||
|
Handler: _Msg_SmsSend_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "dingTalkBlackBoardSend",
|
||||||
|
Handler: _Msg_DingTalkBlackBoardSend_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "wxBizSend",
|
||||||
|
Handler: _Msg_WxBizSend_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "callInfo",
|
||||||
|
Handler: _Msg_CallInfo_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "callCaptcha",
|
||||||
|
Handler: _Msg_CallCaptcha_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "dingOACreate",
|
||||||
|
Handler: _Msg_DingOACreate_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "dingOAUpdate",
|
||||||
|
Handler: _Msg_DingOAUpdate_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "dingOAComment",
|
||||||
|
Handler: _Msg_DingOAComment_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "dingOAGet",
|
||||||
|
Handler: _Msg_DingOAGet_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "FinanceNotify",
|
||||||
|
Handler: _Msg_FinanceNotify_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "hsSmsSend",
|
||||||
|
Handler: _Msg_HsSmsSend_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "msg/msg.proto",
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package protoc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitea.cdlsxd.cn/self-tools/l_msg_api/protoc/msg"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var rpcMsgClient msg.MsgClient
|
||||||
|
|
||||||
|
func InstanceMsgClient(host string) msg.MsgClient {
|
||||||
|
if rpcMsgClient != nil {
|
||||||
|
return rpcMsgClient
|
||||||
|
}
|
||||||
|
conn, err := grpc.NewClient(host)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("did not connect: %v", err)
|
||||||
|
}
|
||||||
|
rpcMsgClient = msg.NewMsgClient(conn)
|
||||||
|
return rpcMsgClient
|
||||||
|
}
|
|
@ -1,17 +1,78 @@
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitea.cdlsxd.cn/self-tools/l_msg_api"
|
"gitea.cdlsxd.cn/self-tools/l_msg_api"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBase(t *testing.T) {
|
const (
|
||||||
msg, err := l_msg_api.NewMessageCenter("", "", "sms", "cron_sms")
|
ClientKey = "ymt"
|
||||||
|
ClientSecret = "ymt"
|
||||||
|
serverHost = "http://121.199.38.107:8000"
|
||||||
|
local = "http://127.0.0.1:8001"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSms(t *testing.T) {
|
||||||
|
msg, err := l_msg_api.NewMessageCenter(serverHost, ClientKey, ClientSecret, "sms", "sms")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := msg.SendSms([]string{"15082245122"}, `{"content": "测试"}`)
|
res, err := msg.SendSms(context.TODO(), []string{"15082245107"}, `{"content": "测试"}`)
|
||||||
|
fmt.Println(res, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOaCreate(t *testing.T) {
|
||||||
|
msg, err := l_msg_api.NewMessageCenter(local, ClientKey, ClientSecret, "sw_oa", "sw_oa_purchase")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
form := []l_msg_api.FormComponentValues{
|
||||||
|
{Name: "采购单号", Value: "123456789123"},
|
||||||
|
{Name: "供应商", Value: "测试供应商"},
|
||||||
|
{Name: "采购总数量", Value: "1"},
|
||||||
|
{Name: "入库仓库", Value: "测试仓库"},
|
||||||
|
{Name: "采购总金额", Value: "11.22"},
|
||||||
|
{Name: "预计到货时间", Value: "2025-03-21"},
|
||||||
|
}
|
||||||
|
res, err := msg.OACreate(context.TODO(), "17101201090101570", "cxvxvxcgfgfvxvxv", &l_msg_api.FormsData{
|
||||||
|
FormComponentValues: form,
|
||||||
|
Finance: &l_msg_api.Finance{
|
||||||
|
Amount: "11.22",
|
||||||
|
CheckUserId: "17109839571135417",
|
||||||
|
GoodsInfo: "实物系统测试商品",
|
||||||
|
PaymentAccount: "1312312321",
|
||||||
|
TaxAmount: "1",
|
||||||
|
CallbackUrl: "www.baidu.com",
|
||||||
|
Remark: "测试备注",
|
||||||
|
Sync: 1,
|
||||||
|
SystemName: "货易通",
|
||||||
|
SubjectName: "成都蓝色兄弟网络科技有限公司(0802)",
|
||||||
|
BankInfo: l_msg_api.BankInfo{
|
||||||
|
BankName: "中国银行",
|
||||||
|
BankAccount: "43243243434",
|
||||||
|
AccountBankName: "中国银行成都分行",
|
||||||
|
ResellerName: "张三",
|
||||||
|
SubjectName: "张三",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
fmt.Println(res, err)
|
fmt.Println(res, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOaComment(t *testing.T) {
|
||||||
|
msg, err := l_msg_api.NewMessageCenter(serverHost, ClientKey, ClientSecret, "sw_oa", "sw_oa_purchase")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
res, err := msg.OAComment(context.TODO(), "P24110515152043136-20250318181554", "sdk测试", "", nil)
|
||||||
|
fmt.Println(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestContext(*testing.T) {
|
||||||
|
c := context.Background()
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue