Merge branch 'master' of e.coding.net:rosydev/baseapi

This commit is contained in:
邹宗楠
2023-11-02 15:51:26 +08:00
2 changed files with 35 additions and 6 deletions

View File

@@ -7,11 +7,14 @@ import (
)
const (
IMStoreStatusOnLine = "ONLINE" // 门店im在线状态
IMStoreStatusBusy = "BUSY" // 忙碌状态
IMType = "IM" // 业务类型,消息默认IM
SubTypeDef = "SEND_MESSAGE" // 子业务类型发送消息。默认值SEND_MESSAGE
ReadIMType = "READ_MESSAGE"
IMStoreStatusOnLine = "ONLINE" // 门店im在线状态
IMStoreStatusBusy = "BUSY" // 忙碌状态
IMType = "IM" // 业务类型,消息默认IM
IMTypeSendMsg = "SEND_MESSAGE" //
IMTypeReadMsg = "READ_MESSAGE" //
IMTypeGetMedia = "GET_MEDIA_URL" //
DefaultUrlExpireTime = 86400 //s
//消息类型
ContentTypeNormal = 1 //普通文本信息
@@ -53,6 +56,26 @@ func (a *API) BusinessSendMsg(param *BusinessSendMsgReq) error {
return nil
}
// GetMediaUrl 获取多媒体文件url
func (a *API) GetMediaUrl(platformShopId, mediaID string) (url string, err error) {
result, err := a.AccessAPI("im.get.media.url", map[string]interface{}{
"platformShopId": platformShopId,
"bizType": IMType,
"subBizType": IMTypeGetMedia,
"payload": map[string]interface{}{
"mediaId": mediaID,
"urlExpireTime": DefaultUrlExpireTime,
},
})
if err != nil {
return "", err
}
if result.ErrNo != 0 {
return "", errors.New(result.Error)
}
return result.Data.(map[string]interface{})["url"].(string), nil
}
// GetStoreIMStatus 获取门店的im状态 1开启-1关闭
func (a *API) GetStoreIMStatus(platformShopId string) (string, error) {
result, err := a.AccessAPI("im.getIMStatus", map[string]interface{}{"platformShopId": platformShopId})

View File

@@ -5,6 +5,12 @@ import (
"testing"
)
func TestGetMediaUrl(t *testing.T) {
data, err := api.GetMediaUrl("1157916361", "$igHNA-kCpGpwZWcDAQTNBDgFzQlUBtoAI4QBpCErI2gCqszMIMLSLDBJb6QDzwAAAYuJvuhDBM4B-Y3tB88AAAACXUH2dAgACgQLzgAC08U")
fmt.Println(err)
fmt.Println(data)
}
func TestGetStoreImStatus(t *testing.T) {
data, err := api.GetStoreIMStatus("1157916361")
if err != nil {
@@ -22,7 +28,7 @@ func TestSendMsg(t *testing.T) {
err := api.BusinessSendMsg(&BusinessSendMsgReq{
PlatformShopId: "1157916361",
BizType: IMType,
SubBizType: SubTypeDef,
SubBizType: IMTypeSendMsg,
Payload: BusinessMsgPayload{
GroupId: "$2$13205337818$PNM",
ReceiverIds: []string{"301157916361", "10154538612", "321921188187760"},