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.
44 lines
1.4 KiB
44 lines
1.4 KiB
3 years ago
|
package apiChat
|
||
|
|
||
|
import (
|
||
|
api "Open_IM/pkg/base_info"
|
||
|
"Open_IM/pkg/common/config"
|
||
|
"Open_IM/pkg/common/constant"
|
||
|
"Open_IM/pkg/common/log"
|
||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||
|
pbChat "Open_IM/pkg/proto/chat"
|
||
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||
|
"Open_IM/pkg/utils"
|
||
|
"context"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"net/http"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func DelMsg(c *gin.Context) {
|
||
|
var (
|
||
|
req api.DelMsgReq
|
||
|
resp api.DelMsgResp
|
||
|
reqPb pbCommon.DelMsgListReq
|
||
|
)
|
||
|
if err := c.BindJSON(&req); err != nil {
|
||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||
|
return
|
||
|
}
|
||
|
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
||
|
}
|
||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||
|
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||
|
msgClient := pbChat.NewChatClient(grpcConn)
|
||
|
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
||
|
if err != nil {
|
||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
||
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
||
|
return
|
||
|
}
|
||
|
resp.ErrCode = respPb.ErrCode
|
||
|
resp.ErrMsg = respPb.ErrMsg
|
||
|
c.JSON(http.StatusOK, resp)
|
||
|
}
|