test-errcode
withchao 2 years ago
parent 7b10b17056
commit 69e94c25f4

@ -4,7 +4,6 @@ import (
common "Open_IM/internal/api_to_rpc" common "Open_IM/internal/api_to_rpc"
api "Open_IM/pkg/base_info" api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/token_verify"
rpc "Open_IM/pkg/proto/friend" rpc "Open_IM/pkg/proto/friend"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -13,20 +12,20 @@ import (
// 不一致 // 不一致
func AddBlacklist(c *gin.Context) { func AddBlacklist(c *gin.Context) {
common.ApiToRpc(c, &api.AddBlacklistReq{}, &api.AddBlacklistResp{}, common.ApiToRpc(c, &api.AddBlacklistReq{}, &api.AddBlacklistResp{},
config.Config.RpcRegisterName.OpenImFriendName, rpc.NewFriendClient, utils.GetSelfFuncName(), token_verify.ParseUserIDFromToken) config.Config.RpcRegisterName.OpenImFriendName, rpc.NewFriendClient, utils.GetSelfFuncName())
} }
func ImportFriend1(c *gin.Context) { func ImportFriend1(c *gin.Context) {
common.ApiToRpc(c, &api.ImportFriendReq{}, &api.ImportFriendResp{}, common.ApiToRpc(c, &api.ImportFriendReq{}, &api.ImportFriendResp{},
config.Config.RpcRegisterName.OpenImFriendName, rpc.NewFriendClient, utils.GetSelfFuncName(), token_verify.ParseUserIDFromToken) config.Config.RpcRegisterName.OpenImFriendName, rpc.NewFriendClient, utils.GetSelfFuncName())
} }
func AddFriend1(c *gin.Context) { func AddFriend1(c *gin.Context) {
common.ApiToRpc(c, &api.AddFriendReq{}, &api.AddFriendResp{}, common.ApiToRpc(c, &api.AddFriendReq{}, &api.AddFriendResp{},
config.Config.RpcRegisterName.OpenImFriendName, rpc.NewFriendClient, utils.GetSelfFuncName(), token_verify.ParseUserIDFromToken) config.Config.RpcRegisterName.OpenImFriendName, rpc.NewFriendClient, utils.GetSelfFuncName())
} }
func AddFriendResponse1(c *gin.Context) { func AddFriendResponse1(c *gin.Context) {
common.ApiToRpc(c, &api.AddFriendResponseReq{}, &api.AddFriendResponseResp{}, common.ApiToRpc(c, &api.AddFriendResponseReq{}, &api.AddFriendResponseResp{},
config.Config.RpcRegisterName.OpenImFriendName, rpc.NewFriendClient, utils.GetSelfFuncName(), token_verify.ParseUserIDFromToken) config.Config.RpcRegisterName.OpenImFriendName, rpc.NewFriendClient, utils.GetSelfFuncName())
} }

@ -445,7 +445,7 @@ func InviteUserToGroup(c *gin.Context) {
func NewCreateGroup(c *gin.Context) { func NewCreateGroup(c *gin.Context) {
common.ApiToRpc(c, &api.CreateGroupReq{}, &api.CreateGroupResp{}, common.ApiToRpc(c, &api.CreateGroupReq{}, &api.CreateGroupResp{},
config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "CreateGroup", token_verify.ParseUserIDFromToken) config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "CreateGroup")
} }
// @Summary 获取用户收到的加群信息列表 // @Summary 获取用户收到的加群信息列表
@ -515,7 +515,7 @@ func GetRecvGroupApplicationList(c *gin.Context) {
// @Router /group/get_user_req_group_applicationList [post] // @Router /group/get_user_req_group_applicationList [post]
func GetUserReqGroupApplicationList(c *gin.Context) { func GetUserReqGroupApplicationList(c *gin.Context) {
common.ApiToRpc(c, &api.GetUserReqGroupApplicationListReq{}, &api.GetUserRespGroupApplicationResp{}, common.ApiToRpc(c, &api.GetUserReqGroupApplicationListReq{}, &api.GetUserRespGroupApplicationResp{},
config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "GetGroupApplicationList", token_verify.ParseUserIDFromToken) config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "GetGroupApplicationList")
} }
// @Summary 通过群ID列表获取群信息 // @Summary 通过群ID列表获取群信息
@ -803,7 +803,7 @@ func QuitGroup(c *gin.Context) {
func NewSetGroupInfo(c *gin.Context) { func NewSetGroupInfo(c *gin.Context) {
common.ApiToRpc(c, &api.SetGroupInfoReq{}, &api.SetGroupInfoResp{}, common.ApiToRpc(c, &api.SetGroupInfoReq{}, &api.SetGroupInfoResp{},
config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "SetGroupInfo", token_verify.ParseUserIDFromToken) config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, "SetGroupInfo")
} }
func argsHandle(params *api.SetGroupInfoReq, req *rpc.SetGroupInfoReq) { func argsHandle(params *api.SetGroupInfoReq, req *rpc.SetGroupInfoReq) {
@ -1263,7 +1263,7 @@ func GetGroupAbstractInfo(c *gin.Context) {
GroupMemberListHash uint64 `json:"groupMemberListHash"` GroupMemberListHash uint64 `json:"groupMemberListHash"`
} }
//common.ApiToRpc(c, &api.GetGroupAbstractInfoReq{}, &GetGroupAbstractInfoResp{}, config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, utils.GetSelfFuncName(), token_verify.ParseUserIDFromToken) //common.ApiToRpc(c, &api.GetGroupAbstractInfoReq{}, &GetGroupAbstractInfoResp{}, config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, utils.GetSelfFuncName(), token_verify.ParseUserIDFromToken)
common.ApiToRpc(c, &api.GetGroupAbstractInfoReq{}, &GetGroupAbstractInfoResp{}, config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, utils.GetSelfFuncName(), nil) common.ApiToRpc(c, &api.GetGroupAbstractInfoReq{}, &GetGroupAbstractInfoResp{}, config.Config.RpcRegisterName.OpenImGroupName, rpc.NewGroupClient, utils.GetSelfFuncName())
//var ( //var (
//req api.GetGroupAbstractInfoReq //req api.GetGroupAbstractInfoReq

@ -65,7 +65,7 @@ func WriteErrorResponse(ctx context.Context, funcName string, err error, args ..
ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": t.ErrCode, "errMsg": t.ErrMsg, "errDtl": t.DetailErrMsg}) ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": t.ErrCode, "errMsg": t.ErrMsg, "errDtl": t.DetailErrMsg})
return return
default: default:
s, ok := status.FromError(err) s, ok := status.FromError(e)
if !ok { if !ok {
ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": constant.ErrDefaultOther.ErrCode, "errMsg": err.Error(), "errDtl": fmt.Sprintf("%+v", err)}) ctx.Value(TraceLogKey).(*ApiInfo).GinCtx.JSON(http.StatusOK, gin.H{"errCode": constant.ErrDefaultOther.ErrCode, "errMsg": err.Error(), "errDtl": fmt.Sprintf("%+v", err)})
return return

Loading…
Cancel
Save