mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 00:55:59 +08:00
errcode
This commit is contained in:
@@ -126,95 +126,3 @@ func AdminLogin(c *gin.Context) {
|
||||
resp.Token = respPb.Token
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.AddUserRegisterAddFriendIDListRequest
|
||||
// resp apiStruct.AddUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.AddUserRegisterAddFriendIDList(context.Background(), &pbAdmin.AddUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", respPb.String())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||
}
|
||||
|
||||
func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.ReduceUserRegisterAddFriendIDListRequest
|
||||
// resp apiStruct.ReduceUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.ReduceUserRegisterAddFriendIDList(context.Background(), &pbAdmin.ReduceUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList, Operation: req.Operation})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||
}
|
||||
|
||||
func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.GetUserRegisterAddFriendIDListRequest
|
||||
resp apiStruct.GetUserRegisterAddFriendIDListResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.GetUserRegisterAddFriendIDList(context.Background(), &pbAdmin.GetUserRegisterAddFriendIDListReq{OperationID: req.OperationID, Pagination: &pbCommon.RequestPagination{
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.Users = respPb.UserInfoList
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
|
||||
func GetUserFriends(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetFriendsReq
|
||||
resp cms_api_struct.GetFriendsResp
|
||||
req cms_struct.GetFriendsReq
|
||||
resp cms_struct.GetFriendsResp
|
||||
reqPb pbAdmin.GetUserFriendsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@@ -49,7 +49,7 @@ func GetUserFriends(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.FriendInfoList {
|
||||
friend := &cms_api_struct.FriendInfo{}
|
||||
friend := &cms_struct.FriendInfo{}
|
||||
utils.CopyStructFields(friend, v)
|
||||
friend.Nickname = v.FriendUser.Nickname
|
||||
friend.UserID = v.FriendUser.UserID
|
||||
|
||||
@@ -18,8 +18,8 @@ import (
|
||||
|
||||
func GetGroups(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupsRequest
|
||||
resp cms_api_struct.GetGroupsResponse
|
||||
req cms_struct.GetGroupsRequest
|
||||
resp cms_struct.GetGroupsResponse
|
||||
reqPb pbGroup.GetGroupsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@@ -48,7 +48,7 @@ func GetGroups(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.CMSGroups {
|
||||
groupResp := cms_api_struct.GroupResponse{}
|
||||
groupResp := cms_struct.GroupResponse{}
|
||||
utils.CopyStructFields(&groupResp, v.GroupInfo)
|
||||
groupResp.GroupOwnerName = v.GroupOwnerUserName
|
||||
groupResp.GroupOwnerID = v.GroupOwnerUserID
|
||||
@@ -63,9 +63,9 @@ func GetGroups(c *gin.Context) {
|
||||
|
||||
func GetGroupMembers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupMembersRequest
|
||||
req cms_struct.GetGroupMembersRequest
|
||||
reqPb pbGroup.GetGroupMembersCMSReq
|
||||
resp cms_api_struct.GetGroupMembersResponse
|
||||
resp cms_struct.GetGroupMembersResponse
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
@@ -94,13 +94,13 @@ func GetGroupMembers(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
||||
resp.ResponsePagination = cms_struct.ResponsePagination{
|
||||
CurrentPage: int(respPb.Pagination.CurrentPage),
|
||||
ShowNumber: int(respPb.Pagination.ShowNumber),
|
||||
}
|
||||
resp.MemberNums = int(respPb.MemberNums)
|
||||
for _, groupMember := range respPb.Members {
|
||||
memberResp := cms_api_struct.GroupMemberResponse{}
|
||||
memberResp := cms_struct.GroupMemberResponse{}
|
||||
utils.CopyStructFields(&memberResp, groupMember)
|
||||
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
|
||||
func GetChatLogs(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetChatLogsReq
|
||||
resp cms_api_struct.GetChatLogsResp
|
||||
req cms_struct.GetChatLogsReq
|
||||
resp cms_struct.GetChatLogsResp
|
||||
reqPb pbAdminCMS.GetChatLogsReq
|
||||
)
|
||||
if err := c.Bind(&req); err != nil {
|
||||
@@ -47,7 +47,7 @@ func GetChatLogs(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.ChatLogs {
|
||||
chatLog := cms_api_struct.ChatLog{}
|
||||
chatLog := cms_struct.ChatLog{}
|
||||
utils.CopyStructFields(&chatLog, v)
|
||||
resp.ChatLogs = append(resp.ChatLogs, &chatLog)
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package cms_api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
func prometheusHandler() gin.HandlerFunc {
|
||||
h := promhttp.Handler()
|
||||
|
||||
return func(c *gin.Context) {
|
||||
h.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"Open_IM/internal/cms_api/middleware"
|
||||
"Open_IM/internal/cms_api/statistics"
|
||||
"Open_IM/internal/cms_api/user"
|
||||
"Open_IM/internal/demo/register"
|
||||
"Open_IM/pkg/common/config"
|
||||
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
@@ -30,22 +29,6 @@ func NewGinRouter() *gin.Engine {
|
||||
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||||
adminRouterGroup.Use(middleware.JWTAuth())
|
||||
adminRouterGroup.POST("/get_user_token", admin.GetUserToken)
|
||||
|
||||
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
|
||||
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
|
||||
adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList)
|
||||
|
||||
adminRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
||||
adminRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
|
||||
adminRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
|
||||
|
||||
adminRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
|
||||
adminRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
|
||||
adminRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
|
||||
|
||||
adminRouterGroup.POST("/query_ip_register", register.QueryIPRegister)
|
||||
adminRouterGroup.POST("/add_ip_limit", register.AddIPLimit)
|
||||
adminRouterGroup.POST("/remove_ip_Limit", register.RemoveIPLimit)
|
||||
}
|
||||
r2 := router.Group("")
|
||||
r2.Use(middleware.JWTAuth())
|
||||
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
|
||||
func GetMessagesStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetMessageStatisticsRequest
|
||||
resp cms_api_struct.GetMessageStatisticsResponse
|
||||
req cms_struct.GetMessageStatisticsRequest
|
||||
resp cms_struct.GetMessageStatisticsResponse
|
||||
reqPb admin.GetMessageStatisticsReq
|
||||
)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
@@ -73,8 +73,8 @@ func GetMessagesStatistics(c *gin.Context) {
|
||||
|
||||
func GetUserStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetUserStatisticsRequest
|
||||
resp cms_api_struct.GetUserStatisticsResponse
|
||||
req cms_struct.GetUserStatisticsRequest
|
||||
resp cms_struct.GetUserStatisticsResponse
|
||||
reqPb admin.GetUserStatisticsReq
|
||||
)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
@@ -138,8 +138,8 @@ func GetUserStatistics(c *gin.Context) {
|
||||
|
||||
func GetGroupStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupStatisticsRequest
|
||||
resp cms_api_struct.GetGroupStatisticsResponse
|
||||
req cms_struct.GetGroupStatisticsRequest
|
||||
resp cms_struct.GetGroupStatisticsResponse
|
||||
reqPb admin.GetGroupStatisticsReq
|
||||
)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
@@ -197,8 +197,8 @@ func GetGroupStatistics(c *gin.Context) {
|
||||
|
||||
func GetActiveUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetActiveUserRequest
|
||||
resp cms_api_struct.GetActiveUserResponse
|
||||
req cms_struct.GetActiveUserRequest
|
||||
resp cms_struct.GetActiveUserResponse
|
||||
reqPb admin.GetActiveUserReq
|
||||
)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
@@ -233,8 +233,8 @@ func GetActiveUser(c *gin.Context) {
|
||||
|
||||
func GetActiveGroup(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetActiveGroupRequest
|
||||
resp cms_api_struct.GetActiveGroupResponse
|
||||
req cms_struct.GetActiveGroupRequest
|
||||
resp cms_struct.GetActiveGroupResponse
|
||||
reqPb admin.GetActiveGroupReq
|
||||
)
|
||||
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
|
||||
func AddUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.AddUserRequest
|
||||
req cms_struct.AddUserRequest
|
||||
reqPb pb.AddUserReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@@ -48,7 +48,7 @@ func AddUser(c *gin.Context) {
|
||||
|
||||
func BlockUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BlockUserRequest
|
||||
req cms_struct.BlockUserRequest
|
||||
reqPb pb.BlockUserReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@@ -78,8 +78,8 @@ func BlockUser(c *gin.Context) {
|
||||
|
||||
func UnblockUser(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.UnblockUserRequest
|
||||
resp cms_api_struct.UnBlockUserResponse
|
||||
req cms_struct.UnblockUserRequest
|
||||
resp cms_struct.UnBlockUserResponse
|
||||
reqPb pb.UnBlockUserReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@@ -110,8 +110,8 @@ func UnblockUser(c *gin.Context) {
|
||||
|
||||
func GetBlockUsers(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetBlockUsersRequest
|
||||
resp cms_api_struct.GetBlockUsersResponse
|
||||
req cms_struct.GetBlockUsersRequest
|
||||
resp cms_struct.GetBlockUsersResponse
|
||||
reqPb pb.GetBlockUsersReq
|
||||
respPb *pb.GetBlockUsersResp
|
||||
)
|
||||
@@ -140,8 +140,8 @@ func GetBlockUsers(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.BlockUsers {
|
||||
resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{
|
||||
UserResponse: cms_api_struct.UserResponse{
|
||||
resp.BlockUsers = append(resp.BlockUsers, cms_struct.BlockUser{
|
||||
UserResponse: cms_struct.UserResponse{
|
||||
UserID: v.UserInfo.UserID,
|
||||
FaceURL: v.UserInfo.FaceURL,
|
||||
Nickname: v.UserInfo.Nickname,
|
||||
@@ -162,8 +162,8 @@ func GetBlockUsers(c *gin.Context) {
|
||||
|
||||
func GetUserIDByEmailAndPhoneNumber(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetUserIDByEmailAndPhoneNumberRequest
|
||||
resp cms_api_struct.GetUserIDByEmailAndPhoneNumberResponse
|
||||
req cms_struct.GetUserIDByEmailAndPhoneNumberRequest
|
||||
resp cms_struct.GetUserIDByEmailAndPhoneNumberResponse
|
||||
reqPb pbAdminCms.GetUserIDByEmailAndPhoneNumberReq
|
||||
respPb *pbAdminCms.GetUserIDByEmailAndPhoneNumberResp
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user