mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-11 04:25:59 +08:00
error
This commit is contained in:
@@ -2,7 +2,7 @@ package a2r
|
||||
|
||||
import (
|
||||
"OpenIM/internal/apiresp"
|
||||
"OpenIM/pkg/common/constant"
|
||||
"OpenIM/pkg/errs"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"google.golang.org/grpc"
|
||||
@@ -15,18 +15,18 @@ func Call[A, B, C any](
|
||||
) {
|
||||
var req A
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
apiresp.GinError(c, constant.ErrArgs.Wrap(err.Error())) // 参数错误
|
||||
apiresp.GinError(c, errs.ErrArgs.Wrap(err.Error())) // 参数错误
|
||||
return
|
||||
}
|
||||
if check, ok := any(&req).(interface{ Check() error }); ok {
|
||||
if err := check.Check(); err != nil {
|
||||
apiresp.GinError(c, constant.ErrArgs.Wrap(err.Error())) // 参数校验失败
|
||||
apiresp.GinError(c, errs.ErrArgs.Wrap(err.Error())) // 参数校验失败
|
||||
return
|
||||
}
|
||||
}
|
||||
cli, err := client()
|
||||
if err != nil {
|
||||
apiresp.GinError(c, constant.ErrInternalServer.Wrap(err.Error())) // 获取RPC连接失败
|
||||
apiresp.GinError(c, errs.ErrInternalServer.Wrap(err.Error())) // 获取RPC连接失败
|
||||
return
|
||||
}
|
||||
data, err := rpc(cli, c, &req)
|
||||
|
||||
+6
-5
@@ -7,6 +7,7 @@ import (
|
||||
"OpenIM/pkg/common/config"
|
||||
"OpenIM/pkg/common/constant"
|
||||
"OpenIM/pkg/common/log"
|
||||
"OpenIM/pkg/errs"
|
||||
"OpenIM/pkg/proto/msg"
|
||||
"OpenIM/pkg/proto/sdkws"
|
||||
"OpenIM/pkg/utils"
|
||||
@@ -192,22 +193,22 @@ func (o *Msg) ManagementSendMsg(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||
apiresp.GinError(c, constant.ErrData)
|
||||
apiresp.GinError(c, errs.ErrData)
|
||||
return
|
||||
} else if err := o.validate.Struct(data); err != nil {
|
||||
apiresp.GinError(c, constant.ErrData)
|
||||
apiresp.GinError(c, errs.ErrData)
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, data, params)
|
||||
switch params.SessionType {
|
||||
case constant.SingleChatType:
|
||||
if len(params.RecvID) == 0 {
|
||||
apiresp.GinError(c, constant.ErrData)
|
||||
apiresp.GinError(c, errs.ErrData)
|
||||
return
|
||||
}
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
if len(params.GroupID) == 0 {
|
||||
apiresp.GinError(c, constant.ErrData)
|
||||
apiresp.GinError(c, errs.ErrData)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -215,7 +216,7 @@ func (o *Msg) ManagementSendMsg(c *gin.Context) {
|
||||
pbData := newUserSendMsgReq(¶ms)
|
||||
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImMsgName)
|
||||
if err != nil {
|
||||
apiresp.GinError(c, constant.ErrInternalServer)
|
||||
apiresp.GinError(c, errs.ErrInternalServer)
|
||||
return
|
||||
}
|
||||
client := msg.NewMsgClient(conn)
|
||||
|
||||
Reference in New Issue
Block a user