480 lines
13 KiB
Go
480 lines
13 KiB
Go
|
|
package controller
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"net/http"
|
|||
|
|
"strings"
|
|||
|
|
req "xiawan/wx/api/req"
|
|||
|
|
"xiawan/wx/api/service"
|
|||
|
|
"xiawan/wx/api/vo"
|
|||
|
|
|
|||
|
|
"log"
|
|||
|
|
|
|||
|
|
"github.com/gin-gonic/gin"
|
|||
|
|
"github.com/gorilla/websocket"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// AddMessageMgrApi 添加要发送的文本消息进入管理器
|
|||
|
|
func AddMessageMgrApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.SendMessageModel)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
result := service.AddMessageMgrService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var (
|
|||
|
|
upgrader = websocket.Upgrader{
|
|||
|
|
ReadBufferSize: 1024,
|
|||
|
|
WriteBufferSize: 1024,
|
|||
|
|
}
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// GetSyncMsgApi 同步消息,ws协议; 下面有【同步消息-HTTP-轮询方式】
|
|||
|
|
// GetSyncMsgApi 处理同步消息的 API 请求。
|
|||
|
|
// 它从请求中获取查询参数 "key",如果不存在或为空,则返回 400 错误和相应的错误信息。
|
|||
|
|
// 如果 "key" 有效,则调用 WebSocketHandler 进行后续处理。
|
|||
|
|
func GetSyncMsgApi(ctx *gin.Context) {
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
ctx.JSON(http.StatusBadRequest, gin.H{
|
|||
|
|
"error": "无效的key",
|
|||
|
|
})
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
service.WebSocketHandler(ctx, queryKey)
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// HttpSyncMsg 同步消息, HTTP-轮询方式
|
|||
|
|
func HttpSyncMsg(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.SyncMessageModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(queryKey))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_ = ctx.ShouldBindJSON(&reqModel)
|
|||
|
|
if reqModel.Count < 0 {
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFail("Count参数错误"))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
result := service.HttpSyncMsg(queryKey, reqModel.Count)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// SendImageMessageApi 发送图片消息
|
|||
|
|
func SendImageMessageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.SendMessageModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(queryKey))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.SendImageMessageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// SendImageNewMessageApi 发送图片消息(New)
|
|||
|
|
func SendImageNewMessageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.SendMessageModel)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Keys
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.SendImageNewMessageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// SendTextMessageApi 发送文本消息
|
|||
|
|
func SendTextMessageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.SendMessageModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.SendTextMessageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ShareCardMessageApi 分享名片消息
|
|||
|
|
func ShareCardMessageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.ShareCardParam)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.ShareCardMessageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// SendTextMessageNoShow 不显示会话(不删聊天记录)
|
|||
|
|
func SendTextMessageNoShow(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.MessageNoShowParam)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.SendTextMessageNoShowService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ForwardImageMessageApi 转发图片
|
|||
|
|
func ForwardImageMessageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.ForwardMessageModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.ForwardImageMessageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ForwardVideoMessageApi 转发视频
|
|||
|
|
func ForwardVideoMessageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.ForwardMessageModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.ForwardVideoMessageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// SendEmojiMessageApi 发送表情
|
|||
|
|
func SendEmojiMessageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.SendEmojiMessageModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.SendEmojiMessageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ForwardEmojiApi 转发表情,包含动图
|
|||
|
|
func ForwardEmojiApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.SendEmojiMessageModel)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.ForwardEmojiService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// SendAppMessageApi 发送App消息
|
|||
|
|
func SendAppMessageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.AppMessageModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.SendAppMessageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// RevokeMsgApi 撤销消息
|
|||
|
|
func RevokeMsgApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.RevokeMsgModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.RevokeMsgService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// RevokeMsgNewApi 撤回消息(New)
|
|||
|
|
func RevokeMsgNewApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.RevokeMsgModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 检查是否有ClientImgIdStr字段,如果有则是图片消息
|
|||
|
|
if reqModel.ClientImgIdStr != "" {
|
|||
|
|
reqModel.IsImage = true
|
|||
|
|
log.Printf("尝试撤回图片消息: NewMsgId=%s, ClientMsgId=%d, CreateTime=%d, ClientImgIdStr=%s",
|
|||
|
|
reqModel.NewMsgId, reqModel.ClientMsgId, reqModel.CreateTime, reqModel.ClientImgIdStr)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
result := service.RevokeMsgNewService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// UploadVoiceRequestApi 发送语音
|
|||
|
|
func UploadVoiceRequestApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.SendUploadVoiceRequestModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.UploadVoiceRequestService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// CdnUploadVideoRequestApi 上传视频
|
|||
|
|
func CdnUploadVideoRequestApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.CdnUploadVideoRequest)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.SendCdnUploadVideoRequestService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// SendCdnDownloadApi 下载 请求
|
|||
|
|
func SendCdnDownloadApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.DownMediaModel)
|
|||
|
|
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.SendCdnDownloadService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GetMsgBigImgApi 获取图片(高清图片下载)
|
|||
|
|
func GetMsgBigImgApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.DownloadParam)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.GetMsgBigImgService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GetMsgVideoApi 获取视频(视频数据下载)
|
|||
|
|
func GetMsgVideoApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.DownloadParam)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.GetMsgVideoService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// NewSyncHistoryMessageApi 同步历史消息
|
|||
|
|
func NewSyncHistoryMessageApi(ctx *gin.Context) {
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.NewSyncHistoryMessageService(queryKey)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GroupMassMsgTextApi 群发接口
|
|||
|
|
func GroupMassMsgTextApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.GroupMassMsgTextModel)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.GroupMassMsgTextService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GroupMassMsgImageApi 群发图片
|
|||
|
|
func GroupMassMsgImageApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.GroupMassMsgImageModel)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.GroupMassMsgImageService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GetMsgVoiceApi 下载语音消息
|
|||
|
|
func GetMsgVoiceApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.DownloadVoiceModel)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
result := service.GetMsgVoiceService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// DownloadEmojiGifApi 下载表情
|
|||
|
|
func DownloadEmojiGifApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.DownloadEmojiModel)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
//确保每次都有Key
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(queryKey))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
result := service.DownloadEmojiGifService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// UploadImageToCDNApi 纯CDN图片上传接口
|
|||
|
|
func UploadImageToCDNApi(ctx *gin.Context) {
|
|||
|
|
reqModel := new(req.UploadImageToCDNModel)
|
|||
|
|
queryKey, isExist := ctx.GetQuery("key")
|
|||
|
|
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
|||
|
|
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if !validateData(ctx, &reqModel) {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
result := service.UploadImageToCDNService(queryKey, *reqModel)
|
|||
|
|
ctx.JSON(http.StatusOK, result)
|
|||
|
|
}
|