mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
api services update
This commit is contained in:
parent
392b1c1d2b
commit
18d3523cf2
@ -3,10 +3,10 @@ package apiAuth
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/src/proto/auth"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -42,7 +42,7 @@ func UserRegister(c *gin.Context) {
|
||||
log.Info("", "", "api user_register init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.RpcGetTokenName)
|
||||
client := pbAuth.NewAuthClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsUserRegister{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package apiAuth
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbAuth "Open_IM/src/proto/auth"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -29,7 +29,7 @@ func UserToken(c *gin.Context) {
|
||||
log.Info("", "", "api user_token init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.RpcGetTokenName)
|
||||
client := pbAuth.NewAuthClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsUserToken{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package apiChat
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbMsg "Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -35,6 +35,7 @@ func UserNewestSeq(c *gin.Context) {
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", params)
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package apiChat
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/chat"
|
||||
"Open_IM/src/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"Open_IM/src/utils"
|
||||
"context"
|
||||
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
@ -3,10 +3,10 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -21,7 +21,7 @@ func AddBlacklist(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsSearchFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -22,7 +22,7 @@ func AddFriend(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsAddFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -23,7 +23,7 @@ func AddFriendResponse(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsAddFriendResponse{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -22,7 +22,7 @@ func DeleteFriend(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsDeleteFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -32,7 +32,7 @@ func GetBlacklist(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetBlackList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -33,7 +33,7 @@ func GetFriendApplyList(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetApplyList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@ -83,7 +83,7 @@ func GetSelfApplyList(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetApplyList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -34,7 +34,7 @@ func GetFriendList(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetFriendLIst{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -21,7 +21,7 @@ func GetFriendsInfo(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api search friend init ...."))
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsSearchFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -21,7 +21,7 @@ func IsFriend(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsIsFriend{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -21,7 +21,7 @@ func RemoveBlacklist(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsRemoveBlackList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package friend
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/src/proto/friend"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -22,7 +22,7 @@ func SetFriendComment(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsSetFriendComment{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,17 +3,17 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsCreateGroupStruct struct {
|
||||
MemberList []*pb.GroupAddMemberInfo `json:"memberList"`
|
||||
GroupName string `json:"name"`
|
||||
GroupName string `json:"groupName"`
|
||||
Introduction string `json:"introduction"`
|
||||
Notification string `json:"notification"`
|
||||
FaceUrl string `json:"faceUrl"`
|
||||
@ -25,7 +25,7 @@ func CreateGroup(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsCreateGroupStruct{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/group"
|
||||
"Open_IM/src/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -24,14 +24,19 @@ func newUserRegisterReq(params *paramsGroupApplicationList) *group.GetGroupAppli
|
||||
}
|
||||
|
||||
type paramsGroupApplicationListRet struct {
|
||||
ID string `json:"id"`
|
||||
GroupID string `json:"groupID"`
|
||||
FromUserID string `json:"fromUserID"`
|
||||
FromUserNickName string `json:"fromUserNickName"`
|
||||
FromUserFaceUrl string `json:"fromUserFaceUrl"`
|
||||
ToUserID string `json:"toUserID"`
|
||||
AddTime int64 `json:"addTime"`
|
||||
RequestMsg string `json:"requestMsg"`
|
||||
Flag int32 `json:"flag"`
|
||||
RequestMsg string `json:"reqMsg"`
|
||||
HandledMsg string `json:"handledMsg"`
|
||||
AddTime int64 `json:"createTime"`
|
||||
FromUserNickname string `json:"fromUserNickName"`
|
||||
ToUserNickname string `json:"toUserNickName"`
|
||||
FromUserFaceUrl string `json:"fromUserFaceURL"`
|
||||
ToUserFaceUrl string `json:"toUserFaceURL"`
|
||||
HandledUser string `json:"handledUser"`
|
||||
Type int32 `json:"type"`
|
||||
HandleStatus int32 `json:"handleStatus"`
|
||||
HandleResult int32 `json:"handleResult"`
|
||||
@ -41,7 +46,7 @@ func GetGroupApplicationList(c *gin.Context) {
|
||||
log.Info("", "", "api GetGroupApplicationList init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGroupApplicationList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@ -67,27 +72,40 @@ func GetGroupApplicationList(c *gin.Context) {
|
||||
}
|
||||
log.Info("", "", "api GetGroupApplicationList call rpc success, [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
var userReq []paramsGroupApplicationListRet
|
||||
for i := 0; i < len(reply.Data.User); i++ {
|
||||
req := paramsGroupApplicationListRet{}
|
||||
req.GroupID = reply.Data.User[i].GroupID
|
||||
req.FromUserID = reply.Data.User[i].FromUserID
|
||||
req.FromUserNickName = reply.Data.User[i].FromUserNickName
|
||||
req.FromUserFaceUrl = reply.Data.User[i].FromUserFaceUrl
|
||||
req.ToUserID = reply.Data.User[i].ToUserID
|
||||
req.RequestMsg = reply.Data.User[i].RequestMsg
|
||||
req.HandledMsg = reply.Data.User[i].HandledMsg
|
||||
req.Type = reply.Data.User[i].Type
|
||||
req.HandleStatus = reply.Data.User[i].HandleStatus
|
||||
req.HandleResult = reply.Data.User[i].HandleResult
|
||||
userReq = append(userReq, req)
|
||||
unProcessCount := 0
|
||||
userReq := make([]paramsGroupApplicationListRet, 0)
|
||||
if reply != nil && reply.Data != nil && reply.Data.User != nil {
|
||||
for i := 0; i < len(reply.Data.User); i++ {
|
||||
req := paramsGroupApplicationListRet{}
|
||||
req.ID = reply.Data.User[i].ID
|
||||
req.GroupID = reply.Data.User[i].GroupID
|
||||
req.FromUserID = reply.Data.User[i].FromUserID
|
||||
req.ToUserID = reply.Data.User[i].ToUserID
|
||||
req.Flag = reply.Data.User[i].Flag
|
||||
req.RequestMsg = reply.Data.User[i].RequestMsg
|
||||
req.HandledMsg = reply.Data.User[i].HandledMsg
|
||||
req.AddTime = reply.Data.User[i].AddTime
|
||||
req.FromUserNickname = reply.Data.User[i].FromUserNickname
|
||||
req.ToUserNickname = reply.Data.User[i].ToUserNickname
|
||||
req.FromUserFaceUrl = reply.Data.User[i].FromUserFaceUrl
|
||||
req.ToUserFaceUrl = reply.Data.User[i].ToUserFaceUrl
|
||||
req.HandledUser = reply.Data.User[i].HandledUser
|
||||
req.Type = reply.Data.User[i].Type
|
||||
req.HandleStatus = reply.Data.User[i].HandleStatus
|
||||
req.HandleResult = reply.Data.User[i].HandleResult
|
||||
userReq = append(userReq, req)
|
||||
|
||||
if req.Flag == 0 {
|
||||
unProcessCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"data": gin.H{
|
||||
"count": reply.Data.Count,
|
||||
"count": unProcessCount,
|
||||
"user": userReq,
|
||||
},
|
||||
})
|
||||
|
@ -3,10 +3,10 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -21,7 +21,7 @@ func GetGroupsInfo(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGetGroupInfo{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@ -40,12 +40,26 @@ func GetGroupsInfo(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("call get groups info rpc server success,info=%s", RpcResp.String())
|
||||
log.InfoByArgs("call get groups info rpc server success", RpcResp.String())
|
||||
if RpcResp.ErrorCode == 0 {
|
||||
groupsInfo := make([]pb.GroupInfo, 0)
|
||||
for _, v := range RpcResp.Data {
|
||||
var groupInfo pb.GroupInfo
|
||||
groupInfo.GroupId = v.GroupId
|
||||
groupInfo.GroupName = v.GroupName
|
||||
groupInfo.Notification = v.Notification
|
||||
groupInfo.Introduction = v.Introduction
|
||||
groupInfo.FaceUrl = v.FaceUrl
|
||||
groupInfo.CreateTime = v.CreateTime
|
||||
groupInfo.OwnerId = v.OwnerId
|
||||
groupInfo.MemberCount = v.MemberCount
|
||||
|
||||
groupsInfo = append(groupsInfo, groupInfo)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": RpcResp.ErrorCode,
|
||||
"errMsg": RpcResp.ErrorMsg,
|
||||
"data": RpcResp.Data,
|
||||
"data": groupsInfo,
|
||||
})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg})
|
||||
|
@ -3,11 +3,11 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -24,10 +24,10 @@ type GetJoinedGroupListReq struct {
|
||||
}
|
||||
|
||||
type KickGroupMemberReq struct {
|
||||
GroupID string `json:"groupID"`
|
||||
UidList []string `json:"uidList" binding:"required"`
|
||||
Reason string `json:"reason"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
GroupID string `json:"groupID"`
|
||||
UidListInfo []*pb.GroupMemberFullInfo `json:"uidListInfo" binding:"required"`
|
||||
Reason string `json:"reason"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
func KickGroupMember(c *gin.Context) {
|
||||
@ -35,7 +35,6 @@ func KickGroupMember(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
|
||||
params := KickGroupMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@ -47,7 +46,7 @@ func KickGroupMember(c *gin.Context) {
|
||||
OperationID: params.OperationID,
|
||||
GroupID: params.GroupID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
UidList: params.UidList,
|
||||
UidListInfo: params.UidListInfo,
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "recv req: ", req.String())
|
||||
|
||||
@ -91,7 +90,6 @@ func GetGroupMembersInfo(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
|
||||
params := GetGroupMembersInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@ -154,7 +152,6 @@ func GetGroupMemberList(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
|
||||
params := GetGroupMemberListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@ -205,7 +202,6 @@ func GetGroupAllMember(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
|
||||
params := getGroupAllMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@ -264,8 +260,6 @@ func GetJoinedGroupList(c *gin.Context) {
|
||||
fmt.Println("config: ", etcdConn, config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
defer etcdConn.Close()
|
||||
|
||||
params := GetJoinedGroupListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
@ -283,6 +277,7 @@ func GetJoinedGroupList(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "GetJoinedGroupList: ", RpcResp)
|
||||
|
||||
type GetJoinedGroupListResp struct {
|
||||
ErrorCode int32 `json:"errCode"`
|
||||
@ -315,7 +310,6 @@ func InviteUserToGroup(c *gin.Context) {
|
||||
log.Info("", "", "InviteUserToGroup start....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
|
||||
params := InviteUserToGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/group"
|
||||
"Open_IM/src/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -53,7 +53,7 @@ func ApplicationGroupResponse(c *gin.Context) {
|
||||
log.Info("", "", "api GroupApplicationResponse init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsGroupApplicationResponse{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -22,7 +22,7 @@ func JoinGroup(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsJoinGroup{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -21,7 +21,7 @@ func QuitGroup(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsQuitGroup{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/src/proto/group"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -25,7 +25,7 @@ func SetGroupInfo(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsSetGroupInfo{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,11 +3,11 @@ package group
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/src/proto/group"
|
||||
"Open_IM/src/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -31,7 +31,7 @@ func TransferGroupOwner(c *gin.Context) {
|
||||
log.Info("", "", "api TransferGroupOwner init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsTransferGroupOwner{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -7,26 +7,23 @@ import (
|
||||
"Open_IM/src/api/group"
|
||||
apiThird "Open_IM/src/api/third"
|
||||
"Open_IM/src/api/user"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/utils"
|
||||
"flag"
|
||||
"github.com/gin-gonic/gin"
|
||||
"os"
|
||||
"strconv"
|
||||
"syscall"
|
||||
//"syscall"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
logFile, err := os.OpenFile("./fatal.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0660)
|
||||
if err != nil {
|
||||
//logFile, err := os.OpenFile("./fatal.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0660)
|
||||
// if err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
syscall.Dup2(int(logFile.Fd()), int(os.Stderr.Fd()))
|
||||
//gin.SetMode(gin.ReleaseMode)
|
||||
//gin.DefaultWriter = ioutil.Discard
|
||||
log.Info("", "", "api server running...")
|
||||
// return
|
||||
// }
|
||||
//syscall.Dup2(int(logFile.Fd()), int(os.Stderr.Fd()))
|
||||
|
||||
//log.Info("", "", "api server running...")
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
// user routing group, which handles user registration and login services
|
||||
|
@ -14,6 +14,9 @@ type paramsTencentCloudStorageCredential struct {
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
var lastTime int64
|
||||
var lastRes *sts.CredentialResult
|
||||
|
||||
func TencentCloudStorageCredential(c *gin.Context) {
|
||||
params := paramsTencentCloudStorageCredential{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@ -23,6 +26,19 @@ func TencentCloudStorageCredential(c *gin.Context) {
|
||||
|
||||
log2.Info(params.Token, params.OperationID, "api TencentUpLoadCredential call start...")
|
||||
|
||||
if time.Now().Unix()-lastTime < 10 && lastRes != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": 0,
|
||||
"errMsg": "",
|
||||
"region": config.Config.Credential.Tencent.Region,
|
||||
"bucket": config.Config.Credential.Tencent.Bucket,
|
||||
"data": lastRes,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
lastTime = time.Now().Unix()
|
||||
|
||||
cli := sts.NewClient(
|
||||
config.Config.Credential.Tencent.SecretID,
|
||||
config.Config.Credential.Tencent.SecretKey,
|
||||
@ -64,6 +80,8 @@ func TencentCloudStorageCredential(c *gin.Context) {
|
||||
}
|
||||
log2.Info(c.Request.Header.Get("token"), c.PostForm("optionID"), "api TencentUpLoadCredential cli.GetCredential success res = %v, res.Credentials = %v", res, res.Credentials)
|
||||
|
||||
lastRes = res
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": 0,
|
||||
"errMsg": "",
|
||||
|
@ -3,10 +3,10 @@ package user
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/src/proto/user"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -27,7 +27,7 @@ func GetUserInfo(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsStruct{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
@ -3,10 +3,10 @@ package user
|
||||
import (
|
||||
"Open_IM/src/common/config"
|
||||
"Open_IM/src/common/log"
|
||||
"Open_IM/src/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/src/proto/user"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skiffer-git/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@ -29,7 +29,7 @@ func UpdateUserInfo(c *gin.Context) {
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
defer etcdConn.Close()
|
||||
//defer etcdConn.Close()
|
||||
|
||||
params := paramsStruct{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user