mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release
This commit is contained in:
commit
5b399d0d06
@ -63,6 +63,7 @@ func main() {
|
|||||||
userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||||
userRouterGroup.POST("/account_check", manage.AccountCheck) //1
|
userRouterGroup.POST("/account_check", manage.AccountCheck) //1
|
||||||
// userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
// userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||||
|
userRouterGroup.POST("/get_users", user.GetUsers)
|
||||||
}
|
}
|
||||||
//friend routing group
|
//friend routing group
|
||||||
friendRouterGroup := r.Group("/friend")
|
friendRouterGroup := r.Group("/friend")
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ func main() {
|
|||||||
authRouterGroup.POST("/password", register.SetPassword)
|
authRouterGroup.POST("/password", register.SetPassword)
|
||||||
authRouterGroup.POST("/login", register.Login)
|
authRouterGroup.POST("/login", register.Login)
|
||||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||||
|
authRouterGroup.POST("/check_login", register.CheckLoginLimit)
|
||||||
}
|
}
|
||||||
demoRouterGroup := r.Group("/auth")
|
demoRouterGroup := r.Group("/auth")
|
||||||
{
|
{
|
||||||
@ -39,7 +41,10 @@ func main() {
|
|||||||
demoRouterGroup.POST("/password", register.SetPassword)
|
demoRouterGroup.POST("/password", register.SetPassword)
|
||||||
demoRouterGroup.POST("/login", register.Login)
|
demoRouterGroup.POST("/login", register.Login)
|
||||||
demoRouterGroup.POST("/reset_password", register.ResetPassword)
|
demoRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||||
|
demoRouterGroup.POST("/check_login", register.CheckLoginLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//deprecated
|
||||||
cmsRouterGroup := r.Group("/cms_admin")
|
cmsRouterGroup := r.Group("/cms_admin")
|
||||||
{
|
{
|
||||||
cmsRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
cmsRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
|
||||||
|
|
||||||
BINARY_NAME=open_im_message_cms
|
|
||||||
BIN_DIR=../../../bin/
|
|
||||||
|
|
||||||
all: gotool build
|
|
||||||
|
|
||||||
build:
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
|
||||||
|
|
||||||
run:
|
|
||||||
@go run ./
|
|
||||||
|
|
||||||
gotool:
|
|
||||||
go fmt ./
|
|
||||||
go vet ./
|
|
||||||
|
|
||||||
install:
|
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
|
@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defaultPorts := config.Config.RpcPort.OpenImMessageCmsPort[0]
|
|
||||||
rpcPort := flag.Int("port", defaultPorts, "rpc listening port")
|
|
||||||
flag.Parse()
|
|
||||||
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
|
|
||||||
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
|
||||||
rpcServer.Run()
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
|
||||||
|
|
||||||
BINARY_NAME=open_im_statistics
|
|
||||||
BIN_DIR=../../../bin/
|
|
||||||
|
|
||||||
all: gotool build
|
|
||||||
|
|
||||||
build:
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
|
||||||
|
|
||||||
run:
|
|
||||||
@go run ./
|
|
||||||
|
|
||||||
gotool:
|
|
||||||
go fmt ./
|
|
||||||
go vet ./
|
|
||||||
|
|
||||||
install:
|
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
|
@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/internal/rpc/statistics"
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defaultPorts := config.Config.RpcPort.OpenImStatisticsPort
|
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
|
||||||
flag.Parse()
|
|
||||||
fmt.Println("start statistics rpc server, port: ", *rpcPort)
|
|
||||||
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
|
||||||
rpcServer.Run()
|
|
||||||
}
|
|
@ -3,7 +3,6 @@ package apiAuth
|
|||||||
import (
|
import (
|
||||||
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/constant"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
@ -67,17 +66,11 @@ func UserRegister(c *gin.Context) {
|
|||||||
if reply.CommonResp.ErrCode != 0 {
|
if reply.CommonResp.ErrCode != 0 {
|
||||||
errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
|
errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
if reply.CommonResp.ErrCode == constant.RegisterLimit {
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterLimit, "errMsg": "用户注册被限制"})
|
|
||||||
} else if reply.CommonResp.ErrCode == constant.InvitationError {
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
|
||||||
} else {
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID, LoginIp: params.CreateIp}
|
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/golang/protobuf/ptypes/wrappers"
|
"github.com/golang/protobuf/ptypes/wrappers"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
|
@ -216,21 +216,22 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
client := pbChat.NewMsgClient(etcdConn)
|
client := pbChat.NewMsgClient(etcdConn)
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call, api call rpc...")
|
log.Info(params.OperationID, "", "api ManagementSendMsg call, api call rpc...")
|
||||||
|
var status int32
|
||||||
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||||
if err != nil || (RpcResp != nil && RpcResp.ErrCode != 0) {
|
if err != nil || (RpcResp != nil && RpcResp.ErrCode != 0) {
|
||||||
resp, err2 := client.SetSendMsgFailedFlag(context.Background(), &pbChat.SetSendMsgFailedFlagReq{OperationID: params.OperationID})
|
status = constant.MsgSendFailed
|
||||||
if err2 != nil {
|
} else {
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
status = constant.MsgSendSuccessed
|
||||||
}
|
|
||||||
if resp != nil && resp.ErrCode != 0 {
|
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
respSetSendMsgStatus, err2 := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: status})
|
||||||
|
if err2 != nil {
|
||||||
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||||
|
}
|
||||||
|
if respSetSendMsgStatus != nil && respSetSendMsgStatus.ErrCode != 0 {
|
||||||
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), respSetSendMsgStatus.ErrCode, respSetSendMsgStatus.ErrMsg)
|
||||||
|
}
|
||||||
|
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
log.Info(params.OperationID, "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||||
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: open_im_sdk.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: open_im_sdk.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||||
@ -319,16 +320,26 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
||||||
var msgSendFailedFlag bool
|
var msgSendFailedFlag bool
|
||||||
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(params.OperationID, errMsg)
|
log.NewError(params.OperationID, errMsg)
|
||||||
//resp.Data.FailedIDList = params.RecvIDList
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "rpc server error: etcdConn == nil"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "rpc server error: etcdConn == nil"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pbChat.NewMsgClient(etcdConn)
|
client := pbChat.NewMsgClient(etcdConn)
|
||||||
|
respSetSendMsgStatus, err := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: constant.MsgIsSending})
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if respSetSendMsgStatus.ErrCode != 0 {
|
||||||
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), "rpc failed", respSetSendMsgStatus)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": respSetSendMsgStatus.ErrMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
req := &api.ManagementSendMsgReq{
|
req := &api.ManagementSendMsgReq{
|
||||||
ManagementSendMsg: params.ManagementSendMsg,
|
ManagementSendMsg: params.ManagementSendMsg,
|
||||||
}
|
}
|
||||||
@ -346,7 +357,6 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
|||||||
for _, recvID := range recvList {
|
for _, recvID := range recvList {
|
||||||
pbData.MsgData.RecvID = recvID
|
pbData.MsgData.RecvID = recvID
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
||||||
|
|
||||||
rpcResp, err := client.SendMsg(context.Background(), pbData)
|
rpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||||
@ -367,14 +377,18 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
|||||||
RecvID: recvID,
|
RecvID: recvID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
var status int32
|
||||||
if msgSendFailedFlag {
|
if msgSendFailedFlag {
|
||||||
resp, err2 := client.SetSendMsgFailedFlag(context.Background(), &pbChat.SetSendMsgFailedFlagReq{OperationID: params.OperationID})
|
status = constant.MsgSendFailed
|
||||||
if err2 != nil {
|
} else {
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
status = constant.MsgSendSuccessed
|
||||||
}
|
}
|
||||||
if resp != nil && resp.ErrCode != 0 {
|
respSetSendMsgStatus, err2 := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: status})
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
if err2 != nil {
|
||||||
}
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||||
|
}
|
||||||
|
if respSetSendMsgStatus != nil && resp.ErrCode != 0 {
|
||||||
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
@ -23,49 +23,6 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DeleteUser(c *gin.Context) {
|
|
||||||
params := api.DeleteUsersReq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := &rpc.DeleteUsersReq{}
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, "DeleteUser args ", req.String())
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
|
||||||
|
|
||||||
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "call delete users rpc server failed", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp := api.DeleteUsersResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FailedUserIDList: RpcResp.FailedUserIDList}
|
|
||||||
if len(RpcResp.FailedUserIDList) == 0 {
|
|
||||||
resp.FailedUserIDList = []string{}
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, "DeleteUser api return", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary 获取所有用户uid列表
|
// @Summary 获取所有用户uid列表
|
||||||
// @Description 获取所有用户uid列表
|
// @Description 获取所有用户uid列表
|
||||||
// @Tags 用户相关
|
// @Tags 用户相关
|
||||||
|
@ -147,13 +147,13 @@ func MinioStorageCredential(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
li, err := cr.NewSTSAssumeRole(endpoint, stsOpts)
|
li, err := cr.NewSTSAssumeRole(endpoint, stsOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", utils.GetSelfFuncName(), "NewSTSAssumeRole failed", err.Error(), stsOpts, config.Config.Credential.Minio.Endpoint)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "NewSTSAssumeRole failed", err.Error(), stsOpts, config.Config.Credential.Minio.Endpoint)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v, err := li.Get()
|
v, err := li.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "li.Get error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "li.Get error", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ func GetSelfUserInfo(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
} else {
|
} else {
|
||||||
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}
|
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}
|
||||||
log.NewError(req.OperationID, "GetUserInfo api return ", resp)
|
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -456,3 +456,59 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
|
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUsers(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req api.GetUsersReq
|
||||||
|
resp api.GetUsersResp
|
||||||
|
reqPb rpc.GetUsersReq
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, "Bind failed ", err.Error(), req)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var ok bool
|
||||||
|
var errInfo string
|
||||||
|
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.UserID = req.UserID
|
||||||
|
reqPb.UserName = req.UserName
|
||||||
|
reqPb.Content = req.Content
|
||||||
|
reqPb.Pagination = &open_im_sdk.RequestPagination{ShowNumber: req.ShowNumber, PageNumber: req.PageNumber}
|
||||||
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||||
|
if etcdConn == nil {
|
||||||
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := rpc.NewUserClient(etcdConn)
|
||||||
|
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range respPb.UserList {
|
||||||
|
user := api.CMSUser{}
|
||||||
|
utils.CopyStructFields(&user, v.User)
|
||||||
|
user.IsBlock = v.IsBlock
|
||||||
|
resp.Data.UserList = append(resp.Data.UserList, &user)
|
||||||
|
}
|
||||||
|
resp.CommResp.ErrCode = respPb.CommonResp.ErrCode
|
||||||
|
resp.CommResp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||||
|
resp.Data.TotalNum = respPb.TotalNums
|
||||||
|
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||||
|
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -3,8 +3,6 @@ package admin
|
|||||||
import (
|
import (
|
||||||
apiStruct "Open_IM/pkg/cms_api_struct"
|
apiStruct "Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||||
@ -66,8 +64,8 @@ func AdminLogin(c *gin.Context) {
|
|||||||
reqPb pbAdmin.AdminLoginReq
|
reqPb pbAdmin.AdminLoginReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.Secret = req.Secret
|
reqPb.Secret = req.Secret
|
||||||
@ -84,24 +82,26 @@ func AdminLogin(c *gin.Context) {
|
|||||||
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
resp.FaceURL = respPb.FaceURL
|
||||||
|
resp.UserName = respPb.UserName
|
||||||
resp.Token = respPb.Token
|
resp.Token = respPb.Token
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req apiStruct.AddUserRegisterAddFriendIDListRequest
|
req apiStruct.AddUserRegisterAddFriendIDListRequest
|
||||||
resp apiStruct.AddUserRegisterAddFriendIDListResponse
|
// resp apiStruct.AddUserRegisterAddFriendIDListResponse
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
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)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||||
@ -110,23 +110,24 @@ func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||||
_, err := client.AddUserRegisterAddFriendIDList(context.Background(), &pbAdmin.AddUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList})
|
respPb, err := client.AddUserRegisterAddFriendIDList(context.Background(), &pbAdmin.AddUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
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) {
|
func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req apiStruct.ReduceUserRegisterAddFriendIDListRequest
|
req apiStruct.ReduceUserRegisterAddFriendIDListRequest
|
||||||
resp apiStruct.ReduceUserRegisterAddFriendIDListResponse
|
// resp apiStruct.ReduceUserRegisterAddFriendIDListResponse
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||||
@ -138,13 +139,13 @@ func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||||
_, err := client.ReduceUserRegisterAddFriendIDList(context.Background(), &pbAdmin.ReduceUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList, Operation: req.Operation})
|
respPb, err := client.ReduceUserRegisterAddFriendIDList(context.Background(), &pbAdmin.ReduceUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList, Operation: req.Operation})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
||||||
@ -153,8 +154,8 @@ func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
|||||||
resp apiStruct.GetUserRegisterAddFriendIDListResponse
|
resp apiStruct.GetUserRegisterAddFriendIDListResponse
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||||
@ -172,12 +173,12 @@ func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
|||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.Users = respPb.UserInfoList
|
resp.Users = respPb.UserInfoList
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
63
internal/cms_api/friend/friend.go
Normal file
63
internal/cms_api/friend/friend.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package friend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/cms_api_struct"
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||||
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetUserFriends(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req cms_api_struct.GetFriendsReq
|
||||||
|
resp cms_api_struct.GetFriendsResp
|
||||||
|
reqPb pbAdmin.GetUserFriendsReq
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
reqPb.Pagination = &pbCommon.RequestPagination{}
|
||||||
|
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||||
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
|
if etcdConn == nil {
|
||||||
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.UserID = req.UserID
|
||||||
|
reqPb.FriendUserName = req.FriendUserName
|
||||||
|
reqPb.FriendUserID = req.FriendUserID
|
||||||
|
|
||||||
|
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||||
|
respPb, err := client.GetUserFriends(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range respPb.FriendInfoList {
|
||||||
|
friend := &cms_api_struct.FriendInfo{}
|
||||||
|
utils.CopyStructFields(friend, v)
|
||||||
|
friend.Nickname = v.FriendUser.Nickname
|
||||||
|
friend.UserID = v.FriendUser.UserID
|
||||||
|
resp.FriendInfoList = append(resp.FriendInfoList, friend)
|
||||||
|
}
|
||||||
|
resp.FriendNums = respPb.FriendNums
|
||||||
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
|
}
|
@ -3,8 +3,6 @@ package group
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||||
@ -18,51 +16,15 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetGroupByID(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetGroupByIDRequest
|
|
||||||
resp cms_api_struct.GetGroupByIDResponse
|
|
||||||
reqPb pbGroup.GetGroupByIDReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupID = req.GroupID
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.GetGroupByID(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupById failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(&resp, respPb.CMSGroup.GroupInfo)
|
|
||||||
resp.GroupOwnerID = respPb.CMSGroup.GroupOwnerUserID
|
|
||||||
resp.GroupOwnerName = respPb.CMSGroup.GroupOwnerUserName
|
|
||||||
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetGroups(c *gin.Context) {
|
func GetGroups(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetGroupsRequest
|
req cms_api_struct.GetGroupsRequest
|
||||||
resp cms_api_struct.GetGroupsResponse
|
resp cms_api_struct.GetGroupsResponse
|
||||||
reqPb pbGroup.GetGroupsReq
|
reqPb pbGroup.GetGroupsReq
|
||||||
)
|
)
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -76,11 +38,13 @@ func GetGroups(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
reqPb.GroupID = req.GroupID
|
||||||
|
reqPb.GroupName = req.GroupName
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
respPb, err := client.GetGroups(context.Background(), &reqPb)
|
respPb, err := client.GetGroups(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range respPb.CMSGroups {
|
for _, v := range respPb.CMSGroups {
|
||||||
@ -91,95 +55,10 @@ func GetGroups(c *gin.Context) {
|
|||||||
resp.Groups = append(resp.Groups, groupResp)
|
resp.Groups = append(resp.Groups, groupResp)
|
||||||
}
|
}
|
||||||
resp.GroupNums = int(respPb.GroupNum)
|
resp.GroupNums = int(respPb.GroupNum)
|
||||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
|
||||||
|
|
||||||
func GetGroupByName(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetGroupRequest
|
|
||||||
resp cms_api_struct.GetGroupResponse
|
|
||||||
reqPb pbGroup.GetGroupReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupName = req.GroupName
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
|
||||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.GetGroup(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, v := range respPb.CMSGroups {
|
|
||||||
groupResp := cms_api_struct.GroupResponse{}
|
|
||||||
utils.CopyStructFields(&groupResp, v.GroupInfo)
|
|
||||||
groupResp.GroupOwnerName = v.GroupOwnerUserName
|
|
||||||
groupResp.GroupOwnerID = v.GroupOwnerUserID
|
|
||||||
resp.Groups = append(resp.Groups, groupResp)
|
|
||||||
}
|
|
||||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
|
||||||
resp.GroupNums = int(respPb.GroupNums)
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGroup(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.CreateGroupRequest
|
|
||||||
_ cms_api_struct.CreateGroupResponse
|
|
||||||
reqPb pbGroup.CreateGroupReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
|
||||||
reqPb.GroupInfo.GroupName = req.GroupName
|
|
||||||
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
|
||||||
reqPb.OwnerUserID = req.GroupMasterId
|
|
||||||
reqPb.OpUserID = req.GroupMasterId
|
|
||||||
for _, v := range req.GroupMembers {
|
|
||||||
reqPb.InitMemberList = append(reqPb.InitMemberList, &pbGroup.GroupAddMemberInfo{
|
|
||||||
UserID: v,
|
|
||||||
RoleLevel: 1,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
_, err := client.CreateGroup(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "CreateGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupMembers(c *gin.Context) {
|
func GetGroupMembers(c *gin.Context) {
|
||||||
@ -188,9 +67,9 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
reqPb pbGroup.GetGroupMembersCMSReq
|
reqPb pbGroup.GetGroupMembersCMSReq
|
||||||
resp cms_api_struct.GetGroupMembersResponse
|
resp cms_api_struct.GetGroupMembersResponse
|
||||||
)
|
)
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -212,7 +91,7 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS failed:", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS failed:", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
||||||
@ -226,179 +105,5 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
||||||
}
|
}
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
|
||||||
|
|
||||||
func AddGroupMembers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.RemoveGroupMembersRequest
|
|
||||||
resp cms_api_struct.RemoveGroupMembersResponse
|
|
||||||
reqPb pbGroup.AddGroupMembersCMSReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserIDList = req.Members
|
|
||||||
reqPb.GroupID = req.GroupId
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "AddGroupMembersCMS failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Success = respPb.Success
|
|
||||||
resp.Failed = respPb.Failed
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RemoveGroupMembers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.RemoveGroupMembersRequest
|
|
||||||
resp cms_api_struct.RemoveGroupMembersResponse
|
|
||||||
reqPb pbGroup.RemoveGroupMembersCMSReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserIDList = req.Members
|
|
||||||
reqPb.GroupID = req.GroupId
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.RemoveGroupMembersCMS(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "RemoveGroupMembersCMS failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Success = respPb.Success
|
|
||||||
resp.Failed = respPb.Failed
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetGroupOwner(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.SetGroupMasterRequest
|
|
||||||
_ cms_api_struct.SetGroupMasterResponse
|
|
||||||
reqPb pbGroup.OperateUserRoleReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupID = req.GroupId
|
|
||||||
reqPb.UserID = req.UserId
|
|
||||||
reqPb.RoleLevel = constant.GroupOwner
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetGroupOrdinaryUsers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.SetGroupMemberRequest
|
|
||||||
_ cms_api_struct.AdminLoginResponse
|
|
||||||
reqPb pbGroup.OperateUserRoleReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupID = req.GroupId
|
|
||||||
reqPb.UserID = req.UserId
|
|
||||||
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterGroupInfo(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.AlterGroupInfoRequest
|
|
||||||
_ cms_api_struct.SetGroupMasterResponse
|
|
||||||
reqPb pbGroup.SetGroupInfoReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OpUserID = c.MustGet("userID").(string)
|
|
||||||
reqPb.GroupInfoForSet = &commonPb.GroupInfoForSet{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
GroupName: req.GroupName,
|
|
||||||
Introduction: req.Introduction,
|
|
||||||
Notification: req.Notification,
|
|
||||||
FaceURL: req.ProfilePhoto,
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
_, err := client.SetGroupInfo(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
}
|
||||||
|
@ -3,96 +3,27 @@ package messageCMS
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbMessage "Open_IM/pkg/proto/message_cms"
|
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BroadcastMessage(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
reqPb pbMessage.BoradcastMessageReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
|
||||||
_, err := client.BoradcastMessage(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func MassSendMassage(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
reqPb pbMessage.MassSendMessageReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
|
||||||
_, err := client.MassSendMessage(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithdrawMessage(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
reqPb pbMessage.WithdrawMessageReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
|
||||||
_, err := client.WithdrawMessage(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetChatLogs(c *gin.Context) {
|
func GetChatLogs(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetChatLogsRequest
|
req cms_api_struct.GetChatLogsReq
|
||||||
resp cms_api_struct.GetChatLogsResponse
|
resp cms_api_struct.GetChatLogsResp
|
||||||
reqPb pbMessage.GetChatLogsReq
|
reqPb pbAdminCMS.GetChatLogsReq
|
||||||
)
|
)
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.Bind(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||||
@ -101,39 +32,28 @@ func GetChatLogs(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
client := pbAdminCMS.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//utils.CopyStructFields(&resp, &respPb)
|
for _, v := range respPb.ChatLogs {
|
||||||
for _, chatLog := range respPb.ChatLogs {
|
chatLog := cms_api_struct.ChatLog{}
|
||||||
resp.ChatLogs = append(resp.ChatLogs, cms_api_struct.ChatLog{
|
utils.CopyStructFields(&chatLog, v)
|
||||||
SessionType: int(chatLog.SessionType),
|
resp.ChatLogs = append(resp.ChatLogs, &chatLog)
|
||||||
ContentType: int(chatLog.ContentType),
|
|
||||||
SenderNickName: chatLog.SenderNickName,
|
|
||||||
SenderId: chatLog.SenderId,
|
|
||||||
SearchContent: chatLog.SearchContent,
|
|
||||||
WholeContent: chatLog.WholeContent,
|
|
||||||
ReceiverNickName: chatLog.ReciverNickName,
|
|
||||||
ReceiverID: chatLog.ReciverId,
|
|
||||||
GroupName: chatLog.GroupName,
|
|
||||||
GroupId: chatLog.GroupId,
|
|
||||||
Date: chatLog.Date,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
"Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func JWTAuth() gin.HandlerFunc {
|
func JWTAuth() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
||||||
log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
// log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
||||||
c.Set("userID", userID)
|
c.Set("userID", userID)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
c.Abort()
|
c.Abort()
|
||||||
http.RespHttp200(c, constant.ErrParseToken, nil)
|
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errInfo})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
|
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
package organization
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetStaffs(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetOrganizations(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSquads(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterStaff(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddOrganization(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func InquireOrganization(g *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterOrganization(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteOrganization(g *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetOrganizationSquads(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterStaffsInfo(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddChildOrganization(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
@ -2,12 +2,13 @@ package cms_api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/cms_api/admin"
|
"Open_IM/internal/cms_api/admin"
|
||||||
|
"Open_IM/internal/cms_api/friend"
|
||||||
"Open_IM/internal/cms_api/group"
|
"Open_IM/internal/cms_api/group"
|
||||||
messageCMS "Open_IM/internal/cms_api/message_cms"
|
messageCMS "Open_IM/internal/cms_api/message_cms"
|
||||||
"Open_IM/internal/cms_api/middleware"
|
"Open_IM/internal/cms_api/middleware"
|
||||||
"Open_IM/internal/cms_api/organization"
|
|
||||||
"Open_IM/internal/cms_api/statistics"
|
"Open_IM/internal/cms_api/statistics"
|
||||||
"Open_IM/internal/cms_api/user"
|
"Open_IM/internal/cms_api/user"
|
||||||
|
"Open_IM/internal/demo/register"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -24,65 +25,48 @@ func NewGinRouter() *gin.Engine {
|
|||||||
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
|
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
|
||||||
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
|
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
|
||||||
adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList)
|
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 := router.Group("")
|
||||||
r2.Use(middleware.JWTAuth())
|
r2.Use(middleware.JWTAuth())
|
||||||
statisticsRouterGroup := r2.Group("/statistics")
|
statisticsRouterGroup := r2.Group("/statistics")
|
||||||
{
|
{
|
||||||
statisticsRouterGroup.GET("/get_messages_statistics", statistics.GetMessagesStatistics)
|
statisticsRouterGroup.POST("/get_messages_statistics", statistics.GetMessagesStatistics)
|
||||||
statisticsRouterGroup.GET("/get_user_statistics", statistics.GetUserStatistics)
|
statisticsRouterGroup.POST("/get_user_statistics", statistics.GetUserStatistics)
|
||||||
statisticsRouterGroup.GET("/get_group_statistics", statistics.GetGroupStatistics)
|
statisticsRouterGroup.POST("/get_group_statistics", statistics.GetGroupStatistics)
|
||||||
statisticsRouterGroup.GET("/get_active_user", statistics.GetActiveUser)
|
statisticsRouterGroup.POST("/get_active_user", statistics.GetActiveUser)
|
||||||
statisticsRouterGroup.GET("/get_active_group", statistics.GetActiveGroup)
|
statisticsRouterGroup.POST("/get_active_group", statistics.GetActiveGroup)
|
||||||
}
|
|
||||||
organizationRouterGroup := r2.Group("/organization")
|
|
||||||
{
|
|
||||||
organizationRouterGroup.GET("/get_staffs", organization.GetStaffs)
|
|
||||||
organizationRouterGroup.GET("/get_organizations", organization.GetOrganizations)
|
|
||||||
organizationRouterGroup.GET("/get_squad", organization.GetSquads)
|
|
||||||
organizationRouterGroup.POST("/add_organization", organization.AddOrganization)
|
|
||||||
organizationRouterGroup.POST("/alter_staff", organization.AlterStaff)
|
|
||||||
organizationRouterGroup.GET("/inquire_organization", organization.InquireOrganization)
|
|
||||||
organizationRouterGroup.POST("/alter_organization", organization.AlterOrganization)
|
|
||||||
organizationRouterGroup.POST("/delete_organization", organization.DeleteOrganization)
|
|
||||||
organizationRouterGroup.POST("/get_organization_squad", organization.GetOrganizationSquads)
|
|
||||||
organizationRouterGroup.PATCH("/alter_corps_info", organization.AlterStaffsInfo)
|
|
||||||
organizationRouterGroup.POST("/add_child_org", organization.AddChildOrganization)
|
|
||||||
}
|
}
|
||||||
groupRouterGroup := r2.Group("/group")
|
groupRouterGroup := r2.Group("/group")
|
||||||
{
|
{
|
||||||
groupRouterGroup.GET("/get_group_by_id", group.GetGroupByID)
|
groupRouterGroup.POST("/get_groups", group.GetGroups)
|
||||||
groupRouterGroup.GET("/get_groups", group.GetGroups)
|
groupRouterGroup.POST("/get_group_members", group.GetGroupMembers)
|
||||||
groupRouterGroup.GET("/get_group_by_name", group.GetGroupByName)
|
|
||||||
groupRouterGroup.GET("/get_group_members", group.GetGroupMembers)
|
|
||||||
groupRouterGroup.POST("/create_group", group.CreateGroup)
|
|
||||||
groupRouterGroup.POST("/add_members", group.AddGroupMembers)
|
|
||||||
groupRouterGroup.POST("/remove_members", group.RemoveGroupMembers)
|
|
||||||
groupRouterGroup.POST("/get_members_in_group", group.GetGroupMembers)
|
|
||||||
groupRouterGroup.POST("/set_group_master", group.SetGroupOwner)
|
|
||||||
groupRouterGroup.POST("/set_group_ordinary_user", group.SetGroupOrdinaryUsers)
|
|
||||||
groupRouterGroup.POST("/alter_group_info", group.AlterGroupInfo)
|
|
||||||
}
|
}
|
||||||
userRouterGroup := r2.Group("/user")
|
userRouterGroup := r2.Group("/user")
|
||||||
{
|
{
|
||||||
userRouterGroup.POST("/resign", user.ResignUser)
|
|
||||||
userRouterGroup.GET("/get_user", user.GetUserById)
|
|
||||||
userRouterGroup.POST("/alter_user", user.AlterUser)
|
|
||||||
userRouterGroup.GET("/get_users", user.GetUsers)
|
|
||||||
userRouterGroup.POST("/add_user", user.AddUser)
|
userRouterGroup.POST("/add_user", user.AddUser)
|
||||||
userRouterGroup.POST("/unblock_user", user.UnblockUser)
|
userRouterGroup.POST("/unblock_user", user.UnblockUser)
|
||||||
userRouterGroup.POST("/block_user", user.BlockUser)
|
userRouterGroup.POST("/block_user", user.BlockUser)
|
||||||
userRouterGroup.GET("/get_block_users", user.GetBlockUsers)
|
userRouterGroup.POST("/get_block_users", user.GetBlockUsers)
|
||||||
userRouterGroup.GET("/get_block_user", user.GetBlockUserById)
|
|
||||||
userRouterGroup.POST("/delete_user", user.DeleteUser)
|
|
||||||
userRouterGroup.GET("/get_users_by_name", user.GetUsersByName)
|
|
||||||
}
|
}
|
||||||
messageCMSRouterGroup := r2.Group("/message")
|
messageCMSRouterGroup := r2.Group("/message")
|
||||||
{
|
{
|
||||||
messageCMSRouterGroup.GET("/get_chat_logs", messageCMS.GetChatLogs)
|
messageCMSRouterGroup.POST("/get_chat_logs", messageCMS.GetChatLogs)
|
||||||
messageCMSRouterGroup.POST("/broadcast_message", messageCMS.BroadcastMessage)
|
}
|
||||||
messageCMSRouterGroup.POST("/mass_send_message", messageCMS.MassSendMassage)
|
friendCMSRouterGroup := r2.Group("friend")
|
||||||
messageCMSRouterGroup.POST("/withdraw_message", messageCMS.WithdrawMessage)
|
{
|
||||||
|
friendCMSRouterGroup.POST("/get_friends", friend.GetUserFriends)
|
||||||
}
|
}
|
||||||
return baseRouter
|
return baseRouter
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,14 @@ package statistics
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pb "Open_IM/pkg/proto/statistics"
|
admin "Open_IM/pkg/proto/admin_cms"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -20,38 +19,40 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
var (
|
var (
|
||||||
req cms_api_struct.GetMessageStatisticsRequest
|
req cms_api_struct.GetMessageStatisticsRequest
|
||||||
resp cms_api_struct.GetMessageStatisticsResponse
|
resp cms_api_struct.GetMessageStatisticsResponse
|
||||||
reqPb pb.GetMessageStatisticsReq
|
reqPb admin.GetMessageStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetMessageStatistics(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetMessageStatistics(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetMessageStatistics failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetMessageStatistics failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// utils.CopyStructFields(&resp, respPb)
|
|
||||||
resp.GroupMessageNum = int(respPb.GroupMessageNum)
|
resp.GroupMessageNum = int(respPb.GroupMessageNum)
|
||||||
resp.PrivateMessageNum = int(respPb.PrivateMessageNum)
|
resp.PrivateMessageNum = int(respPb.PrivateMessageNum)
|
||||||
for _, v := range respPb.PrivateMessageNumList {
|
for _, v := range respPb.PrivateMessageNumList {
|
||||||
resp.PrivateMessageNumList = append(resp.PrivateMessageNumList, struct {
|
resp.PrivateMessageNumList = append(resp.PrivateMessageNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
MessageNum int "json:\"message_num\""
|
MessageNum int "json:\"messageNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
MessageNum: int(v.Num),
|
MessageNum: int(v.Num),
|
||||||
@ -60,53 +61,54 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
for _, v := range respPb.GroupMessageNumList {
|
for _, v := range respPb.GroupMessageNumList {
|
||||||
resp.GroupMessageNumList = append(resp.GroupMessageNumList, struct {
|
resp.GroupMessageNumList = append(resp.GroupMessageNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
MessageNum int "json:\"message_num\""
|
MessageNum int "json:\"messageNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
MessageNum: int(v.Num),
|
MessageNum: int(v.Num),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserStatistics(c *gin.Context) {
|
func GetUserStatistics(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetUserStatisticsRequest
|
req cms_api_struct.GetUserStatisticsRequest
|
||||||
resp cms_api_struct.GetUserStatisticsResponse
|
resp cms_api_struct.GetUserStatisticsResponse
|
||||||
reqPb pb.GetUserStatisticsReq
|
reqPb admin.GetUserStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetUserStatistics(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetUserStatistics(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error(), reqPb.String())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// utils.CopyStructFields(&resp, respPb)
|
|
||||||
resp.ActiveUserNum = int(respPb.ActiveUserNum)
|
resp.ActiveUserNum = int(respPb.ActiveUserNum)
|
||||||
resp.IncreaseUserNum = int(respPb.IncreaseUserNum)
|
resp.IncreaseUserNum = int(respPb.IncreaseUserNum)
|
||||||
resp.TotalUserNum = int(respPb.TotalUserNum)
|
resp.TotalUserNum = int(respPb.TotalUserNum)
|
||||||
for _, v := range respPb.ActiveUserNumList {
|
for _, v := range respPb.ActiveUserNumList {
|
||||||
resp.ActiveUserNumList = append(resp.ActiveUserNumList, struct {
|
resp.ActiveUserNumList = append(resp.ActiveUserNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
ActiveUserNum int "json:\"active_user_num\""
|
ActiveUserNum int "json:\"activeUserNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
ActiveUserNum: int(v.Num),
|
ActiveUserNum: int(v.Num),
|
||||||
@ -115,7 +117,7 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
for _, v := range respPb.IncreaseUserNumList {
|
for _, v := range respPb.IncreaseUserNumList {
|
||||||
resp.IncreaseUserNumList = append(resp.IncreaseUserNumList, struct {
|
resp.IncreaseUserNumList = append(resp.IncreaseUserNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
IncreaseUserNum int "json:\"increase_user_num\""
|
IncreaseUserNum int "json:\"increaseUserNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
IncreaseUserNum: int(v.Num),
|
IncreaseUserNum: int(v.Num),
|
||||||
@ -124,43 +126,45 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
for _, v := range respPb.TotalUserNumList {
|
for _, v := range respPb.TotalUserNumList {
|
||||||
resp.TotalUserNumList = append(resp.TotalUserNumList, struct {
|
resp.TotalUserNumList = append(resp.TotalUserNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
TotalUserNum int "json:\"total_user_num\""
|
TotalUserNum int "json:\"totalUserNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
TotalUserNum: int(v.Num),
|
TotalUserNum: int(v.Num),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupStatistics(c *gin.Context) {
|
func GetGroupStatistics(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetGroupStatisticsRequest
|
req cms_api_struct.GetGroupStatisticsRequest
|
||||||
resp cms_api_struct.GetGroupStatisticsResponse
|
resp cms_api_struct.GetGroupStatisticsResponse
|
||||||
reqPb pb.GetGroupStatisticsReq
|
reqPb admin.GetGroupStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetGroupStatistics(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetGroupStatistics(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// utils.CopyStructFields(&resp, respPb)
|
// utils.CopyStructFields(&resp, respPb)
|
||||||
@ -170,7 +174,7 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
resp.IncreaseGroupNumList = append(resp.IncreaseGroupNumList,
|
resp.IncreaseGroupNumList = append(resp.IncreaseGroupNumList,
|
||||||
struct {
|
struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
IncreaseGroupNum int "json:\"increase_group_num\""
|
IncreaseGroupNum int "json:\"increaseGroupNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
IncreaseGroupNum: int(v.Num),
|
IncreaseGroupNum: int(v.Num),
|
||||||
@ -180,7 +184,7 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
resp.TotalGroupNumList = append(resp.TotalGroupNumList,
|
resp.TotalGroupNumList = append(resp.TotalGroupNumList,
|
||||||
struct {
|
struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
TotalGroupNum int "json:\"total_group_num\""
|
TotalGroupNum int "json:\"totalGroupNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
TotalGroupNum: int(v.Num),
|
TotalGroupNum: int(v.Num),
|
||||||
@ -188,77 +192,81 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetActiveUser(c *gin.Context) {
|
func GetActiveUser(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetActiveUserRequest
|
req cms_api_struct.GetActiveUserRequest
|
||||||
resp cms_api_struct.GetActiveUserResponse
|
resp cms_api_struct.GetActiveUserResponse
|
||||||
reqPb pb.GetActiveUserReq
|
reqPb admin.GetActiveUserReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetActiveUser(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetActiveUser(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveUser failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveUser failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetActiveGroup(c *gin.Context) {
|
func GetActiveGroup(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetActiveGroupRequest
|
req cms_api_struct.GetActiveGroupRequest
|
||||||
resp cms_api_struct.GetActiveGroupResponse
|
resp cms_api_struct.GetActiveGroupResponse
|
||||||
reqPb pb.GetActiveGroupReq
|
reqPb admin.GetActiveGroupReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetActiveGroup(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetActiveGroup(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, group := range respPb.Groups {
|
for _, group := range respPb.Groups {
|
||||||
resp.ActiveGroupList = append(resp.ActiveGroupList, struct {
|
resp.ActiveGroupList = append(resp.ActiveGroupList, struct {
|
||||||
GroupName string "json:\"group_name\""
|
GroupName string "json:\"groupName\""
|
||||||
GroupId string "json:\"group_id\""
|
GroupId string "json:\"groupID\""
|
||||||
MessageNum int "json:\"message_num\""
|
MessageNum int "json:\"messageNum\""
|
||||||
}{
|
}{
|
||||||
GroupName: group.GroupName,
|
GroupName: group.GroupName,
|
||||||
GroupId: group.GroupId,
|
GroupId: group.GroupId,
|
||||||
@ -266,5 +274,5 @@ func GetActiveGroup(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
@ -3,196 +3,18 @@ package user
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||||
pb "Open_IM/pkg/proto/user"
|
pb "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetUserById(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetUserRequest
|
|
||||||
resp cms_api_struct.GetUserResponse
|
|
||||||
reqPb pb.GetUserByIdReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetUserById(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if respPb.User.UserId == "" {
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(&resp, respPb.User)
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUsersByName(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetUsersByNameRequest
|
|
||||||
resp cms_api_struct.GetUsersByNameResponse
|
|
||||||
reqPb pb.GetUsersByNameReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.UserName = req.UserName
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{
|
|
||||||
PageNumber: int32(req.PageNumber),
|
|
||||||
ShowNumber: int32(req.ShowNumber),
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetUsersByName(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(&resp.Users, respPb.Users)
|
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
|
||||||
resp.UserNums = respPb.UserNums
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUsers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetUsersRequest
|
|
||||||
resp cms_api_struct.GetUsersResponse
|
|
||||||
reqPb pb.GetUsersReq
|
|
||||||
)
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError("0", "ShouldBindQuery failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(&resp.Users, respPb.User)
|
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
|
||||||
resp.UserNums = respPb.UserNums
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResignUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.ResignUserRequest
|
|
||||||
resp cms_api_struct.ResignUserResponse
|
|
||||||
reqPb pb.ResignUserReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
_, err := client.ResignUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
|
||||||
}
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.AlterUserRequest
|
|
||||||
resp cms_api_struct.AlterUserResponse
|
|
||||||
reqPb pb.AlterUserReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
_, err := client.AlterUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, "microserver failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddUser(c *gin.Context) {
|
func AddUser(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.AddUserRequest
|
req cms_api_struct.AddUserRequest
|
||||||
@ -200,7 +22,7 @@ func AddUser(c *gin.Context) {
|
|||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -214,24 +36,23 @@ func AddUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.AddUser(context.Background(), &reqPb)
|
respPb, err := client.AddUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func BlockUser(c *gin.Context) {
|
func BlockUser(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.BlockUserRequest
|
req cms_api_struct.BlockUserRequest
|
||||||
resp cms_api_struct.BlockUserResponse
|
|
||||||
reqPb pb.BlockUserReq
|
reqPb pb.BlockUserReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
fmt.Println(err)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -245,13 +66,13 @@ func BlockUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
fmt.Println(reqPb)
|
respPb, err := client.BlockUser(context.Background(), &reqPb)
|
||||||
_, err := client.BlockUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnblockUser(c *gin.Context) {
|
func UnblockUser(c *gin.Context) {
|
||||||
@ -260,9 +81,9 @@ func UnblockUser(c *gin.Context) {
|
|||||||
resp cms_api_struct.UnBlockUserResponse
|
resp cms_api_struct.UnBlockUserResponse
|
||||||
reqPb pb.UnBlockUserReq
|
reqPb pb.UnBlockUserReq
|
||||||
)
|
)
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -276,13 +97,14 @@ func UnblockUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.UnBlockUser(context.Background(), &reqPb)
|
respPb, err := client.UnBlockUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBlockUsers(c *gin.Context) {
|
func GetBlockUsers(c *gin.Context) {
|
||||||
@ -293,9 +115,9 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
respPb *pb.GetBlockUsersResp
|
respPb *pb.GetBlockUsersResp
|
||||||
)
|
)
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -313,21 +135,18 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetBlockUsers rpc", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetBlockUsers rpc", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range respPb.BlockUsers {
|
for _, v := range respPb.BlockUsers {
|
||||||
resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{
|
resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{
|
||||||
UserResponse: cms_api_struct.UserResponse{
|
UserResponse: cms_api_struct.UserResponse{
|
||||||
UserId: v.User.UserId,
|
UserID: v.UserInfo.UserID,
|
||||||
ProfilePhoto: v.User.ProfilePhoto,
|
FaceURL: v.UserInfo.FaceURL,
|
||||||
Nickname: v.User.Nickname,
|
Nickname: v.UserInfo.Nickname,
|
||||||
IsBlock: v.User.IsBlock,
|
PhoneNumber: v.UserInfo.PhoneNumber,
|
||||||
Birth: v.User.Birth,
|
Email: v.UserInfo.Email,
|
||||||
PhoneNumber: v.User.PhoneNumber,
|
Gender: int(v.UserInfo.Gender),
|
||||||
Email: v.User.Email,
|
|
||||||
Gender: int(v.User.Gender),
|
|
||||||
CreateTime: v.User.CreateTime,
|
|
||||||
},
|
},
|
||||||
BeginDisableTime: v.BeginDisableTime,
|
BeginDisableTime: v.BeginDisableTime,
|
||||||
EndDisableTime: v.EndDisableTime,
|
EndDisableTime: v.EndDisableTime,
|
||||||
@ -337,70 +156,5 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.UserNums = respPb.UserNums
|
resp.UserNums = respPb.UserNums
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
|
||||||
|
|
||||||
func GetBlockUserById(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetBlockUserRequest
|
|
||||||
resp cms_api_struct.GetBlockUserResponse
|
|
||||||
reqPb pb.GetBlockUserByIdReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserId = req.UserId
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetBlockUserById(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, "GetBlockUserById rpc failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
|
|
||||||
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
|
|
||||||
utils.CopyStructFields(&resp, respPb.BlockUser.User)
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.DeleteUserRequest
|
|
||||||
reqPb pb.DeleteUserReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserId = req.UserId
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
_, err := client.DeleteUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, "DeleteUser rpc failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
}
|
||||||
|
85
internal/demo/register/check_login.go
Normal file
85
internal/demo/register/check_login.go
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package register
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CheckLoginLimitReq struct {
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CheckLoginLimitResp struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckLoginLimit(c *gin.Context) {
|
||||||
|
req := CheckLoginLimitReq{}
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ip := c.Request.Header.Get("X-Forward-For")
|
||||||
|
if ip == "" {
|
||||||
|
ip = c.ClientIP()
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "IP: ", ip)
|
||||||
|
user, err := imdb.GetUserIPLimit(req.UserID)
|
||||||
|
if err != nil && !errors.Is(gorm.ErrRecordNotFound, err) {
|
||||||
|
errMsg := req.OperationID + " imdb.GetUserByUserID failed " + err.Error() + req.UserID
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := imdb.UpdateIpReocord(req.UserID, ip); err != nil {
|
||||||
|
log.NewError(req.OperationID, err.Error(), req.UserID, ip)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var Limited bool
|
||||||
|
var LimitError error
|
||||||
|
Limited, LimitError = imdb.IsLimitLoginIp(ip)
|
||||||
|
if LimitError != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if Limited {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "ip limited Login"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Limited, LimitError = imdb.IsLimitUserLoginIp(user.UserID, ip)
|
||||||
|
if LimitError != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if Limited {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "user ip limited Login"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Limited, LimitError = imdb.UserIsBlock(user.UserID)
|
||||||
|
if LimitError != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, user.UserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if Limited {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "user is block"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||||
|
}
|
@ -6,9 +6,10 @@ import (
|
|||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InvitationCode struct {
|
type InvitationCode struct {
|
||||||
@ -87,7 +88,8 @@ type GetInvitationCodesReq struct {
|
|||||||
|
|
||||||
type GetInvitationCodesResp struct {
|
type GetInvitationCodesResp struct {
|
||||||
apiStruct.Pagination
|
apiStruct.Pagination
|
||||||
Codes []InvitationCode `json:"codes"`
|
Codes []InvitationCode `json:"codes"`
|
||||||
|
CodeNums int64 `json:"codeNums"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetInvitationCodes(c *gin.Context) {
|
func GetInvitationCodes(c *gin.Context) {
|
||||||
@ -98,7 +100,7 @@ func GetInvitationCodes(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||||
codes, err := imdb.GetInvitationCodes(req.ShowNumber, req.PageNumber, req.Status)
|
codes, count, err := imdb.GetInvitationCodes(req.ShowNumber, req.PageNumber, req.Status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.ShowNumber, req.PageNumber, req.Status)
|
log.NewError(req.OperationID, "GetInvitationCode failed", req.ShowNumber, req.PageNumber, req.Status)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
||||||
@ -115,6 +117,7 @@ func GetInvitationCodes(c *gin.Context) {
|
|||||||
Status: v.Status,
|
Status: v.Status,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
resp.CodeNums = count
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ import (
|
|||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
//"github.com/jinzhu/gorm"
|
//"github.com/jinzhu/gorm"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@ -141,7 +143,7 @@ func QueryUserIDLimitLogin(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": gin.H{"limit": resp}})
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddUserIPLimitLoginReq struct {
|
type AddUserIPLimitLoginReq struct {
|
||||||
@ -163,8 +165,8 @@ func AddUserIPLimitLogin(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||||
userIp := db.UserIpLimit{UserID: req.UserID, Ip: req.IP}
|
userIp := db.UserIpLimit{UserID: req.UserID, Ip: req.IP}
|
||||||
err := imdb.UpdateUserInfo(db.User{
|
err := imdb.UpdateUserInfo(db.User{
|
||||||
UserID: req.UserID,
|
UserID: req.UserID,
|
||||||
LoginLimit: 1,
|
// LoginLimit: 1,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
http2 "Open_IM/pkg/common/http"
|
http2 "Open_IM/pkg/common/http"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/common/token_verify"
|
||||||
pbFriend "Open_IM/pkg/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -32,6 +33,8 @@ type ParamsSetPassword struct {
|
|||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
AreaCode string `json:"areaCode"`
|
AreaCode string `json:"areaCode"`
|
||||||
InvitationCode string `json:"invitationCode"`
|
InvitationCode string `json:"invitationCode"`
|
||||||
|
Gender int32 `json:"gender"`
|
||||||
|
Birth int32 `json:"birth"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetPassword(c *gin.Context) {
|
func SetPassword(c *gin.Context) {
|
||||||
@ -41,28 +44,34 @@ func SetPassword(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ip := c.Request.Header.Get("X-Forward-For")
|
ip := c.Request.Header.Get("X-Forward-For")
|
||||||
if ip == "" {
|
if ip == "" {
|
||||||
ip = c.ClientIP()
|
ip = c.ClientIP()
|
||||||
}
|
}
|
||||||
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "ip:", ip)
|
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "ip:", ip)
|
||||||
Limited, LimitError := imdb.IsLimitRegisterIp(ip)
|
|
||||||
if LimitError != nil {
|
|
||||||
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if Limited {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.RegisterLimit, "errMsg": "limited"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ok, opUserID, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), params.OperationID)
|
||||||
|
if !ok || !utils.IsContain(opUserID, config.Config.Manager.AppManagerUid) {
|
||||||
|
Limited, LimitError := imdb.IsLimitRegisterIp(ip)
|
||||||
|
if LimitError != nil {
|
||||||
|
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if Limited {
|
||||||
|
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "is limited", ip, "params:", params)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.RegisterLimit, "errMsg": "limited"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
openIMRegisterReq := api.UserRegisterReq{}
|
||||||
var account string
|
var account string
|
||||||
if params.Email != "" {
|
if params.Email != "" {
|
||||||
account = params.Email
|
account = params.Email
|
||||||
|
openIMRegisterReq.Email = params.Email
|
||||||
} else if params.PhoneNumber != "" {
|
} else if params.PhoneNumber != "" {
|
||||||
account = params.PhoneNumber
|
account = params.PhoneNumber
|
||||||
|
openIMRegisterReq.PhoneNumber = params.PhoneNumber
|
||||||
} else {
|
} else {
|
||||||
account = params.UserID
|
account = params.UserID
|
||||||
}
|
}
|
||||||
@ -84,7 +93,7 @@ func SetPassword(c *gin.Context) {
|
|||||||
if config.Config.Demo.NeedInvitationCode && params.InvitationCode != "" {
|
if config.Config.Demo.NeedInvitationCode && params.InvitationCode != "" {
|
||||||
err := imdb.CheckInvitationCode(params.InvitationCode)
|
err := imdb.CheckInvitationCode(params.InvitationCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "InvitationCode error"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,18 +108,15 @@ func SetPassword(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
userID = params.UserID
|
userID = params.UserID
|
||||||
}
|
}
|
||||||
|
|
||||||
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
||||||
openIMRegisterReq := api.UserRegisterReq{}
|
|
||||||
openIMRegisterReq.OperationID = params.OperationID
|
openIMRegisterReq.OperationID = params.OperationID
|
||||||
openIMRegisterReq.Platform = params.Platform
|
openIMRegisterReq.Platform = params.Platform
|
||||||
openIMRegisterReq.UserID = userID
|
openIMRegisterReq.UserID = userID
|
||||||
openIMRegisterReq.Nickname = params.Nickname
|
openIMRegisterReq.Nickname = params.Nickname
|
||||||
openIMRegisterReq.Secret = config.Config.Secret
|
openIMRegisterReq.Secret = config.Config.Secret
|
||||||
openIMRegisterReq.FaceURL = params.FaceURL
|
openIMRegisterReq.FaceURL = params.FaceURL
|
||||||
openIMRegisterReq.CreateIp = ip
|
openIMRegisterReq.Gender = params.Gender
|
||||||
openIMRegisterReq.LastLoginIp = ip
|
openIMRegisterReq.Birth = uint32(params.Birth)
|
||||||
openIMRegisterReq.InvitationCode = params.InvitationCode
|
|
||||||
openIMRegisterResp := api.UserRegisterResp{}
|
openIMRegisterResp := api.UserRegisterResp{}
|
||||||
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "register req:", openIMRegisterReq)
|
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "register req:", openIMRegisterReq)
|
||||||
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
||||||
@ -124,14 +130,10 @@ func SetPassword(c *gin.Context) {
|
|||||||
log.NewError(params.OperationID, "request openIM register error", account, "err", "resp: ", openIMRegisterResp.ErrCode)
|
log.NewError(params.OperationID, "request openIM register error", account, "err", "resp: ", openIMRegisterResp.ErrCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register limit"})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if openIMRegisterResp.ErrCode == constant.RegisterLimit {
|
if openIMRegisterResp.ErrCode != 0 {
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterLimit, "errMsg": "用户注册被限制"})
|
|
||||||
return
|
|
||||||
} else if openIMRegisterResp.ErrCode == constant.InvitationError {
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -150,8 +152,11 @@ func SetPassword(c *gin.Context) {
|
|||||||
imdb.FinishInvitationCode(params.InvitationCode, userID)
|
imdb.FinishInvitationCode(params.InvitationCode, userID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := imdb.InsertIpRecord(userID, ip); err != nil {
|
||||||
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), userID, ip, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
log.Info(params.OperationID, "end setuserInfo", account, params.Password)
|
||||||
// demo onboarding
|
// demo onboarding
|
||||||
if params.UserID == "" && config.Config.Demo.OnboardProcess {
|
if params.UserID == "" && config.Config.Demo.OnboardProcess {
|
||||||
select {
|
select {
|
||||||
@ -168,6 +173,7 @@ func SetPassword(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// register add friend
|
||||||
select {
|
select {
|
||||||
case ChImportFriend <- &pbFriend.ImportFriendReq{
|
case ChImportFriend <- &pbFriend.ImportFriendReq{
|
||||||
OperationID: params.OperationID,
|
OperationID: params.OperationID,
|
||||||
|
@ -102,7 +102,10 @@ type Options struct {
|
|||||||
} `json:"HW"`
|
} `json:"HW"`
|
||||||
XM struct {
|
XM struct {
|
||||||
ChannelID string `json:"/extra.channel_id"`
|
ChannelID string `json:"/extra.channel_id"`
|
||||||
} `json:""`
|
} `json:"XM"`
|
||||||
|
VV struct {
|
||||||
|
Classification int `json:"/classification"`
|
||||||
|
} `json:"VV"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PushResp struct {
|
type PushResp struct {
|
||||||
@ -156,6 +159,11 @@ func (g *Getui) Push(userIDList []string, title, detailContent, operationID stri
|
|||||||
XM: struct {
|
XM: struct {
|
||||||
ChannelID string `json:"/extra.channel_id"`
|
ChannelID string `json:"/extra.channel_id"`
|
||||||
}{ChannelID: "high_system"},
|
}{ChannelID: "high_system"},
|
||||||
|
VV: struct {
|
||||||
|
Classification int "json:\"/classification\""
|
||||||
|
}{
|
||||||
|
Classification: 1,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
pushResp := PushResp{}
|
pushResp := PushResp{}
|
||||||
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
||||||
|
@ -78,10 +78,14 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if pushMsg.MsgData.ContentType == constant.SignalingNotification {
|
if pushMsg.MsgData.ContentType == constant.SignalingNotification {
|
||||||
if err := db.DB.HandleSignalInfo(pushMsg.OperationID, pushMsg.MsgData); err != nil {
|
isSend, err := db.DB.HandleSignalInfo(pushMsg.OperationID, pushMsg.MsgData, pushMsg.PushToUserID)
|
||||||
|
if err != nil {
|
||||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), err.Error(), pushMsg.MsgData)
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), err.Error(), pushMsg.MsgData)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !isSend {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var title, detailContent string
|
var title, detailContent string
|
||||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{})
|
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{})
|
||||||
|
@ -3,8 +3,8 @@ package admin_cms
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/db"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
@ -12,11 +12,15 @@ import (
|
|||||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type adminCMSServer struct {
|
type adminCMSServer struct {
|
||||||
@ -81,34 +85,48 @@ func (s *adminCMSServer) Run() {
|
|||||||
|
|
||||||
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.AdminLoginResp{}
|
resp := &pbAdminCMS.AdminLoginResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
for i, adminID := range config.Config.Manager.AppManagerUid {
|
for i, adminID := range config.Config.Manager.AppManagerUid {
|
||||||
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
|
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
|
||||||
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
|
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
||||||
return resp, openIMHttp.WrapError(constant.ErrTokenUnknown)
|
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
||||||
resp.Token = token
|
resp.Token = token
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.Token == "" {
|
if resp.Token == "" {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
||||||
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
|
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrTokenMalformed.ErrMsg
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
admin, err := imdb.GetUserByUserID(req.AdminID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed", req.AdminID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrTokenMalformed.ErrMsg
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.UserName = admin.Nickname
|
||||||
|
resp.FaceURL = admin.FaceURL
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) AddUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.AddUserRegisterAddFriendIDListReq) (*pbAdminCMS.AddUserRegisterAddFriendIDListResp, error) {
|
func (s *adminCMSServer) AddUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.AddUserRegisterAddFriendIDListReq) (*pbAdminCMS.AddUserRegisterAddFriendIDListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.AddUserRegisterAddFriendIDListResp{}
|
resp := &pbAdminCMS.AddUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
if err := imdb.AddUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
if err := imdb.AddUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -116,16 +134,20 @@ func (s *adminCMSServer) AddUserRegisterAddFriendIDList(_ context.Context, req *
|
|||||||
|
|
||||||
func (s *adminCMSServer) ReduceUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.ReduceUserRegisterAddFriendIDListReq) (*pbAdminCMS.ReduceUserRegisterAddFriendIDListResp, error) {
|
func (s *adminCMSServer) ReduceUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.ReduceUserRegisterAddFriendIDListReq) (*pbAdminCMS.ReduceUserRegisterAddFriendIDListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.ReduceUserRegisterAddFriendIDListResp{}
|
resp := &pbAdminCMS.ReduceUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
if req.Operation == 0 {
|
if req.Operation == 0 {
|
||||||
if err := imdb.ReduceUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
if err := imdb.ReduceUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := imdb.DeleteAllRegisterAddFriendIDList(); err != nil {
|
if err := imdb.DeleteAllRegisterAddFriendIDList(); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
@ -134,16 +156,19 @@ func (s *adminCMSServer) ReduceUserRegisterAddFriendIDList(_ context.Context, re
|
|||||||
|
|
||||||
func (s *adminCMSServer) GetUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.GetUserRegisterAddFriendIDListReq) (*pbAdminCMS.GetUserRegisterAddFriendIDListResp, error) {
|
func (s *adminCMSServer) GetUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.GetUserRegisterAddFriendIDListReq) (*pbAdminCMS.GetUserRegisterAddFriendIDListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.GetUserRegisterAddFriendIDListResp{UserInfoList: []*server_api_params.UserInfo{}}
|
resp := &pbAdminCMS.GetUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
userIDList, err := imdb.GetRegisterAddFriendList(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
userIDList, err := imdb.GetRegisterAddFriendList(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
userList, err := imdb.GetUsersByUserIDList(userIDList)
|
userList, err := imdb.GetUsersByUserIDList(userIDList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userIDList)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userList, userIDList)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userList, userIDList)
|
||||||
resp.Pagination = &server_api_params.ResponsePagination{
|
resp.Pagination = &server_api_params.ResponsePagination{
|
||||||
@ -154,3 +179,500 @@ func (s *adminCMSServer) GetUserRegisterAddFriendIDList(_ context.Context, req *
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetChatLogs(_ context.Context, req *pbAdminCMS.GetChatLogsReq) (*pbAdminCMS.GetChatLogsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetChatLogs", req.String())
|
||||||
|
resp := &pbAdminCMS.GetChatLogsResp{CommonResp: &pbAdminCMS.CommonResp{}, Pagination: &server_api_params.ResponsePagination{}}
|
||||||
|
time, err := utils.TimeStringToTime(req.SendTime)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrArgs.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
chatLog := db.ChatLog{
|
||||||
|
Content: req.Content,
|
||||||
|
SendTime: time,
|
||||||
|
ContentType: req.ContentType,
|
||||||
|
SessionType: req.SessionType,
|
||||||
|
RecvID: req.RecvID,
|
||||||
|
SendID: req.SendID,
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
|
||||||
|
nums, err := imdb.GetChatLogCount(chatLog)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLogCount", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.ChatLogsNum = int32(nums)
|
||||||
|
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
for _, chatLog := range chatLogs {
|
||||||
|
pbChatLog := &pbAdminCMS.ChatLog{}
|
||||||
|
utils.CopyStructFields(pbChatLog, chatLog)
|
||||||
|
pbChatLog.SendTime = chatLog.SendTime.Unix()
|
||||||
|
pbChatLog.CreateTime = chatLog.CreateTime.Unix()
|
||||||
|
if chatLog.SenderNickname == "" {
|
||||||
|
sendUser, err := imdb.GetUserByUserID(chatLog.SendID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pbChatLog.SenderNickname = sendUser.Nickname
|
||||||
|
}
|
||||||
|
switch chatLog.SessionType {
|
||||||
|
case constant.SingleChatType:
|
||||||
|
recvUser, err := imdb.GetUserByUserID(chatLog.RecvID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pbChatLog.SenderNickname = recvUser.Nickname
|
||||||
|
|
||||||
|
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||||
|
group, err := imdb.GetGroupInfoByGroupID(chatLog.RecvID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById failed")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pbChatLog.RecvID = group.GroupID
|
||||||
|
pbChatLog.GroupName = group.GroupName
|
||||||
|
}
|
||||||
|
resp.ChatLogs = append(resp.ChatLogs, pbChatLog)
|
||||||
|
}
|
||||||
|
resp.Pagination = &server_api_params.ResponsePagination{
|
||||||
|
CurrentPage: req.Pagination.PageNumber,
|
||||||
|
ShowNumber: req.Pagination.ShowNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp output: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetActiveGroup(_ context.Context, req *pbAdminCMS.GetActiveGroupReq) (*pbAdminCMS.GetActiveGroupResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
|
||||||
|
resp := &pbAdminCMS.GetActiveGroupResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||||
|
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
for _, activeGroup := range activeGroups {
|
||||||
|
resp.Groups = append(resp.Groups,
|
||||||
|
&pbAdminCMS.GroupResp{
|
||||||
|
GroupName: activeGroup.Name,
|
||||||
|
GroupId: activeGroup.Id,
|
||||||
|
MessageNum: int32(activeGroup.MessageNum),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetActiveUser(_ context.Context, req *pbAdminCMS.GetActiveUserReq) (*pbAdminCMS.GetActiveUserResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
|
resp := &pbAdminCMS.GetActiveUserResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||||
|
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
for _, activeUser := range activeUsers {
|
||||||
|
resp.Users = append(resp.Users,
|
||||||
|
&pbAdminCMS.UserResp{
|
||||||
|
UserID: activeUser.ID,
|
||||||
|
NickName: activeUser.Name,
|
||||||
|
MessageNum: int32(activeUser.MessageNum),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseTimeFromTo(from, to string) (time.Time, time.Time, error) {
|
||||||
|
var fromTime time.Time
|
||||||
|
var toTime time.Time
|
||||||
|
fromTime, err := utils.TimeStringToTime(from)
|
||||||
|
if err != nil {
|
||||||
|
return fromTime, toTime, err
|
||||||
|
}
|
||||||
|
toTime, err = utils.TimeStringToTime(to)
|
||||||
|
if err != nil {
|
||||||
|
return fromTime, toTime, err
|
||||||
|
}
|
||||||
|
return fromTime, toTime, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isInOneMonth(from, to time.Time) bool {
|
||||||
|
return from.Month() == to.Month() && from.Year() == to.Year()
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRangeDate(from, to time.Time) [][2]time.Time {
|
||||||
|
interval := to.Sub(from)
|
||||||
|
var times [][2]time.Time
|
||||||
|
switch {
|
||||||
|
// today
|
||||||
|
case interval == 0:
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
from, from.Add(time.Hour * 24),
|
||||||
|
})
|
||||||
|
// days
|
||||||
|
case isInOneMonth(from, to):
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
||||||
|
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
||||||
|
if toTime.After(to.Add(time.Hour * 24)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// month
|
||||||
|
case !isInOneMonth(from, to):
|
||||||
|
if to.Sub(from) < time.Hour*24*30 {
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
||||||
|
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
||||||
|
if toTime.After(to.Add(time.Hour * 24)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
if i == 0 {
|
||||||
|
fromTime := from
|
||||||
|
toTime := getFirstDateOfNextNMonth(fromTime, 1)
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fromTime := getFirstDateOfNextNMonth(from, i)
|
||||||
|
toTime := getFirstDateOfNextNMonth(fromTime, 1)
|
||||||
|
if toTime.After(to) {
|
||||||
|
toTime = to
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return times
|
||||||
|
}
|
||||||
|
|
||||||
|
func getFirstDateOfNextNMonth(currentTime time.Time, n int) time.Time {
|
||||||
|
lastOfMonth := time.Date(currentTime.Year(), currentTime.Month(), 1, 0, 0, 0, 0, currentTime.Location()).AddDate(0, n, 0)
|
||||||
|
return lastOfMonth
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetGroupStatistics(_ context.Context, req *pbAdminCMS.GetGroupStatisticsReq) (*pbAdminCMS.GetGroupStatisticsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
|
resp := &pbAdminCMS.GetGroupStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
totalGroupNum, err := imdb.GetTotalGroupNum()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.IncreaseGroupNum = increaseGroupNum
|
||||||
|
resp.TotalGroupNum = totalGroupNum
|
||||||
|
times := GetRangeDate(fromTime, toTime)
|
||||||
|
log.NewDebug(req.OperationID, "times:", times)
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
resp.IncreaseGroupNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
resp.TotalGroupNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
wg.Add(len(times))
|
||||||
|
for i, v := range times {
|
||||||
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
|
defer wg.Done()
|
||||||
|
num, err := imdb.GetIncreaseGroupNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.IncreaseGroupNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
num, err = imdb.GetGroupNum(v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.TotalGroupNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
}(wg, i, v)
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetMessageStatistics(_ context.Context, req *pbAdminCMS.GetMessageStatisticsReq) (*pbAdminCMS.GetMessageStatisticsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
|
resp := &pbAdminCMS.GetMessageStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
privateMessageNum, err := imdb.GetPrivateMessageNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetPrivateMessageNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
groupMessageNum, err := imdb.GetGroupMessageNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
|
||||||
|
resp.PrivateMessageNum = privateMessageNum
|
||||||
|
resp.GroupMessageNum = groupMessageNum
|
||||||
|
times := GetRangeDate(fromTime, toTime)
|
||||||
|
resp.GroupMessageNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
resp.PrivateMessageNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
wg.Add(len(times))
|
||||||
|
for i, v := range times {
|
||||||
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
|
num, err := imdb.GetPrivateMessageNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.PrivateMessageNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
num, err = imdb.GetGroupMessageNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.GroupMessageNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
}(wg, i, v)
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetUserStatistics(_ context.Context, req *pbAdminCMS.GetUserStatisticsReq) (*pbAdminCMS.GetUserStatisticsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp := &pbAdminCMS.GetUserStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
activeUserNum, err := imdb.GetActiveUserNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUserNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
increaseUserNum, err := imdb.GetIncreaseUserNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
totalUserNum, err := imdb.GetTotalUserNum()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.ActiveUserNum = activeUserNum
|
||||||
|
resp.TotalUserNum = totalUserNum
|
||||||
|
resp.IncreaseUserNum = increaseUserNum
|
||||||
|
times := GetRangeDate(fromTime, toTime)
|
||||||
|
resp.TotalUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
resp.ActiveUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
resp.IncreaseUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
wg.Add(len(times))
|
||||||
|
for i, v := range times {
|
||||||
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
|
defer wg.Done()
|
||||||
|
num, err := imdb.GetActiveUserNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.ActiveUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
|
||||||
|
num, err = imdb.GetTotalUserNumByDate(v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNumByDate", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.TotalUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
num, err = imdb.GetIncreaseUserNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.IncreaseUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
}(wg, i, v)
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetUserFriends(_ context.Context, req *pbAdminCMS.GetUserFriendsReq) (*pbAdminCMS.GetUserFriendsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp := &pbAdminCMS.GetUserFriendsResp{CommonResp: &pbAdminCMS.CommonResp{}, Pagination: &server_api_params.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber}}
|
||||||
|
var friendList []*imdb.FriendUser
|
||||||
|
var err error
|
||||||
|
if req.FriendUserID != "" {
|
||||||
|
friend, err := imdb.GetFriendByIDCMS(req.UserID, req.FriendUserID)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err, req.UserID, req.FriendUserID)
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID, req.FriendUserID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
friendList = append(friendList, friend)
|
||||||
|
resp.FriendNums = 1
|
||||||
|
} else {
|
||||||
|
var count int64
|
||||||
|
friendList, count, err = imdb.GetUserFriendsCMS(req.UserID, req.FriendUserName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID, req.FriendUserName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.FriendNums = int32(count)
|
||||||
|
}
|
||||||
|
for _, v := range friendList {
|
||||||
|
friendInfo := &server_api_params.FriendInfo{}
|
||||||
|
userInfo := &server_api_params.UserInfo{UserID: v.FriendUserID, Nickname: v.Nickname}
|
||||||
|
utils.CopyStructFields(friendInfo, v)
|
||||||
|
friendInfo.FriendUser = userInfo
|
||||||
|
resp.FriendInfoList = append(resp.FriendInfoList, friendInfo)
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GenerateInvitationCode(_ context.Context, req *pbAdminCMS.GenerateInvitationCodeReq) (*pbAdminCMS.GenerateInvitationCodeResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetInvitationCodes(_ context.Context, req *pbAdminCMS.GetInvitationCodesReq) (*pbAdminCMS.GetInvitationCodesResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) QueryIPRegister(_ context.Context, req *pbAdminCMS.QueryIPRegisterReq) (*pbAdminCMS.QueryIPRegisterResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) AddIPLimit(_ context.Context, req *pbAdminCMS.AddIPLimitReq) (*pbAdminCMS.AddIPLimitResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) RemoveIPLimit(_ context.Context, req *pbAdminCMS.RemoveIPLimitReq) (*pbAdminCMS.RemoveIPLimitResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) QueryUserIDIPLimitLogin(_ context.Context, req *pbAdminCMS.QueryUserIDIPLimitLoginReq) (*pbAdminCMS.QueryUserIDIPLimitLoginResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) AddUserIPLimitLogin(_ context.Context, req *pbAdminCMS.AddUserIPLimitLoginReq) (*pbAdminCMS.AddUserIPLimitLoginResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) RemoveUserIPLimit(_ context.Context, req *pbAdminCMS.RemoveUserIPLimitReq) (*pbAdminCMS.RemoveUserIPLimitResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetClientInitConfig(_ context.Context, req *pbAdminCMS.GetClientInitConfigReq) (*pbAdminCMS.GetClientInitConfigResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) SetClientInitConfig(_ context.Context, req *pbAdminCMS.SetClientInitConfigReq) (*pbAdminCMS.SetClientInitConfigResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
@ -29,43 +29,24 @@ func (rpc *rpcAuth) UserRegister(_ context.Context, req *pbAuth.UserRegisterReq)
|
|||||||
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
||||||
}
|
}
|
||||||
log.Debug(req.OperationID, "copy ", user, req.UserInfo)
|
log.Debug(req.OperationID, "copy ", user, req.UserInfo)
|
||||||
Limited, LimitError := imdb.IsLimitRegisterIp(req.UserInfo.CreateIp)
|
|
||||||
if LimitError != nil {
|
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: LimitError.Error()}}, nil
|
|
||||||
}
|
|
||||||
if Limited {
|
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.RegisterLimit, ErrMsg: "Register Limit"}}, nil
|
|
||||||
}
|
|
||||||
err := imdb.UserRegister(user)
|
err := imdb.UserRegister(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == constant.InvitationMsg {
|
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.InvitationError, ErrMsg: "邀请码错误"}}, nil
|
|
||||||
}
|
|
||||||
errMsg := req.OperationID + " imdb.UserRegister failed " + err.Error() + user.UserID
|
errMsg := req.OperationID + " imdb.UserRegister failed " + err.Error() + user.UserID
|
||||||
log.NewError(req.OperationID, errMsg, user)
|
log.NewError(req.OperationID, errMsg, user)
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}})
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}})
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}}, nil
|
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rpc *rpcAuth) UserToken(_ context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
func (rpc *rpcAuth) UserToken(_ context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||||
_, err := imdb.GetUserByUserID(req.FromUserID)
|
|
||||||
if err != nil {
|
|
||||||
errMsg := req.OperationID + " imdb.GetUserByUserID failed " + err.Error() + req.FromUserID
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
tokens, expTime, err := token_verify.CreateToken(req.FromUserID, int(req.Platform))
|
tokens, expTime, err := token_verify.CreateToken(req.FromUserID, int(req.Platform))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " token_verify.CreateToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
errMsg := req.OperationID + " token_verify.CreateToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime})
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime})
|
||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil
|
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
|||||||
if err = rocksCache.DelConversationFromCache(v, req.Conversation.ConversationID); err != nil {
|
if err = rocksCache.DelConversationFromCache(v, req.Conversation.ConversationID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
||||||
}
|
}
|
||||||
chat.ConversationUnreadChangeNotification(req.OperationID, v, req.Conversation.ConversationID)
|
chat.ConversationUnreadChangeNotification(req.OperationID, v, req.Conversation.ConversationID, conversation.UpdateUnreadCountTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/db/rocks_cache"
|
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||||
"Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
cp "Open_IM/pkg/common/utils"
|
cp "Open_IM/pkg/common/utils"
|
||||||
@ -19,12 +18,15 @@ import (
|
|||||||
pbUser "Open_IM/pkg/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"google.golang.org/grpc"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type groupServer struct {
|
type groupServer struct {
|
||||||
@ -121,7 +123,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
err := imdb.InsertIntoGroup(groupInfo)
|
err := imdb.InsertIntoGroup(groupInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "InsertIntoGroup failed, ", err.Error(), groupInfo)
|
log.NewError(req.OperationID, "InsertIntoGroup failed, ", err.Error(), groupInfo)
|
||||||
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
|
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
var okUserIDList []string
|
var okUserIDList []string
|
||||||
resp := &pbGroup.CreateGroupResp{GroupInfo: &open_im_sdk.GroupInfo{}}
|
resp := &pbGroup.CreateGroupResp{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||||
@ -131,7 +133,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
us, err = imdb.GetUserByUserID(req.OwnerUserID)
|
us, err = imdb.GetUserByUserID(req.OwnerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OwnerUserID)
|
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OwnerUserID)
|
||||||
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
|
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
//to group member
|
//to group member
|
||||||
groupMember = db.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID, JoinSource: constant.JoinByInvitation, InviterUserID: req.OpUserID}
|
groupMember = db.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID, JoinSource: constant.JoinByInvitation, InviterUserID: req.OpUserID}
|
||||||
@ -139,7 +141,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
err = imdb.InsertIntoGroupMember(groupMember)
|
err = imdb.InsertIntoGroupMember(groupMember)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
|
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
|
||||||
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
|
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +318,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
log.NewError(req.OperationID, "InsertIntoGroupRequest failed ", err.Error(), groupRequest)
|
// log.NewError(req.OperationID, "InsertIntoGroupRequest failed ", err.Error(), groupRequest)
|
||||||
// return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
// return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
} else {
|
} else {
|
||||||
var resultNode pbGroup.Id2Result
|
var resultNode pbGroup.Id2Result
|
||||||
@ -827,7 +829,6 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
|||||||
|
|
||||||
func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
|
func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
|
||||||
log.NewInfo(req.OperationID, "GroupApplicationResponse args ", req.String())
|
log.NewInfo(req.OperationID, "GroupApplicationResponse args ", req.String())
|
||||||
|
|
||||||
groupRequest := db.GroupRequest{}
|
groupRequest := db.GroupRequest{}
|
||||||
utils.CopyStructFields(&groupRequest, req)
|
utils.CopyStructFields(&groupRequest, req)
|
||||||
groupRequest.UserID = req.FromUserID
|
groupRequest.UserID = req.FromUserID
|
||||||
@ -1162,7 +1163,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
group, err := imdb.GetGroupInfoByGroupID(req.GroupInfoForSet.GroupID)
|
group, err := imdb.GetGroupInfoByGroupID(req.GroupInfoForSet.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), req.GroupInfoForSet.GroupID)
|
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), req.GroupInfoForSet.GroupID)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if group.Status == constant.GroupStatusDismissed {
|
if group.Status == constant.GroupStatusDismissed {
|
||||||
@ -1199,7 +1200,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
m["need_verification"] = req.GroupInfoForSet.NeedVerification.Value
|
m["need_verification"] = req.GroupInfoForSet.NeedVerification.Value
|
||||||
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
||||||
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.GroupInfoForSet.LookMemberInfo != nil {
|
if req.GroupInfoForSet.LookMemberInfo != nil {
|
||||||
@ -1208,7 +1209,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
m["look_member_info"] = req.GroupInfoForSet.LookMemberInfo.Value
|
m["look_member_info"] = req.GroupInfoForSet.LookMemberInfo.Value
|
||||||
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
||||||
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.GroupInfoForSet.ApplyMemberFriend != nil {
|
if req.GroupInfoForSet.ApplyMemberFriend != nil {
|
||||||
@ -1217,7 +1218,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
m["apply_member_friend"] = req.GroupInfoForSet.ApplyMemberFriend.Value
|
m["apply_member_friend"] = req.GroupInfoForSet.ApplyMemberFriend.Value
|
||||||
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
||||||
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -1234,11 +1235,11 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
err = imdb.SetGroupInfo(groupInfo)
|
err = imdb.SetGroupInfo(groupInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), groupInfo)
|
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), groupInfo)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
if err := rocksCache.DelGroupInfoFromCache(req.GroupInfoForSet.GroupID); err != nil {
|
if err := rocksCache.DelGroupInfoFromCache(req.GroupInfoForSet.GroupID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelGroupInfoFromCache failed ", err.Error(), req.GroupInfoForSet.GroupID)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelGroupInfoFromCache failed ", err.Error(), req.GroupInfoForSet.GroupID)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
||||||
@ -1252,7 +1253,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, http.WrapError(constant.ErrInternal)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
client := pbCache.NewCacheClient(etcdConn)
|
client := pbCache.NewCacheClient(etcdConn)
|
||||||
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||||
@ -1281,7 +1282,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, http.WrapError(constant.ErrInternal)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
nClient := pbConversation.NewConversationClient(nEtcdConn)
|
nClient := pbConversation.NewConversationClient(nEtcdConn)
|
||||||
conversationReply, err := nClient.ModifyConversationField(context.Background(), &conversationReq)
|
conversationReply, err := nClient.ModifyConversationField(context.Background(), &conversationReq)
|
||||||
@ -1336,154 +1337,89 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupByID(_ context.Context, req *pbGroup.GetGroupByIDReq) (*pbGroup.GetGroupByIDResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbGroup.GetGroupByIDResp{CMSGroup: &pbGroup.CMSGroup{
|
|
||||||
GroupInfo: &open_im_sdk.GroupInfo{},
|
|
||||||
}}
|
|
||||||
group, err := imdb.GetGroupInfoByGroupID(req.GroupID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById error", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
|
|
||||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(group.GroupID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
groupMemberNum, err := imdb.GetGroupMemberNumByGroupID(req.GroupID)
|
|
||||||
if err == nil {
|
|
||||||
resp.CMSGroup.GroupInfo.MemberCount = uint32(groupMemberNum)
|
|
||||||
} else {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
resp.CMSGroup.GroupOwnerUserName = groupMember.Nickname
|
|
||||||
resp.CMSGroup.GroupOwnerUserID = groupMember.UserID
|
|
||||||
resp.CMSGroup.GroupInfo.CreatorUserID = group.CreatorUserID
|
|
||||||
resp.CMSGroup.GroupInfo.CreateTime = uint32(group.CreateTime.Unix())
|
|
||||||
utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pbGroup.GetGroupResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbGroup.GetGroupResp{
|
|
||||||
CMSGroups: []*pbGroup.CMSGroup{},
|
|
||||||
}
|
|
||||||
groups, err := imdb.GetGroupsByName(req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsByName error", req.String(), req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "groups", groups)
|
|
||||||
nums, err := imdb.GetGroupsCountNum(db.Group{GroupName: req.GroupName})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error(), req.GroupName)
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.GroupNums = nums
|
|
||||||
resp.Pagination = &open_im_sdk.RequestPagination{
|
|
||||||
PageNumber: req.Pagination.PageNumber,
|
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
|
||||||
}
|
|
||||||
for _, v := range groups {
|
|
||||||
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
|
||||||
utils.CopyStructFields(group.GroupInfo, v)
|
|
||||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(v.GroupID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
|
||||||
group.GroupOwnerUserID = groupMember.UserID
|
|
||||||
group.GroupOwnerUserName = groupMember.Nickname
|
|
||||||
resp.CMSGroups = append(resp.CMSGroups, group)
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) {
|
func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", req.String())
|
||||||
resp := &pbGroup.GetGroupsResp{
|
resp := &pbGroup.GetGroupsResp{
|
||||||
|
CommonResp: &pbGroup.CommonResp{},
|
||||||
CMSGroups: []*pbGroup.CMSGroup{},
|
CMSGroups: []*pbGroup.CMSGroup{},
|
||||||
Pagination: &open_im_sdk.RequestPagination{},
|
Pagination: &open_im_sdk.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber},
|
||||||
}
|
}
|
||||||
groups, err := imdb.GetGroups(int(req.Pagination.PageNumber), int(req.Pagination.ShowNumber))
|
if req.GroupID != "" {
|
||||||
if err != nil {
|
groupInfoDB, err := imdb.GetGroupInfoByGroupID(req.GroupID)
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroups error", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.GroupNum, err = imdb.GetGroupsCountNum(db.Group{})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.Pagination.PageNumber = req.Pagination.PageNumber
|
|
||||||
resp.Pagination.ShowNumber = req.Pagination.ShowNumber
|
|
||||||
for _, v := range groups {
|
|
||||||
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
|
||||||
utils.CopyStructFields(group.GroupInfo, v)
|
|
||||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(v.GroupID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
continue
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
resp.GroupNum = 1
|
||||||
group.GroupOwnerUserID = groupMember.UserID
|
groupInfo := &open_im_sdk.GroupInfo{}
|
||||||
group.GroupOwnerUserName = groupMember.Nickname
|
utils.CopyStructFields(groupInfo, groupInfoDB)
|
||||||
resp.CMSGroups = append(resp.CMSGroups, group)
|
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(req.GroupID)
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUserRoleReq) (*pbGroup.OperateUserRoleResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
|
||||||
resp := &pbGroup.OperateUserRoleResp{}
|
|
||||||
oldOwnerUserID, err := imdb.GetGroupOwnerInfoByGroupID(req.GroupID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
return resp, http.WrapError(constant.ErrInternal)
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
var reqPb pbGroup.TransferGroupOwnerReq
|
|
||||||
reqPb.OperationID = req.OperationID
|
|
||||||
reqPb.NewOwnerUserID = req.UserID
|
|
||||||
reqPb.GroupID = req.GroupID
|
|
||||||
reqPb.OpUserID = "cms admin"
|
|
||||||
reqPb.OldOwnerUserID = oldOwnerUserID.UserID
|
|
||||||
reply, err := client.TransferGroupOwner(context.Background(), &reqPb)
|
|
||||||
if reply.CommonResp.ErrCode != 0 || err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "TransferGroupOwner rpc failed")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
memberNum, err := imdb.GetGroupMembersCount(req.GroupID, "")
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
groupInfo.MemberCount = uint32(memberNum)
|
||||||
|
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{GroupInfo: groupInfo, GroupOwnerUserName: groupMember.Nickname, GroupOwnerUserID: groupMember.UserID})
|
||||||
|
} else {
|
||||||
|
groups, err := imdb.GetGroupsByName(req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsByName error", req.String(), req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
}
|
||||||
|
for _, v := range groups {
|
||||||
|
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||||
|
utils.CopyStructFields(group.GroupInfo, v)
|
||||||
|
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(v.GroupID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupOwnerInfoByGroupID failed", err.Error(), v)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
||||||
|
group.GroupOwnerUserID = groupMember.UserID
|
||||||
|
group.GroupOwnerUserName = groupMember.Nickname
|
||||||
|
resp.CMSGroups = append(resp.CMSGroups, group)
|
||||||
|
}
|
||||||
|
resp.GroupNum, err = imdb.GetGroupsCountNum(db.Group{GroupName: req.GroupName})
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups resp", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
|
func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
||||||
resp := &pbGroup.GetGroupMembersCMSResp{}
|
resp := &pbGroup.GetGroupMembersCMSResp{CommonResp: &pbGroup.CommonResp{}}
|
||||||
groupMembers, err := imdb.GetGroupMembersByGroupIdCMS(req.GroupID, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
groupMembers, err := imdb.GetGroupMembersByGroupIdCMS(req.GroupID, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersByGroupIdCMS Error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersByGroupIdCMS Error", err.Error())
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupMembersCount, err := imdb.GetGroupMembersCount(req.GroupID, req.UserName)
|
groupMembersCount, err := imdb.GetGroupMembersCount(req.GroupID, req.UserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS Error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS Error", err.Error())
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, groupMembersCount)
|
log.NewInfo(req.OperationID, groupMembersCount)
|
||||||
resp.MemberNums = int32(groupMembersCount)
|
resp.MemberNums = int32(groupMembersCount)
|
||||||
@ -1502,151 +1438,6 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.RemoveGroupMembersCMSReq) (*pbGroup.RemoveGroupMembersCMSResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
|
||||||
resp := &pbGroup.RemoveGroupMembersCMSResp{}
|
|
||||||
for _, userId := range req.UserIDList {
|
|
||||||
err := imdb.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, userId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
resp.Failed = append(resp.Failed, userId)
|
|
||||||
} else {
|
|
||||||
resp.Success = append(resp.Success, userId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reqKick := &pbGroup.KickGroupMemberReq{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
KickedUserIDList: resp.Success,
|
|
||||||
Reason: "admin kick",
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
OpUserID: req.OpUserID,
|
|
||||||
}
|
|
||||||
var reqPb pbUser.SetConversationReq
|
|
||||||
var c pbConversation.Conversation
|
|
||||||
for _, v := range resp.Success {
|
|
||||||
reqPb.OperationID = req.OperationID
|
|
||||||
c.OwnerUserID = v
|
|
||||||
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
|
|
||||||
c.ConversationType = constant.GroupChatType
|
|
||||||
c.GroupID = req.GroupID
|
|
||||||
c.IsNotInGroup = true
|
|
||||||
reqPb.Conversation = &c
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
return resp, http.WrapError(constant.ErrInternal)
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error(), v)
|
|
||||||
} else {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
cacheClient := pbCache.NewCacheClient(etcdConn)
|
|
||||||
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
if cacheResp.CommonResp.ErrCode != 0 {
|
|
||||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, userID := range resp.Success {
|
|
||||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, userID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID, userID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chat.MemberKickedNotification(reqKick, resp.Success)
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGroupMembersCMSReq) (*pbGroup.AddGroupMembersCMSResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
|
||||||
resp := &pbGroup.AddGroupMembersCMSResp{}
|
|
||||||
for _, userId := range req.UserIDList {
|
|
||||||
if isExist := imdb.IsExistGroupMember(req.GroupID, userId); isExist {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "user is exist in group", userId, req.GroupID)
|
|
||||||
resp.Failed = append(resp.Failed, userId)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
user, err := imdb.GetUserByUserID(userId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID", err.Error())
|
|
||||||
resp.Failed = append(resp.Failed, userId)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
groupMember := db.GroupMember{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
UserID: userId,
|
|
||||||
Nickname: user.Nickname,
|
|
||||||
FaceURL: "",
|
|
||||||
RoleLevel: 1,
|
|
||||||
JoinTime: time.Time{},
|
|
||||||
JoinSource: constant.JoinByAdmin,
|
|
||||||
OperatorUserID: "CmsAdmin",
|
|
||||||
Ex: "",
|
|
||||||
}
|
|
||||||
if err := imdb.InsertIntoGroupMember(groupMember); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "InsertIntoGroupMember failed", req.String())
|
|
||||||
resp.Failed = append(resp.Failed, userId)
|
|
||||||
} else {
|
|
||||||
resp.Success = append(resp.Success, userId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
cacheClient := pbCache.NewCacheClient(etcdConn)
|
|
||||||
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
if cacheResp.CommonResp.ErrCode != 0 {
|
|
||||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
|
|
||||||
chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, "admin add you to group", resp.Success)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) GetUserReqApplicationList(_ context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
|
func (s *groupServer) GetUserReqApplicationList(_ context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbGroup.GetUserReqApplicationListResp{}
|
resp := &pbGroup.GetUserReqApplicationListResp{}
|
||||||
|
@ -1,182 +0,0 @@
|
|||||||
package messageCMS
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
"Open_IM/pkg/common/db"
|
|
||||||
errors "Open_IM/pkg/common/http"
|
|
||||||
"context"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
|
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
||||||
pbMessageCMS "Open_IM/pkg/proto/message_cms"
|
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
||||||
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
|
|
||||||
"net"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type messageCMSServer struct {
|
|
||||||
rpcPort int
|
|
||||||
rpcRegisterName string
|
|
||||||
etcdSchema string
|
|
||||||
etcdAddr []string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMessageCMSServer(port int) *messageCMSServer {
|
|
||||||
log.NewPrivateLog(constant.LogFileName)
|
|
||||||
return &messageCMSServer{
|
|
||||||
rpcPort: port,
|
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImMessageCMSName,
|
|
||||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
|
||||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) Run() {
|
|
||||||
log.NewInfo("0", "messageCMS rpc start ")
|
|
||||||
|
|
||||||
listenIP := ""
|
|
||||||
if config.Config.ListenIP == "" {
|
|
||||||
listenIP = "0.0.0.0"
|
|
||||||
} else {
|
|
||||||
listenIP = config.Config.ListenIP
|
|
||||||
}
|
|
||||||
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
|
|
||||||
|
|
||||||
//listener network
|
|
||||||
listener, err := net.Listen("tcp", address)
|
|
||||||
if err != nil {
|
|
||||||
panic("listening err:" + err.Error() + s.rpcRegisterName)
|
|
||||||
}
|
|
||||||
log.NewInfo("0", "listen network success, ", address, listener)
|
|
||||||
defer listener.Close()
|
|
||||||
//grpc server
|
|
||||||
srv := grpc.NewServer()
|
|
||||||
defer srv.GracefulStop()
|
|
||||||
//Service registers with etcd
|
|
||||||
pbMessageCMS.RegisterMessageCMSServer(srv, s)
|
|
||||||
rpcRegisterIP := config.Config.RpcRegisterIP
|
|
||||||
if config.Config.RpcRegisterIP == "" {
|
|
||||||
rpcRegisterIP, err = utils.GetLocalIP()
|
|
||||||
if err != nil {
|
|
||||||
log.Error("", "GetLocalIP failed ", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
|
||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
|
||||||
panic(utils.Wrap(err, "register message_cms module rpc to etcd err"))
|
|
||||||
}
|
|
||||||
err = srv.Serve(listener)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("0", "Serve failed ", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo("0", "message cms rpc success")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) BoradcastMessage(_ context.Context, req *pbMessageCMS.BoradcastMessageReq) (*pbMessageCMS.BoradcastMessageResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "BoradcastMessage", req.String())
|
|
||||||
resp := &pbMessageCMS.BoradcastMessageResp{}
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetChatLogsReq) (*pbMessageCMS.GetChatLogsResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetChatLogs", req.String())
|
|
||||||
resp := &pbMessageCMS.GetChatLogsResp{}
|
|
||||||
time, err := utils.TimeStringToTime(req.Date)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
|
|
||||||
}
|
|
||||||
chatLog := db.ChatLog{
|
|
||||||
Content: req.Content,
|
|
||||||
SendTime: time,
|
|
||||||
ContentType: req.ContentType,
|
|
||||||
SessionType: req.SessionType,
|
|
||||||
}
|
|
||||||
switch chatLog.SessionType {
|
|
||||||
case constant.SingleChatType:
|
|
||||||
chatLog.SendID = req.UserId
|
|
||||||
case constant.GroupChatType:
|
|
||||||
chatLog.RecvID = req.GroupId
|
|
||||||
chatLog.SendID = req.UserId
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
|
|
||||||
nums, err := imdb.GetChatLogCount(chatLog)
|
|
||||||
resp.ChatLogsNum = int32(nums)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLogCount", err.Error())
|
|
||||||
}
|
|
||||||
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
for _, chatLog := range chatLogs {
|
|
||||||
pbChatLog := &pbMessageCMS.ChatLogs{
|
|
||||||
SessionType: chatLog.SessionType,
|
|
||||||
ContentType: chatLog.ContentType,
|
|
||||||
SearchContent: req.Content,
|
|
||||||
WholeContent: chatLog.Content,
|
|
||||||
Date: chatLog.CreateTime.String(),
|
|
||||||
SenderNickName: chatLog.SenderNickname,
|
|
||||||
SenderId: chatLog.SendID,
|
|
||||||
}
|
|
||||||
if chatLog.SenderNickname == "" {
|
|
||||||
sendUser, err := imdb.GetUserByUserID(chatLog.SendID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pbChatLog.SenderNickName = sendUser.Nickname
|
|
||||||
}
|
|
||||||
switch chatLog.SessionType {
|
|
||||||
case constant.SingleChatType:
|
|
||||||
recvUser, err := imdb.GetUserByUserID(chatLog.RecvID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pbChatLog.ReciverId = recvUser.UserID
|
|
||||||
pbChatLog.ReciverNickName = recvUser.Nickname
|
|
||||||
|
|
||||||
case constant.GroupChatType:
|
|
||||||
group, err := imdb.GetGroupInfoByGroupID(chatLog.RecvID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById failed")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pbChatLog.GroupId = group.GroupID
|
|
||||||
pbChatLog.GroupName = group.GroupName
|
|
||||||
}
|
|
||||||
resp.ChatLogs = append(resp.ChatLogs, pbChatLog)
|
|
||||||
}
|
|
||||||
resp.Pagination = &open_im_sdk.ResponsePagination{
|
|
||||||
CurrentPage: req.Pagination.PageNumber,
|
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp output: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) MassSendMessage(_ context.Context, req *pbMessageCMS.MassSendMessageReq) (*pbMessageCMS.MassSendMessageResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "MassSendMessage", req.String())
|
|
||||||
resp := &pbMessageCMS.MassSendMessageResp{}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) WithdrawMessage(_ context.Context, req *pbMessageCMS.WithdrawMessageReq) (*pbMessageCMS.WithdrawMessageResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "WithdrawMessage", req.String())
|
|
||||||
resp := &pbMessageCMS.WithdrawMessageResp{}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
@ -70,11 +70,12 @@ func ConversationChangeNotification(operationID, userID string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//会话未读数同步
|
//会话未读数同步
|
||||||
func ConversationUnreadChangeNotification(operationID, userID, conversationID string) {
|
func ConversationUnreadChangeNotification(operationID, userID, conversationID string, updateUnreadCountTime int64) {
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName())
|
log.NewInfo(operationID, utils.GetSelfFuncName())
|
||||||
ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{
|
ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
ConversationIDList: []string{conversationID},
|
ConversationIDList: []string{conversationID},
|
||||||
|
UpdateUnreadCountTime: updateUnreadCountTime,
|
||||||
}
|
}
|
||||||
var tips open_im_sdk.TipsComm
|
var tips open_im_sdk.TipsComm
|
||||||
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
||||||
|
@ -7,13 +7,15 @@ import (
|
|||||||
pbMsg "Open_IM/pkg/proto/msg"
|
pbMsg "Open_IM/pkg/proto/msg"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
goRedis "github.com/go-redis/redis/v8"
|
goRedis "github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rpc *rpcChat) SetSendMsgFailedFlag(_ context.Context, req *pbMsg.SetSendMsgFailedFlagReq) (resp *pbMsg.SetSendMsgFailedFlagResp, err error) {
|
func (rpc *rpcChat) SetSendMsgStatus(_ context.Context, req *pbMsg.SetSendMsgStatusReq) (resp *pbMsg.SetSendMsgStatusResp, err error) {
|
||||||
resp = &pbMsg.SetSendMsgFailedFlagResp{}
|
resp = &pbMsg.SetSendMsgStatusResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
if err := db.DB.SetSendMsgFailedFlag(req.OperationID); err != nil {
|
if err := db.DB.SetSendMsgStatus(req.Status, req.OperationID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
resp.ErrCode = constant.ErrDB.ErrCode
|
resp.ErrCode = constant.ErrDB.ErrCode
|
||||||
resp.ErrMsg = err.Error()
|
resp.ErrMsg = err.Error()
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -25,9 +27,11 @@ func (rpc *rpcChat) SetSendMsgFailedFlag(_ context.Context, req *pbMsg.SetSendMs
|
|||||||
func (rpc *rpcChat) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) {
|
func (rpc *rpcChat) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
resp = &pbMsg.GetSendMsgStatusResp{}
|
resp = &pbMsg.GetSendMsgStatusResp{}
|
||||||
if err := db.DB.GetSendMsgStatus(req.OperationID); err != nil {
|
status, err := db.DB.GetSendMsgStatus(req.OperationID)
|
||||||
|
if err != nil {
|
||||||
|
resp.Status = constant.MsgStatusNotExist
|
||||||
if err == goRedis.Nil {
|
if err == goRedis.Nil {
|
||||||
resp.Status = 0
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.OperationID, "not exist")
|
||||||
return resp, nil
|
return resp, nil
|
||||||
} else {
|
} else {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
@ -36,7 +40,7 @@ func (rpc *rpcChat) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgSta
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp.Status = 1
|
resp.Status = int32(status)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -1,399 +0,0 @@
|
|||||||
package statistics
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
"context"
|
|
||||||
"strconv"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
//"Open_IM/pkg/common/constant"
|
|
||||||
//"Open_IM/pkg/common/db"
|
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
|
|
||||||
//cp "Open_IM/pkg/common/utils"
|
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
||||||
pbStatistics "Open_IM/pkg/proto/statistics"
|
|
||||||
|
|
||||||
//open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
//"context"
|
|
||||||
errors "Open_IM/pkg/common/http"
|
|
||||||
"net"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type statisticsServer struct {
|
|
||||||
rpcPort int
|
|
||||||
rpcRegisterName string
|
|
||||||
etcdSchema string
|
|
||||||
etcdAddr []string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewStatisticsServer(port int) *statisticsServer {
|
|
||||||
log.NewPrivateLog(constant.LogFileName)
|
|
||||||
return &statisticsServer{
|
|
||||||
rpcPort: port,
|
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImStatisticsName,
|
|
||||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
|
||||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) Run() {
|
|
||||||
log.NewInfo("0", "Statistics rpc start ")
|
|
||||||
|
|
||||||
listenIP := ""
|
|
||||||
if config.Config.ListenIP == "" {
|
|
||||||
listenIP = "0.0.0.0"
|
|
||||||
} else {
|
|
||||||
listenIP = config.Config.ListenIP
|
|
||||||
}
|
|
||||||
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
|
|
||||||
|
|
||||||
//listener network
|
|
||||||
listener, err := net.Listen("tcp", address)
|
|
||||||
if err != nil {
|
|
||||||
panic("listening err:" + err.Error() + s.rpcRegisterName)
|
|
||||||
}
|
|
||||||
log.NewInfo("0", "listen network success, ", address, listener)
|
|
||||||
defer listener.Close()
|
|
||||||
//grpc server
|
|
||||||
srv := grpc.NewServer()
|
|
||||||
defer srv.GracefulStop()
|
|
||||||
//Service registers with etcd
|
|
||||||
pbStatistics.RegisterUserServer(srv, s)
|
|
||||||
rpcRegisterIP := config.Config.RpcRegisterIP
|
|
||||||
if config.Config.RpcRegisterIP == "" {
|
|
||||||
rpcRegisterIP, err = utils.GetLocalIP()
|
|
||||||
if err != nil {
|
|
||||||
log.Error("", "GetLocalIP failed ", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
|
||||||
panic(utils.Wrap(err, "register statistics module rpc to etcd err"))
|
|
||||||
}
|
|
||||||
err = srv.Serve(listener)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("0", "Serve failed ", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo("0", "statistics rpc success")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.GetActiveGroupReq) (*pbStatistics.GetActiveGroupResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
|
|
||||||
resp := &pbStatistics.GetActiveGroupResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
|
||||||
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
for _, activeGroup := range activeGroups {
|
|
||||||
resp.Groups = append(resp.Groups,
|
|
||||||
&pbStatistics.GroupResp{
|
|
||||||
GroupName: activeGroup.Name,
|
|
||||||
GroupId: activeGroup.Id,
|
|
||||||
MessageNum: int32(activeGroup.MessageNum),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.GetActiveUserReq) (*pbStatistics.GetActiveUserResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
|
||||||
resp := &pbStatistics.GetActiveUserResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
|
||||||
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
for _, activeUser := range activeUsers {
|
|
||||||
resp.Users = append(resp.Users,
|
|
||||||
&pbStatistics.UserResp{
|
|
||||||
UserId: activeUser.Id,
|
|
||||||
NickName: activeUser.Name,
|
|
||||||
MessageNum: int32(activeUser.MessageNum),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseTimeFromTo(from, to string) (time.Time, time.Time, error) {
|
|
||||||
var fromTime time.Time
|
|
||||||
var toTime time.Time
|
|
||||||
fromTime, err := utils.TimeStringToTime(from)
|
|
||||||
if err != nil {
|
|
||||||
return fromTime, toTime, err
|
|
||||||
}
|
|
||||||
toTime, err = utils.TimeStringToTime(to)
|
|
||||||
if err != nil {
|
|
||||||
return fromTime, toTime, err
|
|
||||||
}
|
|
||||||
return fromTime, toTime, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func isInOneMonth(from, to time.Time) bool {
|
|
||||||
return from.Month() == to.Month() && from.Year() == to.Year()
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetRangeDate(from, to time.Time) [][2]time.Time {
|
|
||||||
interval := to.Sub(from)
|
|
||||||
var times [][2]time.Time
|
|
||||||
switch {
|
|
||||||
// today
|
|
||||||
case interval == 0:
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
from, from.Add(time.Hour * 24),
|
|
||||||
})
|
|
||||||
// days
|
|
||||||
case isInOneMonth(from, to):
|
|
||||||
for i := 0; ; i++ {
|
|
||||||
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
|
||||||
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
|
||||||
if toTime.After(to.Add(time.Hour * 24)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// month
|
|
||||||
case !isInOneMonth(from, to):
|
|
||||||
if to.Sub(from) < time.Hour*24*30 {
|
|
||||||
for i := 0; ; i++ {
|
|
||||||
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
|
||||||
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
|
||||||
if toTime.After(to.Add(time.Hour * 24)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for i := 0; ; i++ {
|
|
||||||
if i == 0 {
|
|
||||||
fromTime := from
|
|
||||||
toTime := getFirstDateOfNextNMonth(fromTime, 1)
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
fromTime := getFirstDateOfNextNMonth(from, i)
|
|
||||||
toTime := getFirstDateOfNextNMonth(fromTime, 1)
|
|
||||||
if toTime.After(to) {
|
|
||||||
toTime = to
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
break
|
|
||||||
}
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return times
|
|
||||||
}
|
|
||||||
|
|
||||||
func getFirstDateOfNextNMonth(currentTime time.Time, n int) time.Time {
|
|
||||||
lastOfMonth := time.Date(currentTime.Year(), currentTime.Month(), 1, 0, 0, 0, 0, currentTime.Location()).AddDate(0, n, 0)
|
|
||||||
return lastOfMonth
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatistics.GetGroupStatisticsReq) (*pbStatistics.GetGroupStatisticsResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
|
||||||
resp := &pbStatistics.GetGroupStatisticsResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
|
||||||
}
|
|
||||||
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
totalGroupNum, err := imdb.GetTotalGroupNum()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.IncreaseGroupNum = increaseGroupNum
|
|
||||||
resp.TotalGroupNum = totalGroupNum
|
|
||||||
times := GetRangeDate(fromTime, toTime)
|
|
||||||
log.NewDebug(req.OperationID, "times:", times)
|
|
||||||
wg := &sync.WaitGroup{}
|
|
||||||
resp.IncreaseGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
resp.TotalGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
wg.Add(len(times))
|
|
||||||
for i, v := range times {
|
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
|
||||||
defer wg.Done()
|
|
||||||
num, err := imdb.GetIncreaseGroupNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.IncreaseGroupNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
num, err = imdb.GetGroupNum(v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.TotalGroupNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
}(wg, i, v)
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatistics.GetMessageStatisticsReq) (*pbStatistics.GetMessageStatisticsResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
|
||||||
resp := &pbStatistics.GetMessageStatisticsResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
|
||||||
}
|
|
||||||
privateMessageNum, err := imdb.GetPrivateMessageNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetPrivateMessageNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
groupMessageNum, err := imdb.GetGroupMessageNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
|
|
||||||
resp.PrivateMessageNum = privateMessageNum
|
|
||||||
resp.GroupMessageNum = groupMessageNum
|
|
||||||
times := GetRangeDate(fromTime, toTime)
|
|
||||||
resp.GroupMessageNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
resp.PrivateMessageNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
wg := &sync.WaitGroup{}
|
|
||||||
wg.Add(len(times))
|
|
||||||
for i, v := range times {
|
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
num, err := imdb.GetPrivateMessageNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.PrivateMessageNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
num, err = imdb.GetGroupMessageNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.GroupMessageNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
}(wg, i, v)
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistics.GetUserStatisticsReq) (*pbStatistics.GetUserStatisticsResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbStatistics.GetUserStatisticsResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
|
||||||
}
|
|
||||||
activeUserNum, err := imdb.GetActiveUserNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUserNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
increaseUserNum, err := imdb.GetIncreaseUserNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
totalUserNum, err := imdb.GetTotalUserNum()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.ActiveUserNum = activeUserNum
|
|
||||||
resp.TotalUserNum = totalUserNum
|
|
||||||
resp.IncreaseUserNum = increaseUserNum
|
|
||||||
times := GetRangeDate(fromTime, toTime)
|
|
||||||
resp.TotalUserNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
resp.ActiveUserNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
resp.IncreaseUserNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
wg := &sync.WaitGroup{}
|
|
||||||
wg.Add(len(times))
|
|
||||||
for i, v := range times {
|
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
|
||||||
defer wg.Done()
|
|
||||||
num, err := imdb.GetActiveUserNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.ActiveUserNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
|
|
||||||
num, err = imdb.GetTotalUserNumByDate(v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNumByDate", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.TotalUserNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
num, err = imdb.GetIncreaseUserNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.IncreaseUserNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
}(wg, i, v)
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
@ -7,7 +7,6 @@ import (
|
|||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||||
errors "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
@ -17,12 +16,13 @@ import (
|
|||||||
pbUser "Open_IM/pkg/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type userServer struct {
|
type userServer struct {
|
||||||
@ -335,27 +335,6 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) DeleteUsers(_ context.Context, req *pbUser.DeleteUsersReq) (*pbUser.DeleteUsersResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, "DeleteUsers args ", req.String())
|
|
||||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
|
||||||
log.NewError(req.OperationID, "IsManagerUserID false ", req.OpUserID)
|
|
||||||
return &pbUser.DeleteUsersResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, FailedUserIDList: req.DeleteUserIDList}, nil
|
|
||||||
}
|
|
||||||
var common pbUser.CommonResp
|
|
||||||
resp := pbUser.DeleteUsersResp{CommonResp: &common}
|
|
||||||
for _, userID := range req.DeleteUserIDList {
|
|
||||||
i := imdb.DeleteUser(userID)
|
|
||||||
if i == 0 {
|
|
||||||
log.NewError(req.OperationID, "delete user error", userID)
|
|
||||||
common.ErrCode = 201
|
|
||||||
common.ErrMsg = "some uid deleted failed"
|
|
||||||
resp.FailedUserIDList = append(resp.FailedUserIDList, userID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, "DeleteUsers rpc return ", resp.String())
|
|
||||||
return &resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) GetAllUserID(_ context.Context, req *pbUser.GetAllUserIDReq) (*pbUser.GetAllUserIDResp, error) {
|
func (s *userServer) GetAllUserID(_ context.Context, req *pbUser.GetAllUserIDReq) (*pbUser.GetAllUserIDResp, error) {
|
||||||
log.NewInfo(req.OperationID, "GetAllUserID args ", req.String())
|
log.NewInfo(req.OperationID, "GetAllUserID args ", req.String())
|
||||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
if !token_verify.IsManagerUserID(req.OpUserID) {
|
||||||
@ -543,270 +522,185 @@ func (s *userServer) SyncJoinedGroupMemberNickname(userID string, newNickname, o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByNameReq) (*pbUser.GetUsersByNameResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
|
|
||||||
resp := &pbUser.GetUsersByNameResp{}
|
|
||||||
users, err := imdb.GetUserByName(req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByName failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
for _, user := range users {
|
|
||||||
isBlock, err := imdb.UserIsBlock(user.UserID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
resp.Users = append(resp.Users, &pbUser.User{
|
|
||||||
ProfilePhoto: user.FaceURL,
|
|
||||||
Nickname: user.Nickname,
|
|
||||||
UserId: user.UserID,
|
|
||||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
|
||||||
CreateIp: user.CreateIp,
|
|
||||||
IsBlock: isBlock,
|
|
||||||
Birth: user.Birth.Format("2006-01-02"),
|
|
||||||
PhoneNumber: user.PhoneNumber,
|
|
||||||
Email: user.Email,
|
|
||||||
LastLoginIp: user.LastLoginIp,
|
|
||||||
LastLoginTime: user.LastLoginTime.Format("2006-01-02 15:04:05"),
|
|
||||||
LoginTimes: user.LoginTimes,
|
|
||||||
Gender: user.Gender,
|
|
||||||
LoginLimit: user.LoginLimit,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
user := db.User{Nickname: req.UserName}
|
|
||||||
userNums, err := imdb.GetUsersCount(user)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.UserNums = userNums
|
|
||||||
resp.Pagination = &sdkws.ResponsePagination{
|
|
||||||
CurrentPage: req.Pagination.PageNumber,
|
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq) (*pbUser.GetUserByIdResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
|
|
||||||
resp := &pbUser.GetUserByIdResp{User: &pbUser.User{}}
|
|
||||||
user, err := imdb.GetUserByUserID(req.UserId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
isBlock, err := imdb.UserIsBlock(req.UserId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.User = &pbUser.User{
|
|
||||||
ProfilePhoto: user.FaceURL,
|
|
||||||
Nickname: user.Nickname,
|
|
||||||
UserId: user.UserID,
|
|
||||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
|
||||||
CreateIp: user.CreateIp,
|
|
||||||
IsBlock: isBlock,
|
|
||||||
Birth: user.Birth.Format("2006-01-02"),
|
|
||||||
PhoneNumber: user.PhoneNumber,
|
|
||||||
Email: user.Email,
|
|
||||||
LastLoginIp: user.LastLoginIp,
|
|
||||||
LastLoginTime: user.LastLoginTime.Format("2006-01-02 15:04:05"),
|
|
||||||
LoginTimes: user.LoginTimes,
|
|
||||||
Gender: user.Gender,
|
|
||||||
LoginLimit: user.LoginLimit,
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pbUser.GetUsersResp, error) {
|
func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pbUser.GetUsersResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
|
var usersDB []db.User
|
||||||
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
var err error
|
||||||
if err != nil {
|
resp := &pbUser.GetUsersResp{CommonResp: &pbUser.CommonResp{}, Pagination: &sdkws.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber}}
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", err.Error())
|
if req.UserID != "" {
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
userDB, err := imdb.GetUserByUserID(req.UserID)
|
||||||
}
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
for _, v := range users {
|
return resp, nil
|
||||||
isBlock, err := imdb.UserIsBlock(v.UserID)
|
|
||||||
if err == nil {
|
|
||||||
registerIP := ""
|
|
||||||
registerInfo, err := imdb.GetRegisterInfo(v.UserID)
|
|
||||||
if registerInfo != nil && err == nil {
|
|
||||||
registerIP = registerInfo.RegisterIP
|
|
||||||
}
|
}
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.UserID, err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
usersDB = append(usersDB, *userDB)
|
||||||
|
resp.TotalNums = 1
|
||||||
|
} else if req.UserName != "" {
|
||||||
|
usersDB, err = imdb.GetUserByName(req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber, err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.TotalNums, err = imdb.GetUsersCount(req.UserName)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.UserName, err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
user := &pbUser.User{
|
} else if req.Content != "" {
|
||||||
ProfilePhoto: v.FaceURL,
|
var count int64
|
||||||
UserId: v.UserID,
|
usersDB, count, err = imdb.GetUsersByNameAndID(req.Content, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
CreateTime: v.CreateTime.Format("2006-01-02 15:04:05"),
|
if err != nil {
|
||||||
CreateIp: v.CreateIp,
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", req.Pagination.ShowNumber, req.Pagination.PageNumber, err.Error())
|
||||||
Nickname: v.Nickname,
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
Birth: v.Birth.Format("2006-01-02"),
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
PhoneNumber: v.PhoneNumber,
|
return resp, nil
|
||||||
Email: v.Email,
|
}
|
||||||
IsBlock: isBlock,
|
resp.TotalNums = int32(count)
|
||||||
LastLoginIp: v.LastLoginIp,
|
} else {
|
||||||
LastLoginTime: v.LastLoginTime.Format("2006-01-02 15:04:05"),
|
usersDB, err = imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
LoginTimes: v.LoginTimes,
|
if err != nil {
|
||||||
Gender: v.Gender,
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", req.Pagination.ShowNumber, req.Pagination.PageNumber, err.Error())
|
||||||
LoginLimit: v.LoginLimit,
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
RegisterIp: registerIP,
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
}
|
return resp, nil
|
||||||
resp.User = append(resp.User, user)
|
}
|
||||||
} else {
|
resp.TotalNums, err = imdb.GetTotalUserNum()
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UserIsBlock failed", err.Error())
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user := db.User{}
|
for _, userDB := range usersDB {
|
||||||
nums, err := imdb.GetUsersCount(user)
|
var user sdkws.UserInfo
|
||||||
|
utils.CopyStructFields(&user, userDB)
|
||||||
|
user.CreateTime = uint32(userDB.CreateTime.Unix())
|
||||||
|
user.Birth = uint32(userDB.Birth.Unix())
|
||||||
|
resp.UserList = append(resp.UserList, &pbUser.CmsUser{User: &user})
|
||||||
|
}
|
||||||
|
|
||||||
|
var userIDList []string
|
||||||
|
for _, v := range resp.UserList {
|
||||||
|
userIDList = append(userIDList, v.User.UserID)
|
||||||
|
}
|
||||||
|
isBlockUser, err := imdb.UsersIsBlock(userIDList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error(), user)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userIDList)
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
resp.UserNums = nums
|
|
||||||
resp.Pagination = &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) ResignUser(ctx context.Context, req *pbUser.ResignUserReq) (*pbUser.ResignUserResp, error) {
|
for _, v := range resp.UserList {
|
||||||
log.NewInfo(req.OperationID, "ResignUser args ", req.String())
|
if utils.IsContain(v.User.UserID, isBlockUser) {
|
||||||
return &pbUser.ResignUserResp{}, nil
|
v.IsBlock = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbUser.AlterUserResp{}
|
|
||||||
birth, _ := time.ParseInLocation("2006-01-02", req.Birth, time.Local)
|
|
||||||
gender, gendererr := strconv.Atoi(req.Gender)
|
|
||||||
if gendererr != nil {
|
|
||||||
gender = 0
|
|
||||||
}
|
}
|
||||||
user := db.User{
|
|
||||||
PhoneNumber: req.PhoneNumber,
|
|
||||||
Nickname: req.Nickname,
|
|
||||||
Email: req.Email,
|
|
||||||
UserID: req.UserId,
|
|
||||||
Gender: int32(gender),
|
|
||||||
FaceURL: req.Photo,
|
|
||||||
Birth: birth,
|
|
||||||
}
|
|
||||||
if err := imdb.UpdateUserInfo(user); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateUserInfo", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
chat.UserInfoUpdatedNotification(req.OperationID, req.UserId, req.OpUserId)
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
|
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.AddUserResp{}
|
resp := &pbUser.AddUserResp{CommonResp: &pbUser.CommonResp{}}
|
||||||
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name, req.Email, req.Gender, req.Photo, req.Birth)
|
err := imdb.AddUser(req.UserInfo.UserID, req.UserInfo.PhoneNumber, req.UserInfo.Nickname, req.UserInfo.Email, req.UserInfo.Gender, req.UserInfo.FaceURL, req.UserInfo.Birth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddUser", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddUser", err.Error(), req.String())
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
|
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.BlockUserResp{}
|
resp := &pbUser.BlockUserResp{CommonResp: &pbUser.CommonResp{}}
|
||||||
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
|
err := imdb.BlockUser(req.UserID, req.EndDisableTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BlockUser", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BlockUser", err.Error(), req.UserID, req.EndDisableTime)
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
|
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.UnBlockUserResp{}
|
resp := &pbUser.UnBlockUserResp{CommonResp: &pbUser.CommonResp{}}
|
||||||
err := imdb.UnBlockUser(req.UserId)
|
err := imdb.UnBlockUser(req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "unBlockUser", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "unBlockUser", err.Error())
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
|
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (resp *pbUser.GetBlockUsersResp, err error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetBlockUsersResp{}
|
resp = &pbUser.GetBlockUsersResp{CommonResp: &pbUser.CommonResp{}, Pagination: &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}}
|
||||||
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
var blockUsers []imdb.BlockUserInfo
|
||||||
if err != nil {
|
if req.UserID != "" {
|
||||||
log.Error(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsers", err.Error())
|
blockUser, err := imdb.GetBlockUserByID(req.UserID)
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
blockUsers = append(blockUsers, blockUser)
|
||||||
|
resp.UserNums = 1
|
||||||
|
} else {
|
||||||
|
blockUsers, err = imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsers", err.Error(), req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
nums, err := imdb.GetBlockUsersNumCount()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsersNumCount failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.UserNums = nums
|
||||||
}
|
}
|
||||||
for _, v := range blockUsers {
|
for _, v := range blockUsers {
|
||||||
resp.BlockUsers = append(resp.BlockUsers, &pbUser.BlockUser{
|
resp.BlockUsers = append(resp.BlockUsers, &pbUser.BlockUser{
|
||||||
User: &pbUser.User{
|
UserInfo: &sdkws.UserInfo{
|
||||||
ProfilePhoto: v.User.FaceURL,
|
FaceURL: v.User.FaceURL,
|
||||||
Nickname: v.User.Nickname,
|
Nickname: v.User.Nickname,
|
||||||
UserId: v.User.UserID,
|
UserID: v.User.UserID,
|
||||||
IsBlock: true,
|
PhoneNumber: v.User.PhoneNumber,
|
||||||
Birth: v.User.Birth.Format("2006-01-02"),
|
Email: v.User.Email,
|
||||||
PhoneNumber: v.User.PhoneNumber,
|
Gender: v.User.Gender,
|
||||||
Email: v.User.Email,
|
|
||||||
Gender: v.User.Gender,
|
|
||||||
},
|
},
|
||||||
BeginDisableTime: (v.BeginDisableTime).String(),
|
BeginDisableTime: (v.BeginDisableTime).String(),
|
||||||
EndDisableTime: (v.EndDisableTime).String(),
|
EndDisableTime: (v.EndDisableTime).String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
resp.Pagination = &sdkws.ResponsePagination{}
|
|
||||||
resp.Pagination.ShowNumber = req.Pagination.ShowNumber
|
|
||||||
resp.Pagination.CurrentPage = req.Pagination.PageNumber
|
|
||||||
nums, err := imdb.GetBlockUsersNumCount()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsersNumCount failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.UserNums = nums
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUserByIdReq) (*pbUser.GetBlockUserByIdResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbUser.GetBlockUserByIdResp{}
|
|
||||||
user, err := imdb.GetBlockUserById(req.UserId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById", err)
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.BlockUser = &pbUser.BlockUser{
|
|
||||||
User: &pbUser.User{
|
|
||||||
ProfilePhoto: user.User.FaceURL,
|
|
||||||
Nickname: user.User.Nickname,
|
|
||||||
UserId: user.User.UserID,
|
|
||||||
IsBlock: true,
|
|
||||||
Birth: user.User.Birth.Format("2006-01-02"),
|
|
||||||
PhoneNumber: user.User.PhoneNumber,
|
|
||||||
Email: user.User.Email,
|
|
||||||
Gender: user.User.Gender,
|
|
||||||
},
|
|
||||||
BeginDisableTime: (user.BeginDisableTime).String(),
|
|
||||||
EndDisableTime: (user.EndDisableTime).String(),
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) DeleteUser(_ context.Context, req *pbUser.DeleteUserReq) (*pbUser.DeleteUserResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
|
||||||
resp := &pbUser.DeleteUserResp{}
|
|
||||||
if row := imdb.DeleteUser(req.UserId); row == 0 {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "delete failed", "delete rows:", row)
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
11
pkg/base_info/common.go
Normal file
11
pkg/base_info/common.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package base_info
|
||||||
|
|
||||||
|
type RequestPagination struct {
|
||||||
|
PageNumber int `json:"pageNumber" binding:"required"`
|
||||||
|
ShowNumber int `json:"showNumber" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResponsePagination struct {
|
||||||
|
CurrentPage int `json:"currentPage"`
|
||||||
|
ShowNumber int `json:"showNumber"`
|
||||||
|
}
|
@ -93,3 +93,40 @@ type CheckMsgIsSendSuccessResp struct {
|
|||||||
CommResp
|
CommResp
|
||||||
Status int32 `json:"status"`
|
Status int32 `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetUsersReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
UserName string `json:"userName"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
PageNumber int32 `json:"pageNumber" binding:"required"`
|
||||||
|
ShowNumber int32 `json:"showNumber" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CMSUser struct {
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
Nickname string `json:"nickname"`
|
||||||
|
FaceURL string `json:"faceURL"`
|
||||||
|
Gender int32 `json:"gender"`
|
||||||
|
PhoneNumber string `json:"phoneNumber"`
|
||||||
|
Birth uint32 `json:"birth"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
Ex string `json:"ex"`
|
||||||
|
CreateIp string `json:"createIp"`
|
||||||
|
CreateTime uint32 `json:"createTime"`
|
||||||
|
LastLoginIp string `json:"LastLoginIp"`
|
||||||
|
LastLoginTime uint32 `json:"LastLoginTime"`
|
||||||
|
AppMangerLevel int32 `json:"appMangerLevel"`
|
||||||
|
GlobalRecvMsgOpt int32 `json:"globalRecvMsgOpt"`
|
||||||
|
IsBlock bool `json:"isBlock"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUsersResp struct {
|
||||||
|
CommResp
|
||||||
|
Data struct {
|
||||||
|
UserList []*CMSUser `json:"userList"`
|
||||||
|
TotalNum int32 `json:"totalNum"`
|
||||||
|
CurrentPage int32 `json:"currentPage"`
|
||||||
|
ShowNumber int32 `json:"showNumber"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
@ -7,21 +7,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ApiUserInfo struct {
|
type ApiUserInfo struct {
|
||||||
UserID string `json:"userID" binding:"required,min=1,max=64" swaggo:"true,用户ID,"`
|
UserID string `json:"userID" binding:"required,min=1,max=64" swaggo:"true,用户ID,"`
|
||||||
Nickname string `json:"nickname" binding:"omitempty,min=1,max=64" swaggo:"true,my id,19"`
|
Nickname string `json:"nickname" binding:"omitempty,min=1,max=64" swaggo:"true,my id,19"`
|
||||||
FaceURL string `json:"faceURL" binding:"omitempty,max=1024"`
|
FaceURL string `json:"faceURL" binding:"omitempty,max=1024"`
|
||||||
Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
|
Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
|
||||||
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`
|
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`
|
||||||
Birth uint32 `json:"birth" binding:"omitempty"`
|
Birth uint32 `json:"birth" binding:"omitempty"`
|
||||||
Email string `json:"email" binding:"omitempty,max=64"`
|
Email string `json:"email" binding:"omitempty,max=64"`
|
||||||
CreateIp string `json:"createIp" binding:"omitempty,max=15"`
|
CreateTime int64 `json:"createTime"`
|
||||||
CreateTime int64 `json:"createTime"`
|
LoginLimit int32 `json:"loginLimit" binding:"omitempty"`
|
||||||
LastLoginIp string `json:"LastLoginIp" binding:"omitempty,max=15"`
|
Ex string `json:"ex" binding:"omitempty,max=1024"`
|
||||||
LastLoginTime int64 `json:"lastLoginTime"`
|
|
||||||
LoginTimes int32 `json:"loginTimes" binding:"omitempty"`
|
|
||||||
LoginLimit int32 `json:"loginLimit" binding:"omitempty"`
|
|
||||||
Ex string `json:"ex" binding:"omitempty,max=1024"`
|
|
||||||
InvitationCode string `json:"invitationCode" binding:"omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//type Conversation struct {
|
//type Conversation struct {
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
import server_api_params "Open_IM/pkg/proto/sdk_ws"
|
import (
|
||||||
|
"Open_IM/pkg/base_info"
|
||||||
|
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
)
|
||||||
|
|
||||||
type AdminLoginRequest struct {
|
type AdminLoginRequest struct {
|
||||||
AdminName string `json:"admin_name" binding:"required"`
|
AdminName string `json:"adminID" binding:"required"`
|
||||||
Secret string `json:"secret" binding:"required"`
|
Secret string `json:"secret" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminLoginResponse struct {
|
type AdminLoginResponse struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
|
UserName string `json:"userName"`
|
||||||
|
FaceURL string `json:"faceURL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddUserRegisterAddFriendIDListRequest struct {
|
type AddUserRegisterAddFriendIDListRequest struct {
|
||||||
@ -30,10 +36,10 @@ type ReduceUserRegisterAddFriendIDListResponse struct {
|
|||||||
|
|
||||||
type GetUserRegisterAddFriendIDListRequest struct {
|
type GetUserRegisterAddFriendIDListRequest struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
RequestPaginationBody
|
base_info.RequestPagination
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUserRegisterAddFriendIDListResponse struct {
|
type GetUserRegisterAddFriendIDListResponse struct {
|
||||||
Users []*server_api_params.UserInfo `json:"users"`
|
Users []*server_api_params.UserInfo `json:"users"`
|
||||||
ResponsePagination
|
base_info.ResponsePagination
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
type RequestPagination struct {
|
type RequestPagination struct {
|
||||||
PageNumber int `form:"page_number" binding:"required"`
|
|
||||||
ShowNumber int `form:"show_number" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RequestPaginationBody struct {
|
|
||||||
PageNumber int `json:"pageNumber" binding:"required"`
|
PageNumber int `json:"pageNumber" binding:"required"`
|
||||||
ShowNumber int `json:"showNumber" binding:"required"`
|
ShowNumber int `json:"showNumber" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResponsePagination struct {
|
type ResponsePagination struct {
|
||||||
CurrentPage int `json:"current_number" binding:"required"`
|
CurrentPage int `json:"currentPage"`
|
||||||
ShowNumber int `json:"show_number" binding:"required"`
|
ShowNumber int `json:"showNumber"`
|
||||||
}
|
}
|
||||||
|
25
pkg/cms_api_struct/friend.go
Normal file
25
pkg/cms_api_struct/friend.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package cms_api_struct
|
||||||
|
|
||||||
|
type GetFriendsReq struct {
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
FriendUserName string `json:"friendUserName"`
|
||||||
|
FriendUserID string `json:"friendUserID"`
|
||||||
|
RequestPagination
|
||||||
|
}
|
||||||
|
|
||||||
|
type FriendInfo struct {
|
||||||
|
OwnerUserID string `json:"ownerUserID"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
CreateTime uint32 `json:"createTime"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
Nickname string `json:"nickName"`
|
||||||
|
AddSource int32 `json:"addSource"`
|
||||||
|
OperatorUserID string `json:"operatorUserID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetFriendsResp struct {
|
||||||
|
ResponsePagination
|
||||||
|
FriendInfoList []*FriendInfo `json:"friendInfoList"`
|
||||||
|
FriendNums int32 `json:"friendNums"`
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
type GroupResponse struct {
|
type GroupResponse struct {
|
||||||
GroupOwnerName string `json:"GroupOwnerName"`
|
GroupOwnerName string `json:"GroupOwnerName"`
|
||||||
GroupOwnerID string `json:"GroupOwnerID"`
|
GroupOwnerID string `json:"GroupOwnerID"`
|
||||||
//*server_api_params.GroupInfo
|
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
GroupName string `json:"groupName"`
|
GroupName string `json:"groupName"`
|
||||||
Notification string `json:"notification"`
|
Notification string `json:"notification"`
|
||||||
@ -23,27 +22,11 @@ type GroupResponse struct {
|
|||||||
NotificationUserID string `json:"notificationUserID"`
|
NotificationUserID string `json:"notificationUserID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupByIDRequest struct {
|
|
||||||
GroupID string `form:"groupID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupByIDResponse struct {
|
|
||||||
GroupResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupRequest struct {
|
|
||||||
GroupName string `form:"groupName" binding:"required"`
|
|
||||||
RequestPagination
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupResponse struct {
|
|
||||||
Groups []GroupResponse `json:"groups"`
|
|
||||||
GroupNums int `json:"groupNums"`
|
|
||||||
ResponsePagination
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupsRequest struct {
|
type GetGroupsRequest struct {
|
||||||
RequestPagination
|
RequestPagination
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
GroupName string `json:"groupName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupsResponse struct {
|
type GetGroupsResponse struct {
|
||||||
@ -52,55 +35,10 @@ type GetGroupsResponse struct {
|
|||||||
ResponsePagination
|
ResponsePagination
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateGroupRequest struct {
|
|
||||||
GroupName string `json:"groupName" binding:"required"`
|
|
||||||
GroupMasterId string `json:"groupOwnerID" binding:"required"`
|
|
||||||
GroupMembers []string `json:"groupMembers" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateGroupResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMasterRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
UserId string `json:"userID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMasterResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMemberRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
UserId string `json:"userID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMemberRespones struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type BanGroupChatRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type BanGroupChatResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type BanPrivateChatRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type BanPrivateChatResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteGroupRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteGroupResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupMembersRequest struct {
|
type GetGroupMembersRequest struct {
|
||||||
GroupID string `form:"groupID" binding:"required"`
|
GroupID string `form:"groupID" binding:"required"`
|
||||||
UserName string `form:"userName"`
|
UserName string `form:"userName"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
RequestPagination
|
RequestPagination
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,41 +62,3 @@ type GetGroupMembersResponse struct {
|
|||||||
ResponsePagination
|
ResponsePagination
|
||||||
MemberNums int `json:"memberNums"`
|
MemberNums int `json:"memberNums"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupMemberRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
Members []string `json:"members" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GroupMemberOperateResponse struct {
|
|
||||||
Success []string `json:"success"`
|
|
||||||
Failed []string `json:"failed"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddGroupMembersRequest struct {
|
|
||||||
GroupMemberRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddGroupMembersResponse struct {
|
|
||||||
GroupMemberOperateResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type RemoveGroupMembersRequest struct {
|
|
||||||
GroupMemberRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type RemoveGroupMembersResponse struct {
|
|
||||||
GroupMemberOperateResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlterGroupInfoRequest struct {
|
|
||||||
GroupID string `json:"groupID"`
|
|
||||||
GroupName string `json:"groupName"`
|
|
||||||
Notification string `json:"notification"`
|
|
||||||
Introduction string `json:"introduction"`
|
|
||||||
ProfilePhoto string `json:"profilePhoto"`
|
|
||||||
GroupType int `json:"groupType"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlterGroupInfoResponse struct {
|
|
||||||
}
|
|
||||||
|
@ -1,50 +1,48 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
type BroadcastRequest struct {
|
import (
|
||||||
Message string `json:"message"`
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
}
|
)
|
||||||
|
|
||||||
type BroadcastResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type MassSendMassageRequest struct {
|
|
||||||
Message string `json:"message"`
|
|
||||||
Users []string `json:"users"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MassSendMassageResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetChatLogsRequest struct {
|
|
||||||
SessionType int `form:"session_type"`
|
|
||||||
ContentType int `form:"content_type"`
|
|
||||||
Content string `form:"content"`
|
|
||||||
UserId string `form:"user_id"`
|
|
||||||
GroupId string `form:"group_id"`
|
|
||||||
Date string `form:"date"`
|
|
||||||
|
|
||||||
|
type GetChatLogsReq struct {
|
||||||
|
SessionType int `json:"sessionType"`
|
||||||
|
ContentType int `json:"contentType"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
SendID string `json:"sendID"`
|
||||||
|
RecvID string `json:"recvID"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
SendTime string `json:"sendTime"`
|
||||||
RequestPagination
|
RequestPagination
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatLog struct {
|
type ChatLog struct {
|
||||||
SessionType int `json:"session_type"`
|
SendID string `json:"sendID,omitempty"`
|
||||||
ContentType int `json:"content_type"`
|
RecvID string `json:"recvID,omitempty"`
|
||||||
SenderNickName string `json:"sender_nick_name"`
|
GroupID string `json:"groupID,omitempty"`
|
||||||
SenderId string `json:"sender_id"`
|
ClientMsgID string `json:"clientMsgID,omitempty"`
|
||||||
SearchContent string `json:"search_content"`
|
ServerMsgID string `json:"serverMsgID,omitempty"`
|
||||||
WholeContent string `json:"whole_content"`
|
SenderPlatformID int32 `json:"senderPlatformID,omitempty"`
|
||||||
|
SenderNickname string `json:"senderNickname,omitempty"`
|
||||||
ReceiverNickName string `json:"receiver_nick_name,omitempty"`
|
SenderFaceURL string `json:"senderFaceURL,omitempty"`
|
||||||
ReceiverID string `json:"receiver_id,omitempty"`
|
SessionType int32 `json:"sessionType,omitempty"`
|
||||||
|
MsgFrom int32 `json:"msgFrom,omitempty"`
|
||||||
GroupName string `json:"group_name,omitempty"`
|
ContentType int32 `json:"contentType,omitempty"`
|
||||||
GroupId string `json:"group_id,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
|
Seq uint32 `json:"seq,omitempty"`
|
||||||
Date string `json:"date"`
|
SendTime int64 `json:"sendTime,omitempty"`
|
||||||
|
CreateTime int64 `json:"createTime,omitempty"`
|
||||||
|
Status int32 `json:"status,omitempty"`
|
||||||
|
Options map[string]bool `json:"options,omitempty"`
|
||||||
|
OfflinePushInfo *pbCommon.OfflinePushInfo `json:"offlinePushInfo,omitempty"`
|
||||||
|
AtUserIDList []string `json:"atUserIDList,omitempty"`
|
||||||
|
MsgDataList []byte `json:"msgDataList,omitempty"`
|
||||||
|
AttachedInfo string `json:"attachedInfo,omitempty"`
|
||||||
|
Ex string `json:"ex,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetChatLogsResponse struct {
|
type GetChatLogsResp struct {
|
||||||
ChatLogs []ChatLog `json:"chat_logs"`
|
ChatLogs []*ChatLog `json:"chatLogs"`
|
||||||
ChatLogsNum int `json:"log_nums"`
|
ChatLogsNum int `json:"logNums"`
|
||||||
ResponsePagination
|
ResponsePagination
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
package cms_api_struct
|
|
||||||
|
|
||||||
type GetStaffsResponse struct {
|
|
||||||
StaffsList []struct {
|
|
||||||
ProfilePhoto string `json:"profile_photo"`
|
|
||||||
NickName string `json:"nick_name"`
|
|
||||||
StaffId int `json:"staff_id"`
|
|
||||||
Position string `json:"position"`
|
|
||||||
EntryTime string `json:"entry_time"`
|
|
||||||
} `json:"staffs_list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetOrganizationsResponse struct {
|
|
||||||
OrganizationList []struct {
|
|
||||||
OrganizationId int `json:"organization_id"`
|
|
||||||
OrganizationName string `json:"organization_name"`
|
|
||||||
} `json:"organization_list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SquadResponse struct {
|
|
||||||
SquadList []struct {
|
|
||||||
SquadId int `json:"squad_id"`
|
|
||||||
SquadName string `json:"squad_name"`
|
|
||||||
} `json:"squad_list"`
|
|
||||||
}
|
|
@ -1,8 +1,9 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
type GetStatisticsRequest struct {
|
type GetStatisticsRequest struct {
|
||||||
From string `form:"from" binding:"required"`
|
From string `json:"from" binding:"required"`
|
||||||
To string `form:"to" binding:"required"`
|
To string `json:"to" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetMessageStatisticsRequest struct {
|
type GetMessageStatisticsRequest struct {
|
||||||
@ -10,16 +11,16 @@ type GetMessageStatisticsRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetMessageStatisticsResponse struct {
|
type GetMessageStatisticsResponse struct {
|
||||||
PrivateMessageNum int `json:"private_message_num"`
|
PrivateMessageNum int `json:"privateMessageNum"`
|
||||||
GroupMessageNum int `json:"group_message_num"`
|
GroupMessageNum int `json:"groupMessageNum"`
|
||||||
PrivateMessageNumList []struct {
|
PrivateMessageNumList []struct {
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
MessageNum int `json:"message_num"`
|
MessageNum int `json:"messageNum"`
|
||||||
} `json:"private_message_num_list"`
|
} `json:"privateMessageNumList"`
|
||||||
GroupMessageNumList []struct {
|
GroupMessageNumList []struct {
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
MessageNum int `json:"message_num"`
|
MessageNum int `json:"messageNum"`
|
||||||
} `json:"group_message_num_list"`
|
} `json:"groupMessageNumList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUserStatisticsRequest struct {
|
type GetUserStatisticsRequest struct {
|
||||||
@ -27,21 +28,21 @@ type GetUserStatisticsRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetUserStatisticsResponse struct {
|
type GetUserStatisticsResponse struct {
|
||||||
IncreaseUserNum int `json:"increase_user_num"`
|
IncreaseUserNum int `json:"increaseUserNum"`
|
||||||
ActiveUserNum int `json:"active_user_num"`
|
ActiveUserNum int `json:"activeUserNum"`
|
||||||
TotalUserNum int `json:"total_user_num"`
|
TotalUserNum int `json:"totalUserNum"`
|
||||||
IncreaseUserNumList []struct {
|
IncreaseUserNumList []struct {
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
IncreaseUserNum int `json:"increase_user_num"`
|
IncreaseUserNum int `json:"increaseUserNum"`
|
||||||
} `json:"increase_user_num_list"`
|
} `json:"increaseUserNumList"`
|
||||||
ActiveUserNumList []struct {
|
ActiveUserNumList []struct {
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
ActiveUserNum int `json:"active_user_num"`
|
ActiveUserNum int `json:"activeUserNum"`
|
||||||
} `json:"active_user_num_list"`
|
} `json:"activeUserNumList"`
|
||||||
TotalUserNumList []struct {
|
TotalUserNumList []struct {
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
TotalUserNum int `json:"total_user_num"`
|
TotalUserNum int `json:"totalUserNum"`
|
||||||
} `json:"total_user_num_list"`
|
} `json:"totalUserNumList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupStatisticsRequest struct {
|
type GetGroupStatisticsRequest struct {
|
||||||
@ -50,16 +51,16 @@ type GetGroupStatisticsRequest struct {
|
|||||||
|
|
||||||
// 群聊统计
|
// 群聊统计
|
||||||
type GetGroupStatisticsResponse struct {
|
type GetGroupStatisticsResponse struct {
|
||||||
IncreaseGroupNum int `json:"increase_group_num"`
|
IncreaseGroupNum int `json:"increaseGroupNum"`
|
||||||
TotalGroupNum int `json:"total_group_num"`
|
TotalGroupNum int `json:"totalGroupNum"`
|
||||||
IncreaseGroupNumList []struct {
|
IncreaseGroupNumList []struct {
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
IncreaseGroupNum int `json:"increase_group_num"`
|
IncreaseGroupNum int `json:"increaseGroupNum"`
|
||||||
} `json:"increase_group_num_list"`
|
} `json:"increaseGroupNumList"`
|
||||||
TotalGroupNumList []struct {
|
TotalGroupNumList []struct {
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
TotalGroupNum int `json:"total_group_num"`
|
TotalGroupNum int `json:"totalGroupNum"`
|
||||||
} `json:"total_group_num_list"`
|
} `json:"totalGroupNumList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetActiveUserRequest struct {
|
type GetActiveUserRequest struct {
|
||||||
@ -69,10 +70,10 @@ type GetActiveUserRequest struct {
|
|||||||
|
|
||||||
type GetActiveUserResponse struct {
|
type GetActiveUserResponse struct {
|
||||||
ActiveUserList []struct {
|
ActiveUserList []struct {
|
||||||
NickName string `json:"nick_name"`
|
NickName string `json:"nickName"`
|
||||||
UserId string `json:"user_id"`
|
UserId string `json:"userID"`
|
||||||
MessageNum int `json:"message_num"`
|
MessageNum int `json:"messageNum"`
|
||||||
} `json:"active_user_list"`
|
} `json:"activeUserList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetActiveGroupRequest struct {
|
type GetActiveGroupRequest struct {
|
||||||
@ -82,8 +83,8 @@ type GetActiveGroupRequest struct {
|
|||||||
|
|
||||||
type GetActiveGroupResponse struct {
|
type GetActiveGroupResponse struct {
|
||||||
ActiveGroupList []struct {
|
ActiveGroupList []struct {
|
||||||
GroupName string `json:"group_name"`
|
GroupName string `json:"groupName"`
|
||||||
GroupId string `json:"group_id"`
|
GroupId string `json:"groupID"`
|
||||||
MessageNum int `json:"message_num"`
|
MessageNum int `json:"messageNum"`
|
||||||
} `json:"active_group_list"`
|
} `json:"activeGroupList"`
|
||||||
}
|
}
|
||||||
|
@ -1,79 +1,31 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
type UserResponse struct {
|
type UserResponse struct {
|
||||||
ProfilePhoto string `json:"profile_photo"`
|
FaceURL string `json:"faceURL"`
|
||||||
Nickname string `json:"nick_name"`
|
Nickname string `json:"nickName"`
|
||||||
UserId string `json:"user_id"`
|
UserID string `json:"userID"`
|
||||||
CreateTime string `json:"create_time,omitempty"`
|
CreateTime string `json:"createTime,omitempty"`
|
||||||
CreateIp string `json:"create_ip,omitempty"`
|
CreateIp string `json:"createIp,omitempty"`
|
||||||
LastLoginTime string `json:"last_login_time,omitempty"`
|
LastLoginTime string `json:"lastLoginTime,omitempty"`
|
||||||
LastLoginIp string `json:"last_login_ip,omitempty"`
|
LastLoginIp string `json:"lastLoginIP,omitempty"`
|
||||||
LoginTimes int32 `json:"login_times"`
|
LoginTimes int32 `json:"loginTimes"`
|
||||||
LoginLimit int32 `json:"login_limit"`
|
LoginLimit int32 `json:"loginLimit"`
|
||||||
IsBlock bool `json:"is_block"`
|
IsBlock bool `json:"isBlock"`
|
||||||
PhoneNumber string `json:"phone_number"`
|
PhoneNumber string `json:"phoneNumber"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Birth string `json:"birth"`
|
Birth string `json:"birth"`
|
||||||
Gender int `json:"gender"`
|
Gender int `json:"gender"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUserRequest struct {
|
|
||||||
UserId string `form:"user_id" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUserResponse struct {
|
|
||||||
UserResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUsersRequest struct {
|
|
||||||
RequestPagination
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUsersResponse struct {
|
|
||||||
Users []*UserResponse `json:"users"`
|
|
||||||
ResponsePagination
|
|
||||||
UserNums int32 `json:"user_nums"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUsersByNameRequest struct {
|
|
||||||
UserName string `form:"user_name" binding:"required"`
|
|
||||||
RequestPagination
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetUsersByNameResponse struct {
|
|
||||||
Users []*UserResponse `json:"users"`
|
|
||||||
ResponsePagination
|
|
||||||
UserNums int32 `json:"user_nums"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResignUserRequest struct {
|
|
||||||
UserId string `json:"user_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResignUserResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlterUserRequest struct {
|
|
||||||
UserId string `json:"user_id" binding:"required"`
|
|
||||||
Nickname string `json:"nickname"`
|
|
||||||
PhoneNumber string `json:"phone_number" validate:"len=11"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Birth string `json:"birth"`
|
|
||||||
Gender string `json:"gender"`
|
|
||||||
Photo string `json:"photo"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlterUserResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddUserRequest struct {
|
type AddUserRequest struct {
|
||||||
PhoneNumber string `json:"phone_number" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
UserId string `json:"user_id" binding:"required"`
|
PhoneNumber string `json:"phoneNumber" binding:"required"`
|
||||||
|
UserId string `json:"userID" binding:"required"`
|
||||||
Name string `json:"name" binding:"required"`
|
Name string `json:"name" binding:"required"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Birth string `json:"birth"`
|
Birth string `json:"birth"`
|
||||||
Gender string `json:"gender"`
|
Gender string `json:"gender"`
|
||||||
Photo string `json:"photo"`
|
FaceURL string `json:"faceURL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddUserResponse struct {
|
type AddUserResponse struct {
|
||||||
@ -81,46 +33,34 @@ type AddUserResponse struct {
|
|||||||
|
|
||||||
type BlockUser struct {
|
type BlockUser struct {
|
||||||
UserResponse
|
UserResponse
|
||||||
BeginDisableTime string `json:"begin_disable_time"`
|
BeginDisableTime string `json:"beginDisableTime"`
|
||||||
EndDisableTime string `json:"end_disable_time"`
|
EndDisableTime string `json:"endDisableTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockUserRequest struct {
|
type BlockUserRequest struct {
|
||||||
UserId string `json:"user_id" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
EndDisableTime string `json:"end_disable_time" binding:"required"`
|
UserID string `json:"userID" binding:"required"`
|
||||||
|
EndDisableTime string `json:"endDisableTime" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockUserResponse struct {
|
type BlockUserResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnblockUserRequest struct {
|
type UnblockUserRequest struct {
|
||||||
UserId string `json:"user_id" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
UserID string `json:"userID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UnBlockUserResponse struct {
|
type UnBlockUserResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetBlockUsersRequest struct {
|
type GetBlockUsersRequest struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
RequestPagination
|
RequestPagination
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetBlockUsersResponse struct {
|
type GetBlockUsersResponse struct {
|
||||||
BlockUsers []BlockUser `json:"block_users"`
|
BlockUsers []BlockUser `json:"blockUsers"`
|
||||||
ResponsePagination
|
ResponsePagination
|
||||||
UserNums int32 `json:"user_nums"`
|
UserNums int32 `json:"userNums"`
|
||||||
}
|
|
||||||
|
|
||||||
type GetBlockUserRequest struct {
|
|
||||||
UserId string `form:"user_id" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetBlockUserResponse struct {
|
|
||||||
BlockUser
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteUserRequest struct {
|
|
||||||
UserId string `json:"user_id" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteUserResponse struct {
|
|
||||||
}
|
}
|
||||||
|
@ -229,6 +229,12 @@ const (
|
|||||||
WorkMomentCommentNotification = 0
|
WorkMomentCommentNotification = 0
|
||||||
WorkMomentLikeNotification = 1
|
WorkMomentLikeNotification = 1
|
||||||
WorkMomentAtUserNotification = 2
|
WorkMomentAtUserNotification = 2
|
||||||
|
|
||||||
|
// sendMsgStaus
|
||||||
|
MsgStatusNotExist = 0
|
||||||
|
MsgIsSending = 1
|
||||||
|
MsgSendSuccessed = 2
|
||||||
|
MsgSendFailed = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -259,10 +259,10 @@ func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string, operationID str
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) HandleSignalInfo(operationID string, msg *pbCommon.MsgData) error {
|
func (d *DataBases) HandleSignalInfo(operationID string, msg *pbCommon.MsgData, pushToUserID string) (isSend bool, err error) {
|
||||||
req := &pbRtc.SignalReq{}
|
req := &pbRtc.SignalReq{}
|
||||||
if err := proto.Unmarshal(msg.Content, req); err != nil {
|
if err := proto.Unmarshal(msg.Content, req); err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
//log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "SignalReq: ", req.String())
|
//log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "SignalReq: ", req.String())
|
||||||
var inviteeUserIDList []string
|
var inviteeUserIDList []string
|
||||||
@ -274,37 +274,40 @@ func (d *DataBases) HandleSignalInfo(operationID string, msg *pbCommon.MsgData)
|
|||||||
case *pbRtc.SignalReq_InviteInGroup:
|
case *pbRtc.SignalReq_InviteInGroup:
|
||||||
inviteeUserIDList = signalInfo.InviteInGroup.Invitation.InviteeUserIDList
|
inviteeUserIDList = signalInfo.InviteInGroup.Invitation.InviteeUserIDList
|
||||||
isInviteSignal = true
|
isInviteSignal = true
|
||||||
|
if !utils.IsContain(pushToUserID, inviteeUserIDList) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
case *pbRtc.SignalReq_HungUp, *pbRtc.SignalReq_Cancel, *pbRtc.SignalReq_Reject, *pbRtc.SignalReq_Accept:
|
case *pbRtc.SignalReq_HungUp, *pbRtc.SignalReq_Cancel, *pbRtc.SignalReq_Reject, *pbRtc.SignalReq_Accept:
|
||||||
return errors.New("signalInfo do not need offlinePush")
|
return false, errors.New("signalInfo do not need offlinePush")
|
||||||
default:
|
default:
|
||||||
log2.NewDebug(operationID, utils.GetSelfFuncName(), "req invalid type", string(msg.Content))
|
log2.NewDebug(operationID, utils.GetSelfFuncName(), "req invalid type", string(msg.Content))
|
||||||
return nil
|
return false, nil
|
||||||
}
|
}
|
||||||
if isInviteSignal {
|
if isInviteSignal {
|
||||||
log2.NewInfo(operationID, utils.GetSelfFuncName(), "invite userID list:", inviteeUserIDList)
|
log2.NewDebug(operationID, utils.GetSelfFuncName(), "invite userID list:", inviteeUserIDList)
|
||||||
for _, userID := range inviteeUserIDList {
|
for _, userID := range inviteeUserIDList {
|
||||||
log2.NewInfo(operationID, utils.GetSelfFuncName(), "invite userID:", userID)
|
log2.NewInfo(operationID, utils.GetSelfFuncName(), "invite userID:", userID)
|
||||||
timeout, err := strconv.Atoi(config.Config.Rtc.SignalTimeout)
|
timeout, err := strconv.Atoi(config.Config.Rtc.SignalTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
keyList := SignalListCache + userID
|
keyList := SignalListCache + userID
|
||||||
err = d.RDB.LPush(context.Background(), keyList, msg.ClientMsgID).Err()
|
err = d.RDB.LPush(context.Background(), keyList, msg.ClientMsgID).Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
err = d.RDB.Expire(context.Background(), keyList, time.Duration(timeout)*time.Second).Err()
|
err = d.RDB.Expire(context.Background(), keyList, time.Duration(timeout)*time.Second).Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
key := SignalCache + msg.ClientMsgID
|
key := SignalCache + msg.ClientMsgID
|
||||||
err = d.RDB.Set(context.Background(), key, msg.Content, time.Duration(timeout)*time.Second).Err()
|
err = d.RDB.Set(context.Background(), key, msg.Content, time.Duration(timeout)*time.Second).Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetSignalInfoFromCacheByClientMsgID(clientMsgID string) (invitationInfo *pbRtc.SignalInviteReq, err error) {
|
func (d *DataBases) GetSignalInfoFromCacheByClientMsgID(clientMsgID string) (invitationInfo *pbRtc.SignalInviteReq, err error) {
|
||||||
@ -395,12 +398,17 @@ func (d *DataBases) GetGetuiToken() (string, error) {
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) SetSendMsgFailedFlag(operationID string) error {
|
func (d *DataBases) SetSendMsgStatus(status int32, operationID string) error {
|
||||||
return d.RDB.Set(context.Background(), sendMsgFailedFlag+operationID, 1, time.Hour*24).Err()
|
return d.RDB.Set(context.Background(), sendMsgFailedFlag+operationID, status, time.Hour*24).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetSendMsgStatus(operationID string) error {
|
func (d *DataBases) GetSendMsgStatus(operationID string) (int, error) {
|
||||||
return d.RDB.Get(context.Background(), sendMsgFailedFlag+operationID).Err()
|
result, err := d.RDB.Get(context.Background(), sendMsgFailedFlag+operationID).Result()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
status, err := strconv.Atoi(result)
|
||||||
|
return status, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) SetFcmToken(account string, platformid int, fcmToken string, expireTime int64) (err error) {
|
func (d *DataBases) SetFcmToken(account string, platformid int, fcmToken string, expireTime int64) (err error) {
|
||||||
|
@ -15,7 +15,7 @@ type Register struct {
|
|||||||
type Invitation struct {
|
type Invitation struct {
|
||||||
InvitationCode string `gorm:"column:invitation_code;primary_key;type:varchar(32)"`
|
InvitationCode string `gorm:"column:invitation_code;primary_key;type:varchar(32)"`
|
||||||
CreateTime time.Time `gorm:"column:create_time"`
|
CreateTime time.Time `gorm:"column:create_time"`
|
||||||
UserID string `gorm:"column:user_id"`
|
UserID string `gorm:"column:user_id;index:userID"`
|
||||||
LastTime time.Time `gorm:"column:last_time"`
|
LastTime time.Time `gorm:"column:last_time"`
|
||||||
Status int32 `gorm:"column:status"`
|
Status int32 `gorm:"column:status"`
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ type Group struct {
|
|||||||
Notification string `gorm:"column:notification;size:255" json:"notification"`
|
Notification string `gorm:"column:notification;size:255" json:"notification"`
|
||||||
Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
|
Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
|
||||||
FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
|
FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
|
||||||
CreateTime time.Time `gorm:"column:create_time"`
|
CreateTime time.Time `gorm:"column:create_time;index:create_time"`
|
||||||
Ex string `gorm:"column:ex" json:"ex;size:1024" json:"ex"`
|
Ex string `gorm:"column:ex" json:"ex;size:1024" json:"ex"`
|
||||||
Status int32 `gorm:"column:status"`
|
Status int32 `gorm:"column:status"`
|
||||||
CreatorUserID string `gorm:"column:creator_user_id;size:64"`
|
CreatorUserID string `gorm:"column:creator_user_id;size:64"`
|
||||||
@ -176,18 +176,22 @@ type User struct {
|
|||||||
Birth time.Time `gorm:"column:birth"`
|
Birth time.Time `gorm:"column:birth"`
|
||||||
Email string `gorm:"column:email;size:64"`
|
Email string `gorm:"column:email;size:64"`
|
||||||
Ex string `gorm:"column:ex;size:1024"`
|
Ex string `gorm:"column:ex;size:1024"`
|
||||||
CreateTime time.Time `gorm:"column:create_time"`
|
CreateTime time.Time `gorm:"column:create_time;index:create_time"`
|
||||||
CreateIp string `gorm:"column:create_ip;size:15"`
|
|
||||||
LastLoginTime time.Time `gorm:"column:last_login_time"`
|
|
||||||
LastLoginIp string `gorm:"column:last_login_ip;size:15"`
|
|
||||||
LoginTimes int32 `gorm:"column:login_times"`
|
|
||||||
LoginLimit int32 `gorm:"column:login_limit"`
|
|
||||||
AppMangerLevel int32 `gorm:"column:app_manger_level"`
|
AppMangerLevel int32 `gorm:"column:app_manger_level"`
|
||||||
GlobalRecvMsgOpt int32 `gorm:"column:global_recv_msg_opt"`
|
GlobalRecvMsgOpt int32 `gorm:"column:global_recv_msg_opt"`
|
||||||
InvitationCode string `gorm:"column:invitation_code"`
|
|
||||||
status int32 `gorm:"column:status"`
|
status int32 `gorm:"column:status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserIpRecord struct {
|
||||||
|
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||||
|
CreateIp string `gorm:"column:create_ip;size:15"`
|
||||||
|
LastLoginTime time.Time `gorm:"column:last_login_time"`
|
||||||
|
LastLoginIp string `gorm:"column:last_login_ip;size:15"`
|
||||||
|
LoginTimes int32 `gorm:"column:login_times"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ip limit login
|
||||||
type IpLimit struct {
|
type IpLimit struct {
|
||||||
Ip string `gorm:"column:ip;primary_key;size:15"`
|
Ip string `gorm:"column:ip;primary_key;size:15"`
|
||||||
LimitRegister int32 `gorm:"column:limit_register;size:1"`
|
LimitRegister int32 `gorm:"column:limit_register;size:1"`
|
||||||
@ -196,6 +200,7 @@ type IpLimit struct {
|
|||||||
LimitTime time.Time `gorm:"column:limit_time"`
|
LimitTime time.Time `gorm:"column:limit_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ip login
|
||||||
type UserIpLimit struct {
|
type UserIpLimit struct {
|
||||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||||
Ip string `gorm:"column:ip;primary_key;size:15"`
|
Ip string `gorm:"column:ip;primary_key;size:15"`
|
||||||
@ -223,17 +228,17 @@ type Black struct {
|
|||||||
type ChatLog struct {
|
type ChatLog struct {
|
||||||
ServerMsgID string `gorm:"column:server_msg_id;primary_key;type:char(64)" json:"serverMsgID"`
|
ServerMsgID string `gorm:"column:server_msg_id;primary_key;type:char(64)" json:"serverMsgID"`
|
||||||
ClientMsgID string `gorm:"column:client_msg_id;type:char(64)" json:"clientMsgID"`
|
ClientMsgID string `gorm:"column:client_msg_id;type:char(64)" json:"clientMsgID"`
|
||||||
SendID string `gorm:"column:send_id;type:char(64)" json:"sendID"`
|
SendID string `gorm:"column:send_id;type:char(64);index:send_id,priority:2" json:"sendID"`
|
||||||
RecvID string `gorm:"column:recv_id;type:char(64)" json:"recvID"`
|
RecvID string `gorm:"column:recv_id;type:char(64);index:recv_id,priority:2" json:"recvID"`
|
||||||
SenderPlatformID int32 `gorm:"column:sender_platform_id" json:"senderPlatformID"`
|
SenderPlatformID int32 `gorm:"column:sender_platform_id" json:"senderPlatformID"`
|
||||||
SenderNickname string `gorm:"column:sender_nick_name;type:varchar(255)" json:"senderNickname"`
|
SenderNickname string `gorm:"column:sender_nick_name;type:varchar(255)" json:"senderNickname"`
|
||||||
SenderFaceURL string `gorm:"column:sender_face_url;type:varchar(255)" json:"senderFaceURL"`
|
SenderFaceURL string `gorm:"column:sender_face_url;type:varchar(255);" json:"senderFaceURL"`
|
||||||
SessionType int32 `gorm:"column:session_type" json:"sessionType"`
|
SessionType int32 `gorm:"column:session_type;index:session_type,priority:2;index:session_type_alone" json:"sessionType"`
|
||||||
MsgFrom int32 `gorm:"column:msg_from" json:"msgFrom"`
|
MsgFrom int32 `gorm:"column:msg_from" json:"msgFrom"`
|
||||||
ContentType int32 `gorm:"column:content_type" json:"contentType"`
|
ContentType int32 `gorm:"column:content_type;index:content_type,priority:2;index:content_type_alone" json:"contentType"`
|
||||||
Content string `gorm:"column:content;type:varchar(3000)" json:"content"`
|
Content string `gorm:"column:content;type:varchar(3000)" json:"content"`
|
||||||
Status int32 `gorm:"column:status" json:"status"`
|
Status int32 `gorm:"column:status" json:"status"`
|
||||||
SendTime time.Time `gorm:"column:send_time" json:"sendTime"`
|
SendTime time.Time `gorm:"column:send_time;index:sendTime;index:content_type,priority:1;index:session_type,priority:1;index:recv_id,priority:1;index:send_id,priority:1" json:"sendTime"`
|
||||||
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
|
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
|
||||||
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ func initMysqlDB() {
|
|||||||
Writer{},
|
Writer{},
|
||||||
logger.Config{
|
logger.Config{
|
||||||
SlowThreshold: 200 * time.Millisecond, // Slow SQL threshold
|
SlowThreshold: 200 * time.Millisecond, // Slow SQL threshold
|
||||||
LogLevel: logger.Error, // Log level
|
LogLevel: logger.Info, // Log level
|
||||||
IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger
|
IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger
|
||||||
Colorful: true, // Disable color
|
Colorful: true, // Disable color
|
||||||
},
|
},
|
||||||
|
@ -3,6 +3,7 @@ package im_mysql_model
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
_ "gorm.io/gorm"
|
_ "gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -74,3 +75,10 @@ func DeleteAllRegisterAddFriendIDList() error {
|
|||||||
err := db.DB.MysqlDB.DefaultGormDB().Where("1 = 1").Delete(&db.RegisterAddFriend{}).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Where("1 = 1").Delete(&db.RegisterAddFriend{}).Error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserIPLimit(userID string) (db.UserIpLimit, error) {
|
||||||
|
var limit db.UserIpLimit
|
||||||
|
limit.UserID = userID
|
||||||
|
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.UserIpLimit{}).Take(&limit).Error
|
||||||
|
return limit, err
|
||||||
|
}
|
||||||
|
@ -2,8 +2,10 @@ package im_mysql_model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InsertToFriend(toInsertFollow *db.Friend) error {
|
func InsertToFriend(toInsertFollow *db.Friend) error {
|
||||||
@ -51,3 +53,34 @@ func UpdateFriendComment(OwnerUserID, FriendUserID, Remark string) error {
|
|||||||
func DeleteSingleFriendInfo(OwnerUserID, FriendUserID string) error {
|
func DeleteSingleFriendInfo(OwnerUserID, FriendUserID string) error {
|
||||||
return db.DB.MysqlDB.DefaultGormDB().Table("friends").Where("owner_user_id=? and friend_user_id=?", OwnerUserID, FriendUserID).Delete(db.Friend{}).Error
|
return db.DB.MysqlDB.DefaultGormDB().Table("friends").Where("owner_user_id=? and friend_user_id=?", OwnerUserID, FriendUserID).Delete(db.Friend{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FriendUser struct {
|
||||||
|
db.Friend
|
||||||
|
Nickname string `gorm:"column:name;size:255"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserFriendsCMS(ownerUserID, friendUserName string, pageNumber, showNumber int32) (friendUserList []*FriendUser, count int64, err error) {
|
||||||
|
db := db.DB.MysqlDB.DefaultGormDB().Table("friends").
|
||||||
|
Select("friends.*, users.name").
|
||||||
|
Where("friends.owner_user_id=?", ownerUserID).Limit(int(showNumber)).
|
||||||
|
Joins("left join users on friends.friend_user_id = users.user_id").
|
||||||
|
Offset(int(showNumber * (pageNumber - 1)))
|
||||||
|
if friendUserName != "" {
|
||||||
|
db = db.Where("users.name like ?", fmt.Sprintf("%%%s%%", friendUserName))
|
||||||
|
}
|
||||||
|
if err = db.Count(&count).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = db.Find(&friendUserList).Error
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetFriendByIDCMS(ownerUserID, friendUserID string) (friendUser *FriendUser, err error) {
|
||||||
|
friendUser = &FriendUser{}
|
||||||
|
err = db.DB.MysqlDB.DefaultGormDB().Table("friends").
|
||||||
|
Select("friends.*, users.name").
|
||||||
|
Where("friends.owner_user_id=? and friends.friend_user_id=?", ownerUserID, friendUserID).
|
||||||
|
Joins("left join users on friends.friend_user_id = users.user_id").
|
||||||
|
Take(friendUser).Error
|
||||||
|
return friendUser, err
|
||||||
|
}
|
||||||
|
@ -213,9 +213,9 @@ func GetGroupMembersByGroupIdCMS(groupId string, userName string, showNumber, pa
|
|||||||
return groupMembers, nil
|
return groupMembers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupMembersCount(groupId, userName string) (int64, error) {
|
func GetGroupMembersCount(groupID, userName string) (int64, error) {
|
||||||
var count int64
|
var count int64
|
||||||
if err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupId).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Count(&count).Error; err != nil {
|
if err := db.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Count(&count).Error; err != nil {
|
||||||
return count, err
|
return count, err
|
||||||
}
|
}
|
||||||
return count, nil
|
return count, nil
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package im_mysql_model
|
package im_mysql_model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ type GroupWithNum struct {
|
|||||||
func GetGroupsByName(groupName string, pageNumber, showNumber int32) ([]GroupWithNum, error) {
|
func GetGroupsByName(groupName string, pageNumber, showNumber int32) ([]GroupWithNum, error) {
|
||||||
var groups []GroupWithNum
|
var groups []GroupWithNum
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("groups").Select("groups.*, (select count(*) from group_members where group_members.group_id=groups.group_id) as num").
|
err := db.DB.MysqlDB.DefaultGormDB().Table("groups").Select("groups.*, (select count(*) from group_members where group_members.group_id=groups.group_id) as num").
|
||||||
Where(fmt.Sprintf(" name like '%%%s%%' ", groupName)).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&groups).Error
|
Where(" name like ? and status != ?", fmt.Sprintf("%%%s%%", groupName), constant.GroupStatusDismissed).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&groups).Error
|
||||||
return groups, err
|
return groups, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +82,7 @@ func OperateGroupStatus(groupId string, groupStatus int32) error {
|
|||||||
|
|
||||||
func GetGroupsCountNum(group db.Group) (int32, error) {
|
func GetGroupsCountNum(group db.Group) (int32, error) {
|
||||||
var count int64
|
var count int64
|
||||||
if err := db.DB.MysqlDB.DefaultGormDB().Table("groups").Where(fmt.Sprintf(" name like '%%%s%%' ", group.GroupName)).Count(&count).Error; err != nil {
|
if err := db.DB.MysqlDB.DefaultGormDB().Table("groups").Where(" name like ? ", fmt.Sprintf("%%%s%%", group.GroupName)).Count(&count).Error; err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return int32(count), nil
|
return int32(count), nil
|
||||||
|
@ -3,9 +3,10 @@ package im_mysql_model
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/jinzhu/gorm"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/jinzhu/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,9 +106,12 @@ func CreateRandomString(strlen int) string {
|
|||||||
return string(result)
|
return string(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetInvitationCodes(showNumber, pageNumber, status int32) ([]db.Invitation, error) {
|
func GetInvitationCodes(showNumber, pageNumber, status int32) ([]db.Invitation, int64, error) {
|
||||||
var invitationList []db.Invitation
|
var invitationList []db.Invitation
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Model(db.Invitation{}).Limit(int(showNumber)).Offset(int(showNumber*(pageNumber-1))).Where("status=?", status).
|
db := db.DB.MysqlDB.DefaultGormDB().Model(db.Invitation{}).Where("status=?", status)
|
||||||
|
var count int64
|
||||||
|
err := db.Count(&count).Error
|
||||||
|
err = db.Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).
|
||||||
Order("create_time desc").Find(&invitationList).Error
|
Order("create_time desc").Find(&invitationList).Error
|
||||||
return invitationList, err
|
return invitationList, count, err
|
||||||
}
|
}
|
||||||
|
@ -74,3 +74,21 @@ func GetRegisterUserNum(ip string) ([]string, error) {
|
|||||||
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.Register{}).Where("register_ip=?", ip).Pluck("user_id", &userIDList).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.Register{}).Where("register_ip=?", ip).Pluck("user_id", &userIDList).Error
|
||||||
return userIDList, err
|
return userIDList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InsertIpRecord(userID, createIp string) error {
|
||||||
|
record := &db.UserIpRecord{UserID: userID, CreateIp: createIp, LastLoginTime: time.Now(), LoginTimes: 1}
|
||||||
|
err := db.DB.MysqlDB.DefaultGormDB().Model(&db.UserIpRecord{}).Create(record).Error
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateIpReocord(userID, ip string) (err error) {
|
||||||
|
record := &db.UserIpRecord{UserID: userID, LastLoginIp: ip, LastLoginTime: time.Now()}
|
||||||
|
result := db.DB.MysqlDB.DefaultGormDB().Model(&db.UserIpRecord{}).Where("user_id=?", userID).Updates(record).Updates("login_times = login_times + 1")
|
||||||
|
if result.Error != nil {
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
|
if result.RowsAffected == 0 {
|
||||||
|
err = InsertIpRecord(userID, ip)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package im_mysql_model
|
package im_mysql_model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
@ -10,10 +11,17 @@ import (
|
|||||||
func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog, error) {
|
func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog, error) {
|
||||||
var chatLogs []db.ChatLog
|
var chatLogs []db.ChatLog
|
||||||
db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").
|
db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").
|
||||||
Where(fmt.Sprintf(" content like '%%%s%%'", chatLog.Content)).
|
|
||||||
Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1)))
|
Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1)))
|
||||||
if chatLog.SessionType != 0 {
|
if chatLog.SendTime.Unix() > 0 {
|
||||||
|
db = db.Where("send_time > ? and send_time < ?", chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
|
||||||
|
}
|
||||||
|
if chatLog.Content != "" {
|
||||||
|
db = db.Where(" content like ? ", fmt.Sprintf("%%%s%%", chatLog.Content))
|
||||||
|
}
|
||||||
|
if chatLog.SessionType == 1 {
|
||||||
db = db.Where("session_type = ?", chatLog.SessionType)
|
db = db.Where("session_type = ?", chatLog.SessionType)
|
||||||
|
} else if chatLog.SessionType == 2 {
|
||||||
|
db = db.Where("session_type in (?)", []int{constant.GroupChatType, constant.SuperGroupChatType})
|
||||||
}
|
}
|
||||||
if chatLog.ContentType != 0 {
|
if chatLog.ContentType != 0 {
|
||||||
db = db.Where("content_type = ?", chatLog.ContentType)
|
db = db.Where("content_type = ?", chatLog.ContentType)
|
||||||
@ -24,20 +32,25 @@ func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog,
|
|||||||
if chatLog.RecvID != "" {
|
if chatLog.RecvID != "" {
|
||||||
db = db.Where("recv_id = ?", chatLog.RecvID)
|
db = db.Where("recv_id = ?", chatLog.RecvID)
|
||||||
}
|
}
|
||||||
if chatLog.SendTime.Unix() > 0 {
|
|
||||||
db = db.Where("send_time > ? and send_time < ?", chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
|
|
||||||
}
|
|
||||||
err := db.Find(&chatLogs).Error
|
err := db.Find(&chatLogs).Error
|
||||||
return chatLogs, err
|
return chatLogs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetChatLogCount(chatLog db.ChatLog) (int64, error) {
|
func GetChatLogCount(chatLog db.ChatLog) (int64, error) {
|
||||||
var chatLogs []db.ChatLog
|
|
||||||
var count int64
|
var count int64
|
||||||
db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").
|
db := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs")
|
||||||
Where(fmt.Sprintf(" content like '%%%s%%'", chatLog.Content))
|
if chatLog.SendTime.Unix() > 0 {
|
||||||
if chatLog.SessionType != 0 {
|
log.NewDebug("", utils.GetSelfFuncName(), chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
|
||||||
|
db = db.Where("send_time > ? and send_time < ?", chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
|
||||||
|
}
|
||||||
|
if chatLog.Content != "" {
|
||||||
|
db = db.Where(" content like ? ", fmt.Sprintf("%%%s%%", chatLog.Content))
|
||||||
|
}
|
||||||
|
if chatLog.SessionType == 1 {
|
||||||
db = db.Where("session_type = ?", chatLog.SessionType)
|
db = db.Where("session_type = ?", chatLog.SessionType)
|
||||||
|
} else if chatLog.SessionType == 2 {
|
||||||
|
db = db.Where("session_type in (?)", []int{constant.GroupChatType, constant.SuperGroupChatType})
|
||||||
}
|
}
|
||||||
if chatLog.ContentType != 0 {
|
if chatLog.ContentType != 0 {
|
||||||
db = db.Where("content_type = ?", chatLog.ContentType)
|
db = db.Where("content_type = ?", chatLog.ContentType)
|
||||||
@ -48,11 +61,7 @@ func GetChatLogCount(chatLog db.ChatLog) (int64, error) {
|
|||||||
if chatLog.RecvID != "" {
|
if chatLog.RecvID != "" {
|
||||||
db = db.Where("recv_id = ?", chatLog.RecvID)
|
db = db.Where("recv_id = ?", chatLog.RecvID)
|
||||||
}
|
}
|
||||||
if chatLog.SendTime.Unix() > 0 {
|
|
||||||
log.NewDebug("", utils.GetSelfFuncName(), chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
|
|
||||||
db = db.Where("send_time > ? and send_time < ?", chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
err := db.Find(&chatLogs).Count(&count).Error
|
err := db.Count(&count).Error
|
||||||
return count, err
|
return count, err
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package im_mysql_model
|
package im_mysql_model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetActiveUserNum(from, to time.Time) (int32, error) {
|
func GetActiveUserNum(from, to time.Time) (int32, error) {
|
||||||
var num int64
|
var num int64
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Select("count(distinct(send_id))").Where("create_time >= ? and create_time <= ?", from, to).Count(&num).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Select("count(distinct(send_id))").Where("send_time >= ? and send_time <= ?", from, to).Count(&num).Error
|
||||||
return int32(num), err
|
return int32(num), err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,13 +32,13 @@ func GetTotalUserNumByDate(to time.Time) (int32, error) {
|
|||||||
|
|
||||||
func GetPrivateMessageNum(from, to time.Time) (int32, error) {
|
func GetPrivateMessageNum(from, to time.Time) (int32, error) {
|
||||||
var num int64
|
var num int64
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Where("create_time >= ? and create_time <= ? and session_type = ?", from, to, 1).Count(&num).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Where("send_time >= ? and send_time <= ? and session_type = ?", from, to, 1).Count(&num).Error
|
||||||
return int32(num), err
|
return int32(num), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupMessageNum(from, to time.Time) (int32, error) {
|
func GetGroupMessageNum(from, to time.Time) (int32, error) {
|
||||||
var num int64
|
var num int64
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Where("create_time >= ? and create_time <= ? and session_type = ?", from, to, 2).Count(&num).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Where("send_time >= ? and send_time <= ? and session_type = ?", from, to, 2).Count(&num).Error
|
||||||
return int32(num), err
|
return int32(num), err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ type activeGroup struct {
|
|||||||
|
|
||||||
func GetActiveGroups(from, to time.Time, limit int) ([]*activeGroup, error) {
|
func GetActiveGroups(from, to time.Time, limit int) ([]*activeGroup, error) {
|
||||||
var activeGroups []*activeGroup
|
var activeGroups []*activeGroup
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Select("recv_id, count(*) as message_num").Where("create_time >= ? and create_time <= ? and session_type = ?", from, to, 2).Group("recv_id").Limit(limit).Order("message_num DESC").Find(&activeGroups).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Select("recv_id, count(*) as message_num").Where("send_time >= ? and send_time <= ? and session_type in (?)", from, to, []int{constant.GroupChatType, constant.SuperGroupChatType}).Group("recv_id").Limit(limit).Order("message_num DESC").Find(&activeGroups).Error
|
||||||
for _, activeGroup := range activeGroups {
|
for _, activeGroup := range activeGroups {
|
||||||
group := db.Group{
|
group := db.Group{
|
||||||
GroupID: activeGroup.Id,
|
GroupID: activeGroup.Id,
|
||||||
@ -80,19 +81,23 @@ func GetActiveGroups(from, to time.Time, limit int) ([]*activeGroup, error) {
|
|||||||
|
|
||||||
type activeUser struct {
|
type activeUser struct {
|
||||||
Name string
|
Name string
|
||||||
Id string `gorm:"column:send_id"`
|
ID string `gorm:"column:send_id"`
|
||||||
MessageNum int `gorm:"column:message_num"`
|
MessageNum int `gorm:"column:message_num"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetActiveUsers(from, to time.Time, limit int) ([]*activeUser, error) {
|
func GetActiveUsers(from, to time.Time, limit int) ([]*activeUser, error) {
|
||||||
var activeUsers []*activeUser
|
var activeUsers []*activeUser
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Select("send_id, count(*) as message_num").Where("create_time >= ? and create_time <= ? and session_type = ?", from, to, 1).Group("send_id").Limit(limit).Order("message_num DESC").Find(&activeUsers).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Select("send_id, count(*) as message_num").Where("send_time >= ? and send_time <= ? and session_type = ?", from, to, constant.SingleChatType).Group("send_id").Limit(limit).Order("message_num DESC").Find(&activeUsers).Error
|
||||||
for _, activeUser := range activeUsers {
|
for _, activeUser := range activeUsers {
|
||||||
user := db.User{
|
user := db.User{
|
||||||
UserID: activeUser.Id,
|
UserID: activeUser.ID,
|
||||||
|
}
|
||||||
|
err = db.DB.MysqlDB.DefaultGormDB().Table("users").Select("user_id, name").Find(&user).Error
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
db.DB.MysqlDB.DefaultGormDB().Table("users").Select("user_id, name").Find(&user)
|
|
||||||
activeUser.Name = user.Nickname
|
activeUser.Name = user.Nickname
|
||||||
|
activeUser.ID = user.UserID
|
||||||
}
|
}
|
||||||
return activeUsers, err
|
return activeUsers, err
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,14 @@ func InsertInToUserBlackList(black db.Black) error {
|
|||||||
return db.DB.MysqlDB.DefaultGormDB().Table("blacks").Create(black).Error
|
return db.DB.MysqlDB.DefaultGormDB().Table("blacks").Create(black).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
//type Black struct {
|
// type Black struct {
|
||||||
// OwnerUserID string `gorm:"column:owner_user_id;primaryKey;"`
|
// OwnerUserID string `gorm:"column:owner_user_id;primaryKey;"`
|
||||||
// BlockUserID string `gorm:"column:block_user_id;primaryKey;"`
|
// BlockUserID string `gorm:"column:block_user_id;primaryKey;"`
|
||||||
// CreateTime time.Time `gorm:"column:create_time"`
|
// CreateTime time.Time `gorm:"column:create_time"`
|
||||||
// AddSource int32 `gorm:"column:add_source"`
|
// AddSource int32 `gorm:"column:add_source"`
|
||||||
// OperatorUserID int32 `gorm:"column:operator_user_id"`
|
// OperatorUserID int32 `gorm:"column:operator_user_id"`
|
||||||
// Ex string `gorm:"column:ex"`
|
// Ex string `gorm:"column:ex"`
|
||||||
//}
|
// }
|
||||||
|
|
||||||
func CheckBlack(ownerUserID, blockUserID string) error {
|
func CheckBlack(ownerUserID, blockUserID string) error {
|
||||||
var black db.Black
|
var black db.Black
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -43,9 +44,6 @@ func UserRegister(user db.User) error {
|
|||||||
if user.Birth.Unix() < 0 {
|
if user.Birth.Unix() < 0 {
|
||||||
user.Birth = utils.UnixSecondToTime(0)
|
user.Birth = utils.UnixSecondToTime(0)
|
||||||
}
|
}
|
||||||
user.LastLoginTime = time.Now()
|
|
||||||
user.LoginTimes = 0
|
|
||||||
user.LastLoginIp = user.CreateIp
|
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("users").Create(&user).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Table("users").Create(&user).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -53,11 +51,6 @@ func UserRegister(user db.User) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteUser(userID string) (i int64) {
|
|
||||||
i = db.DB.MysqlDB.DefaultGormDB().Table("users").Where("user_id=?", userID).Delete(db.User{}).RowsAffected
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAllUser() ([]db.User, error) {
|
func GetAllUser() ([]db.User, error) {
|
||||||
var userList []db.User
|
var userList []db.User
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("users").Find(&userList).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Table("users").Find(&userList).Error
|
||||||
@ -124,31 +117,21 @@ func GetUsers(showNumber, pageNumber int32) ([]db.User, error) {
|
|||||||
return users, err
|
return users, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddUser(userId string, phoneNumber string, name string, email string, gender string, photo string, birth string) error {
|
func AddUser(userID string, phoneNumber string, name string, email string, gender int32, faceURL string, birth uint32) error {
|
||||||
_gender, _err := strconv.Atoi(gender)
|
_birth, _err := time.ParseInLocation("2006-01-02", strconv.Itoa(int(birth)), time.Local)
|
||||||
if _err != nil {
|
|
||||||
_gender = 0
|
|
||||||
}
|
|
||||||
_birth, _err := time.ParseInLocation("2006-01-02", birth, time.Local)
|
|
||||||
if _err != nil {
|
if _err != nil {
|
||||||
_birth = time.Now()
|
_birth = time.Now()
|
||||||
}
|
}
|
||||||
user := db.User{
|
user := db.User{
|
||||||
UserID: userId,
|
UserID: userID,
|
||||||
Nickname: name,
|
Nickname: name,
|
||||||
FaceURL: photo,
|
FaceURL: faceURL,
|
||||||
Gender: int32(_gender),
|
Gender: gender,
|
||||||
PhoneNumber: phoneNumber,
|
PhoneNumber: phoneNumber,
|
||||||
Birth: _birth,
|
Birth: _birth,
|
||||||
Email: email,
|
Email: email,
|
||||||
Ex: "",
|
Ex: "",
|
||||||
CreateTime: time.Now(),
|
CreateTime: time.Now(),
|
||||||
CreateIp: "",
|
|
||||||
LastLoginTime: time.Now(),
|
|
||||||
LastLoginIp: "",
|
|
||||||
LoginTimes: 0,
|
|
||||||
LoginLimit: 0,
|
|
||||||
InvitationCode: "",
|
|
||||||
}
|
}
|
||||||
result := db.DB.MysqlDB.DefaultGormDB().Table("users").Create(&user)
|
result := db.DB.MysqlDB.DefaultGormDB().Table("users").Create(&user)
|
||||||
return result.Error
|
return result.Error
|
||||||
@ -163,8 +146,13 @@ func UserIsBlock(userId string) (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func BlockUser(userId, endDisableTime string) error {
|
func UsersIsBlock(userIDList []string) (inBlockUserIDList []string, err error) {
|
||||||
user, err := GetUserByUserID(userId)
|
err = db.DB.MysqlDB.DefaultGormDB().Table("black_lists").Where("uid in (?) and end_disable_time > now()", userIDList).Pluck("uid", &inBlockUserIDList).Error
|
||||||
|
return inBlockUserIDList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func BlockUser(userID, endDisableTime string) error {
|
||||||
|
user, err := GetUserByUserID(userID)
|
||||||
if err != nil || user.UserID == "" {
|
if err != nil || user.UserID == "" {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -173,37 +161,25 @@ func BlockUser(userId, endDisableTime string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if end.Before(time.Now()) {
|
if end.Before(time.Now()) {
|
||||||
return constant.ErrDB
|
return errors.New("endDisableTime is before now")
|
||||||
}
|
}
|
||||||
var blockUser db.BlackList
|
var blockUser db.BlackList
|
||||||
db.DB.MysqlDB.DefaultGormDB().Table("black_lists").Where("uid=?", userId).First(&blockUser)
|
db.DB.MysqlDB.DefaultGormDB().Table("black_lists").Where("uid=?", userID).First(&blockUser)
|
||||||
if blockUser.UserId != "" {
|
if blockUser.UserId != "" {
|
||||||
db.DB.MysqlDB.DefaultGormDB().Model(&blockUser).Where("uid=?", blockUser.UserId).Update("end_disable_time", end)
|
db.DB.MysqlDB.DefaultGormDB().Model(&blockUser).Where("uid=?", blockUser.UserId).Update("end_disable_time", end)
|
||||||
if user.LoginLimit != 2 {
|
|
||||||
db.DB.MysqlDB.DefaultGormDB().Table("users").Where("user_id=?", blockUser.UserId).Update("login_limit", 2)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
blockUser = db.BlackList{
|
blockUser = db.BlackList{
|
||||||
UserId: userId,
|
UserId: userID,
|
||||||
BeginDisableTime: time.Now(),
|
BeginDisableTime: time.Now(),
|
||||||
EndDisableTime: end,
|
EndDisableTime: end,
|
||||||
}
|
}
|
||||||
result := db.DB.MysqlDB.DefaultGormDB().Create(&blockUser)
|
err = db.DB.MysqlDB.DefaultGormDB().Create(&blockUser).Error
|
||||||
if result.Error == nil {
|
return err
|
||||||
if user.LoginLimit != 2 {
|
|
||||||
db.DB.MysqlDB.DefaultGormDB().Table("users").Where("user_id=?", blockUser.UserId).Update("login_limit", 2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.Error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnBlockUser(userId string) error {
|
func UnBlockUser(userID string) error {
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Where("uid=?", userId).Delete(&db.BlackList{}).Error
|
return db.DB.MysqlDB.DefaultGormDB().Where("uid=?", userID).Delete(&db.BlackList{}).Error
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return db.DB.MysqlDB.DefaultGormDB().Table("users").Where("user_id=?", userId).Update("login_limit", 0).Error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockUserInfo struct {
|
type BlockUserInfo struct {
|
||||||
@ -212,7 +188,7 @@ type BlockUserInfo struct {
|
|||||||
EndDisableTime time.Time
|
EndDisableTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBlockUserById(userId string) (BlockUserInfo, error) {
|
func GetBlockUserByID(userId string) (BlockUserInfo, error) {
|
||||||
var blockUserInfo BlockUserInfo
|
var blockUserInfo BlockUserInfo
|
||||||
blockUser := db.BlackList{
|
blockUser := db.BlackList{
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
@ -267,13 +243,24 @@ func GetBlockUsers(showNumber, pageNumber int32) ([]BlockUserInfo, error) {
|
|||||||
|
|
||||||
func GetUserByName(userName string, showNumber, pageNumber int32) ([]db.User, error) {
|
func GetUserByName(userName string, showNumber, pageNumber int32) ([]db.User, error) {
|
||||||
var users []db.User
|
var users []db.User
|
||||||
err := db.DB.MysqlDB.DefaultGormDB().Table("users").Where(fmt.Sprintf(" name like '%%%s%%' ", userName)).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&users).Error
|
err := db.DB.MysqlDB.DefaultGormDB().Table("users").Where(" name like ?", fmt.Sprintf("%%%s%%", userName)).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&users).Error
|
||||||
return users, err
|
return users, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUsersCount(user db.User) (int32, error) {
|
func GetUsersByNameAndID(content string, showNumber, pageNumber int32) ([]db.User, int64, error) {
|
||||||
|
var users []db.User
|
||||||
var count int64
|
var count int64
|
||||||
if err := db.DB.MysqlDB.DefaultGormDB().Table("users").Where(fmt.Sprintf(" name like '%%%s%%' ", user.Nickname)).Count(&count).Error; err != nil {
|
db := db.DB.MysqlDB.DefaultGormDB().Table("users").Where(" name like ? or user_id = ? ", fmt.Sprintf("%%%s%%", content), content)
|
||||||
|
if err := db.Count(&count).Error; err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
err := db.Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&users).Error
|
||||||
|
return users, count, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUsersCount(userName string) (int32, error) {
|
||||||
|
var count int64
|
||||||
|
if err := db.DB.MysqlDB.DefaultGormDB().Table("users").Where(" name like ? ", fmt.Sprintf("%%%s%%", userName)).Count(&count).Error; err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return int32(count), nil
|
return int32(count), nil
|
||||||
|
@ -75,7 +75,10 @@ func GetFriendIDListFromCache(userID string) ([]string, error) {
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(friendIDList)
|
bytes, err := json.Marshal(friendIDList)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
friendIDListStr, err := db.DB.Rc.Fetch(friendRelationCache+userID, time.Second*30*60, getFriendIDList)
|
friendIDListStr, err := db.DB.Rc.Fetch(friendRelationCache+userID, time.Second*30*60, getFriendIDList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -98,7 +101,10 @@ func GetBlackListFromCache(userID string) ([]string, error) {
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(blackIDList)
|
bytes, err := json.Marshal(blackIDList)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
blackIDListStr, err := db.DB.Rc.Fetch(blackListCache+userID, time.Second*30*60, getBlackIDList)
|
blackIDListStr, err := db.DB.Rc.Fetch(blackListCache+userID, time.Second*30*60, getBlackIDList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -120,7 +126,10 @@ func GetJoinedGroupIDListFromCache(userID string) ([]string, error) {
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(joinedGroupList)
|
bytes, err := json.Marshal(joinedGroupList)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
joinedGroupIDListStr, err := db.DB.Rc.Fetch(joinedGroupListCache+userID, time.Second*30*60, getJoinedGroupIDList)
|
joinedGroupIDListStr, err := db.DB.Rc.Fetch(joinedGroupListCache+userID, time.Second*30*60, getJoinedGroupIDList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -155,7 +164,10 @@ func GetGroupMemberIDListFromCache(groupID string) ([]string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(groupMemberIDList)
|
bytes, err := json.Marshal(groupMemberIDList)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, f)
|
groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -178,7 +190,10 @@ func GetUserInfoFromCache(userID string) (*db.User, error) {
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(userInfo)
|
bytes, err := json.Marshal(userInfo)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
userInfoStr, err := db.DB.Rc.Fetch(userInfoCache+userID, time.Second*30*60, getUserInfo)
|
userInfoStr, err := db.DB.Rc.Fetch(userInfoCache+userID, time.Second*30*60, getUserInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -200,7 +215,10 @@ func GetGroupMemberInfoFromCache(groupID, userID string) (*db.GroupMember, error
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(groupMemberInfo)
|
bytes, err := json.Marshal(groupMemberInfo)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
groupMemberInfoStr, err := db.DB.Rc.Fetch(groupMemberInfoCache+groupID+"-"+userID, time.Second*30*60, getGroupMemberInfo)
|
groupMemberInfoStr, err := db.DB.Rc.Fetch(groupMemberInfoCache+groupID+"-"+userID, time.Second*30*60, getGroupMemberInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -266,7 +284,10 @@ func GetAllGroupMembersInfoFromCache(groupID string) ([]*db.GroupMember, error)
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(groupMembers)
|
bytes, err := json.Marshal(groupMembers)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
groupMembersStr, err := db.DB.Rc.Fetch(groupAllMemberInfoCache+groupID, time.Second*30*60, getGroupMemberInfo)
|
groupMembersStr, err := db.DB.Rc.Fetch(groupAllMemberInfoCache+groupID, time.Second*30*60, getGroupMemberInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -288,7 +309,10 @@ func GetGroupInfoFromCache(groupID string) (*db.Group, error) {
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(groupInfo)
|
bytes, err := json.Marshal(groupInfo)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
groupInfoStr, err := db.DB.Rc.Fetch(groupInfoCache+groupID, time.Second*30*60, getGroupInfo)
|
groupInfoStr, err := db.DB.Rc.Fetch(groupInfoCache+groupID, time.Second*30*60, getGroupInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -310,7 +334,10 @@ func GetAllFriendsInfoFromCache(userID string) ([]*db.Friend, error) {
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(friendInfoList)
|
bytes, err := json.Marshal(friendInfoList)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
allFriendInfoStr, err := db.DB.Rc.Fetch(allFriendInfoCache+userID, time.Second*30*60, getAllFriendInfo)
|
allFriendInfoStr, err := db.DB.Rc.Fetch(allFriendInfoCache+userID, time.Second*30*60, getAllFriendInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -332,7 +359,10 @@ func GetAllDepartmentsFromCache() ([]db.Department, error) {
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(departmentList)
|
bytes, err := json.Marshal(departmentList)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
allDepartmentsStr, err := db.DB.Rc.Fetch(allDepartmentCache, time.Second*30*60, getAllDepartments)
|
allDepartmentsStr, err := db.DB.Rc.Fetch(allDepartmentCache, time.Second*30*60, getAllDepartments)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -354,7 +384,10 @@ func GetAllDepartmentMembersFromCache() ([]db.DepartmentMember, error) {
|
|||||||
return "", utils.Wrap(err, "")
|
return "", utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(departmentMembers)
|
bytes, err := json.Marshal(departmentMembers)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
allDepartmentMembersStr, err := db.DB.Rc.Fetch(allDepartmentMemberCache, time.Second*30*60, getAllDepartmentMembers)
|
allDepartmentMembersStr, err := db.DB.Rc.Fetch(allDepartmentMemberCache, time.Second*30*60, getAllDepartmentMembers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -379,7 +412,10 @@ func GetJoinedSuperGroupListFromCache(userID string) ([]string, error) {
|
|||||||
return "", errors.New("GroupIDList == 0")
|
return "", errors.New("GroupIDList == 0")
|
||||||
}
|
}
|
||||||
bytes, err := json.Marshal(userToSuperGroup.GroupIDList)
|
bytes, err := json.Marshal(userToSuperGroup.GroupIDList)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
joinedSuperGroupListStr, err := db.DB.Rc.Fetch(joinedSuperGroupListCache+userID, time.Second*30*60, getJoinedSuperGroupIDList)
|
joinedSuperGroupListStr, err := db.DB.Rc.Fetch(joinedSuperGroupListCache+userID, time.Second*30*60, getJoinedSuperGroupIDList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -445,7 +481,10 @@ func GetUserConversationIDListFromCache(userID string) ([]string, error) {
|
|||||||
}
|
}
|
||||||
log.NewDebug("", utils.GetSelfFuncName(), conversationIDList)
|
log.NewDebug("", utils.GetSelfFuncName(), conversationIDList)
|
||||||
bytes, err := json.Marshal(conversationIDList)
|
bytes, err := json.Marshal(conversationIDList)
|
||||||
return string(bytes), utils.Wrap(err, "")
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
conversationIDListStr, err := db.DB.Rc.Fetch(conversationIDListCache+userID, time.Second*30*60, getConversationIDList)
|
conversationIDListStr, err := db.DB.Rc.Fetch(conversationIDListCache+userID, time.Second*30*60, getConversationIDList)
|
||||||
var conversationIDList []string
|
var conversationIDList []string
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
package http
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
"fmt"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
|
|
||||||
//"Open_IM/pkg/cms_api_struct"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type BaseResp struct {
|
|
||||||
Code int32 `json:"code"`
|
|
||||||
ErrMsg string `json:"err_msg"`
|
|
||||||
Data interface{} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func RespHttp200(ctx *gin.Context, err error, data interface{}) {
|
|
||||||
var resp BaseResp
|
|
||||||
switch e := err.(type) {
|
|
||||||
case constant.ErrInfo:
|
|
||||||
resp.Code = e.ErrCode
|
|
||||||
resp.ErrMsg = e.ErrMsg
|
|
||||||
default:
|
|
||||||
s, ok := status.FromError(err)
|
|
||||||
if !ok {
|
|
||||||
fmt.Println("need grpc format error")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Code = int32(s.Code())
|
|
||||||
resp.ErrMsg = s.Message()
|
|
||||||
}
|
|
||||||
resp.Data = data
|
|
||||||
ctx.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// warp error
|
|
||||||
func WrapError(err constant.ErrInfo) error {
|
|
||||||
return status.Error(codes.Code(err.ErrCode), err.ErrMsg)
|
|
||||||
}
|
|
@ -42,7 +42,7 @@ func loggerInit(moduleName string) *Logger {
|
|||||||
}
|
}
|
||||||
writer := bufio.NewWriter(src)
|
writer := bufio.NewWriter(src)
|
||||||
logger.SetOutput(writer)
|
logger.SetOutput(writer)
|
||||||
//logger.SetOutput(os.Stdout)
|
// logger.SetOutput(os.Stdout)
|
||||||
//Log Console Print Style Setting
|
//Log Console Print Style Setting
|
||||||
logger.SetFormatter(&nested.Formatter{
|
logger.SetFormatter(&nested.Formatter{
|
||||||
TimestampFormat: "2006-01-02 15:04:05.000",
|
TimestampFormat: "2006-01-02 15:04:05.000",
|
||||||
|
@ -282,7 +282,7 @@ func GetDefaultGatewayConn4Unique(schema, etcdaddr, operationID string) []*grpc.
|
|||||||
if len(grpcConns) > 0 {
|
if len(grpcConns) > 0 {
|
||||||
return grpcConns
|
return grpcConns
|
||||||
}
|
}
|
||||||
log.NewWarn(operationID, utils.GetSelfFuncName(), " len(grpcConns) < 0 ", schema, etcdaddr, config.Config.RpcRegisterName.OpenImRelayName)
|
log.NewWarn(operationID, utils.GetSelfFuncName(), " len(grpcConns) == 0 ", schema, etcdaddr, config.Config.RpcRegisterName.OpenImRelayName)
|
||||||
grpcConns = GetDefaultGatewayConn4UniqueFromcfg(operationID)
|
grpcConns = GetDefaultGatewayConn4UniqueFromcfg(operationID)
|
||||||
log.NewDebug(operationID, utils.GetSelfFuncName(), config.Config.RpcRegisterName.OpenImRelayName, grpcConns)
|
log.NewDebug(operationID, utils.GetSelfFuncName(), config.Config.RpcRegisterName.OpenImRelayName, grpcConns)
|
||||||
return grpcConns
|
return grpcConns
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,15 +3,24 @@ option go_package = "./admin_cms;admin_cms";
|
|||||||
import "Open_IM/pkg/proto/sdk_ws/ws.proto";
|
import "Open_IM/pkg/proto/sdk_ws/ws.proto";
|
||||||
package admin_cms;
|
package admin_cms;
|
||||||
|
|
||||||
|
|
||||||
|
message CommonResp {
|
||||||
|
int32 errCode = 1;
|
||||||
|
string errMsg = 2;
|
||||||
|
}
|
||||||
|
|
||||||
message AdminLoginReq {
|
message AdminLoginReq {
|
||||||
string OperationID = 1;
|
string operationID = 1;
|
||||||
string AdminID = 2;
|
string adminID = 2;
|
||||||
string Secret = 3;
|
string secret = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
message AdminLoginResp {
|
message AdminLoginResp {
|
||||||
string token = 1;
|
string token = 1;
|
||||||
|
string userName = 2;
|
||||||
|
string faceURL = 3;
|
||||||
|
CommonResp commonResp = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AddUserRegisterAddFriendIDListReq {
|
message AddUserRegisterAddFriendIDListReq {
|
||||||
@ -20,7 +29,7 @@ message AddUserRegisterAddFriendIDListReq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message AddUserRegisterAddFriendIDListResp {
|
message AddUserRegisterAddFriendIDListResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReduceUserRegisterAddFriendIDListReq {
|
message ReduceUserRegisterAddFriendIDListReq {
|
||||||
@ -30,17 +39,278 @@ message ReduceUserRegisterAddFriendIDListReq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message ReduceUserRegisterAddFriendIDListResp {
|
message ReduceUserRegisterAddFriendIDListResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetUserRegisterAddFriendIDListReq {
|
message GetUserRegisterAddFriendIDListReq {
|
||||||
string operationID = 1;
|
string operationID = 1;
|
||||||
server_api_params.RequestPagination Pagination = 2;
|
server_api_params.RequestPagination pagination = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetUserRegisterAddFriendIDListResp {
|
message GetUserRegisterAddFriendIDListResp {
|
||||||
repeated server_api_params.UserInfo UserInfoList = 1;
|
repeated server_api_params.UserInfo userInfoList = 1;
|
||||||
|
server_api_params.ResponsePagination pagination = 2;
|
||||||
|
CommonResp commonResp = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetChatLogsReq {
|
||||||
|
string content = 1;
|
||||||
|
string sendID = 2;
|
||||||
|
string recvID = 3;
|
||||||
|
string sendTime = 4;
|
||||||
|
int32 sessionType = 5;
|
||||||
|
int32 contentType = 6;
|
||||||
|
server_api_params.RequestPagination pagination = 7;
|
||||||
|
string operationID = 8;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message ChatLog {
|
||||||
|
string serverMsgID = 1;
|
||||||
|
string clientMsgID = 2;
|
||||||
|
string sendID = 3;
|
||||||
|
string recvID = 4;
|
||||||
|
string groupID = 5;
|
||||||
|
string recvNickname = 6;
|
||||||
|
int32 senderPlatformID = 7;
|
||||||
|
string senderNickname = 8;
|
||||||
|
string senderFaceURL = 9;
|
||||||
|
string groupName = 10;
|
||||||
|
int32 sessionType = 11;
|
||||||
|
int32 msgFrom = 12;
|
||||||
|
int32 contentType = 13;
|
||||||
|
string content = 14;
|
||||||
|
int32 status = 15;
|
||||||
|
int64 sendTime = 16;
|
||||||
|
int64 createTime = 17;
|
||||||
|
string ex = 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetChatLogsResp {
|
||||||
|
repeated ChatLog chatLogs = 1;
|
||||||
|
server_api_params.ResponsePagination pagination = 2;
|
||||||
|
int32 chatLogsNum = 3;
|
||||||
|
CommonResp commonResp = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message StatisticsReq {
|
||||||
|
string from = 1;
|
||||||
|
string to = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetActiveUserReq{
|
||||||
|
StatisticsReq statisticsReq = 1;
|
||||||
|
string operationID = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UserResp{
|
||||||
|
string nickName = 1;
|
||||||
|
string userID = 2;
|
||||||
|
int32 messageNum = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetActiveUserResp {
|
||||||
|
repeated UserResp Users = 1;
|
||||||
|
CommonResp commonResp = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetActiveGroupReq{
|
||||||
|
StatisticsReq statisticsReq = 1;
|
||||||
|
string operationID = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GroupResp {
|
||||||
|
string GroupName = 1;
|
||||||
|
string GroupId = 2;
|
||||||
|
int32 MessageNum = 3;
|
||||||
|
CommonResp commonResp = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetActiveGroupResp {
|
||||||
|
repeated GroupResp Groups = 1;
|
||||||
|
CommonResp commonResp = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DateNumList {
|
||||||
|
string Date = 1;
|
||||||
|
int32 Num = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message GetMessageStatisticsReq {
|
||||||
|
StatisticsReq StatisticsReq = 1;
|
||||||
|
string OperationID = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message GetMessageStatisticsResp {
|
||||||
|
int32 PrivateMessageNum = 1;
|
||||||
|
int32 GroupMessageNum = 2;
|
||||||
|
repeated DateNumList PrivateMessageNumList = 3;
|
||||||
|
repeated DateNumList GroupMessageNumList = 4;
|
||||||
|
CommonResp commonResp = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetGroupStatisticsReq {
|
||||||
|
StatisticsReq StatisticsReq = 1;
|
||||||
|
string OperationID = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message GetGroupStatisticsResp {
|
||||||
|
int32 IncreaseGroupNum = 1;
|
||||||
|
int32 TotalGroupNum = 2;
|
||||||
|
repeated DateNumList IncreaseGroupNumList = 3;
|
||||||
|
repeated DateNumList TotalGroupNumList = 4;
|
||||||
|
CommonResp commonResp = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserStatisticsReq {
|
||||||
|
StatisticsReq StatisticsReq = 1;
|
||||||
|
string OperationID = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserStatisticsResp {
|
||||||
|
int32 IncreaseUserNum = 1;
|
||||||
|
int32 ActiveUserNum = 2;
|
||||||
|
int32 TotalUserNum = 3;
|
||||||
|
repeated DateNumList IncreaseUserNumList = 4;
|
||||||
|
repeated DateNumList ActiveUserNumList = 5;
|
||||||
|
repeated DateNumList TotalUserNumList = 6;
|
||||||
|
CommonResp commonResp = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GenerateInvitationCodeReq {
|
||||||
|
string operationID = 1;
|
||||||
|
int32 codeLen = 2;
|
||||||
|
int32 codeNum = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GenerateInvitationCodeResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetInvitationCodesReq {
|
||||||
|
string operationID = 1;
|
||||||
|
string code = 2;
|
||||||
|
int32 status = 3;
|
||||||
|
server_api_params.RequestPagination pagination = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message invitationCode {
|
||||||
|
string invitationCode = 1;
|
||||||
|
int32 createTime = 2;
|
||||||
|
int32 lastTime = 3;
|
||||||
|
string userID = 4;
|
||||||
|
int32 status = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetInvitationCodesResp {
|
||||||
|
repeated invitationCode invitationCodes = 1;
|
||||||
server_api_params.ResponsePagination Pagination = 2;
|
server_api_params.ResponsePagination Pagination = 2;
|
||||||
|
CommonResp commonResp = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryIPRegisterReq {
|
||||||
|
string operationID = 1;
|
||||||
|
string IP = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryIPRegisterResp {
|
||||||
|
string IP = 1;
|
||||||
|
int32 RegisterNum = 2;
|
||||||
|
int32 Status = 3;
|
||||||
|
repeated string userIDList = 4;
|
||||||
|
CommonResp commonResp = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddIPLimitReq {
|
||||||
|
string operationID = 1;
|
||||||
|
string IP = 2;
|
||||||
|
int32 limitTime = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddIPLimitResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoveIPLimitReq {
|
||||||
|
string operationID = 1;
|
||||||
|
string IP = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoveIPLimitResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryUserIDIPLimitLoginReq {
|
||||||
|
string operationID = 1;
|
||||||
|
string userID = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UserIPLimit {
|
||||||
|
string userID = 1;
|
||||||
|
string IP = 2;
|
||||||
|
int32 createTime = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QueryUserIDIPLimitLoginResp {
|
||||||
|
repeated UserIPLimit UserIPLimits = 1;
|
||||||
|
CommonResp commonResp = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddUserIPLimitLoginReq {
|
||||||
|
string userID = 1;
|
||||||
|
string operationID = 2;
|
||||||
|
string IP = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddUserIPLimitLoginResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoveUserIPLimitReq {
|
||||||
|
string userID = 1;
|
||||||
|
string operationID = 2;
|
||||||
|
string IP = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RemoveUserIPLimitResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetClientInitConfigReq {
|
||||||
|
string operationID = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetClientInitConfigResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetClientInitConfigReq {
|
||||||
|
string operationID = 1;
|
||||||
|
string discoverPageURL = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetClientInitConfigResp {
|
||||||
|
CommonResp commonResp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserFriendsReq {
|
||||||
|
string operationID = 1;
|
||||||
|
string userID = 2;
|
||||||
|
string friendUserID = 3;
|
||||||
|
string friendUserName = 4;
|
||||||
|
server_api_params.RequestPagination pagination = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message GetUserFriendsResp {
|
||||||
|
server_api_params.ResponsePagination pagination = 1;
|
||||||
|
repeated server_api_params.FriendInfo friendInfoList = 2;
|
||||||
|
int32 friendNums = 3;
|
||||||
|
CommonResp commonResp = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
service adminCMS {
|
service adminCMS {
|
||||||
@ -48,4 +318,28 @@ service adminCMS {
|
|||||||
rpc AddUserRegisterAddFriendIDList(AddUserRegisterAddFriendIDListReq) returns(AddUserRegisterAddFriendIDListResp);
|
rpc AddUserRegisterAddFriendIDList(AddUserRegisterAddFriendIDListReq) returns(AddUserRegisterAddFriendIDListResp);
|
||||||
rpc ReduceUserRegisterAddFriendIDList(ReduceUserRegisterAddFriendIDListReq) returns(ReduceUserRegisterAddFriendIDListResp);
|
rpc ReduceUserRegisterAddFriendIDList(ReduceUserRegisterAddFriendIDListReq) returns(ReduceUserRegisterAddFriendIDListResp);
|
||||||
rpc GetUserRegisterAddFriendIDList(GetUserRegisterAddFriendIDListReq) returns(GetUserRegisterAddFriendIDListResp);
|
rpc GetUserRegisterAddFriendIDList(GetUserRegisterAddFriendIDListReq) returns(GetUserRegisterAddFriendIDListResp);
|
||||||
|
|
||||||
|
|
||||||
|
rpc GetChatLogs(GetChatLogsReq) returns(GetChatLogsResp);
|
||||||
|
|
||||||
|
rpc GetActiveUser(GetActiveUserReq) returns(GetActiveUserResp);
|
||||||
|
rpc GetActiveGroup(GetActiveGroupReq) returns(GetActiveGroupResp);
|
||||||
|
rpc GetMessageStatistics(GetMessageStatisticsReq) returns(GetMessageStatisticsResp);
|
||||||
|
rpc GetGroupStatistics(GetGroupStatisticsReq) returns(GetGroupStatisticsResp);
|
||||||
|
rpc GetUserStatistics(GetUserStatisticsReq) returns(GetUserStatisticsResp);
|
||||||
|
|
||||||
|
rpc GenerateInvitationCode(GenerateInvitationCodeReq) returns(GenerateInvitationCodeResp);
|
||||||
|
rpc GetInvitationCodes(GetInvitationCodesReq) returns(GetInvitationCodesResp);
|
||||||
|
|
||||||
|
rpc QueryIPRegister(QueryIPRegisterReq) returns(QueryIPRegisterResp);
|
||||||
|
rpc AddIPLimit(AddIPLimitReq) returns(AddIPLimitResp);
|
||||||
|
rpc RemoveIPLimit(RemoveIPLimitReq) returns(RemoveIPLimitResp);
|
||||||
|
rpc QueryUserIDIPLimitLogin(QueryUserIDIPLimitLoginReq) returns(QueryUserIDIPLimitLoginResp);
|
||||||
|
rpc AddUserIPLimitLogin(AddUserIPLimitLoginReq) returns(AddUserIPLimitLoginResp);
|
||||||
|
rpc RemoveUserIPLimit(RemoveUserIPLimitReq) returns(RemoveUserIPLimitResp);
|
||||||
|
|
||||||
|
rpc GetClientInitConfig(GetClientInitConfigReq) returns(GetClientInitConfigResp);
|
||||||
|
rpc SetClientInitConfig(SetClientInitConfigReq) returns(SetClientInitConfigResp);
|
||||||
|
|
||||||
|
rpc GetUserFriends(GetUserFriendsReq) returns(GetUserFriendsResp);
|
||||||
}
|
}
|
@ -1,5 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package base;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -219,27 +219,19 @@ message CMSGroup {
|
|||||||
string GroupOwnerUserID = 3;
|
string GroupOwnerUserID = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupReq {
|
|
||||||
string GroupName = 1;
|
|
||||||
server_api_params.RequestPagination Pagination = 2;
|
|
||||||
string OperationID = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetGroupResp {
|
|
||||||
repeated CMSGroup CMSGroups = 1;
|
|
||||||
server_api_params.RequestPagination Pagination = 2;
|
|
||||||
int32 GroupNums = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetGroupsReq {
|
message GetGroupsReq {
|
||||||
server_api_params.RequestPagination Pagination = 1;
|
server_api_params.RequestPagination Pagination = 1;
|
||||||
string OperationID = 2;
|
string GroupName = 2;
|
||||||
|
string GroupID = 3;
|
||||||
|
string OperationID = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupsResp {
|
message GetGroupsResp {
|
||||||
repeated CMSGroup CMSGroups = 1;
|
repeated CMSGroup CMSGroups = 1;
|
||||||
server_api_params.RequestPagination Pagination = 2;
|
server_api_params.ResponsePagination Pagination = 2;
|
||||||
int32 GroupNum = 3;
|
int32 GroupNum = 3;
|
||||||
|
CommonResp commonResp = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupMemberReq {
|
message GetGroupMemberReq {
|
||||||
@ -247,26 +239,6 @@ message GetGroupMemberReq {
|
|||||||
string OperationID = 2;
|
string OperationID = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message OperateUserRoleReq {
|
|
||||||
string GroupID = 1;
|
|
||||||
string UserID = 2;
|
|
||||||
int32 RoleLevel = 3;
|
|
||||||
string OperationID = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message OperateUserRoleResp {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetGroupByIDReq {
|
|
||||||
string GroupID = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetGroupByIDResp {
|
|
||||||
CMSGroup CMSGroup = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetGroupMembersCMSReq {
|
message GetGroupMembersCMSReq {
|
||||||
string GroupID = 1;
|
string GroupID = 1;
|
||||||
string UserName = 2;
|
string UserName = 2;
|
||||||
@ -278,30 +250,7 @@ message GetGroupMembersCMSResp {
|
|||||||
repeated server_api_params.GroupMemberFullInfo members = 1;
|
repeated server_api_params.GroupMemberFullInfo members = 1;
|
||||||
server_api_params.ResponsePagination Pagination = 2;
|
server_api_params.ResponsePagination Pagination = 2;
|
||||||
int32 MemberNums = 3;
|
int32 MemberNums = 3;
|
||||||
}
|
CommonResp commonResp = 4;
|
||||||
|
|
||||||
message RemoveGroupMembersCMSReq {
|
|
||||||
string GroupID = 1;
|
|
||||||
repeated string UserIDList = 2;
|
|
||||||
string OperationID = 3;
|
|
||||||
string OpUserID = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message RemoveGroupMembersCMSResp {
|
|
||||||
repeated string success = 1;
|
|
||||||
repeated string failed = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AddGroupMembersCMSReq {
|
|
||||||
string GroupID = 1;
|
|
||||||
repeated string UserIDList = 2;
|
|
||||||
string OperationID = 3;
|
|
||||||
string OpUserID = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AddGroupMembersCMSResp {
|
|
||||||
repeated string success = 1;
|
|
||||||
repeated string failed = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message DismissGroupReq{
|
message DismissGroupReq{
|
||||||
@ -444,13 +393,9 @@ service group{
|
|||||||
rpc inviteUserToGroup(InviteUserToGroupReq) returns (InviteUserToGroupResp);
|
rpc inviteUserToGroup(InviteUserToGroupReq) returns (InviteUserToGroupResp);
|
||||||
rpc getGroupAllMember(GetGroupAllMemberReq) returns(GetGroupAllMemberResp);
|
rpc getGroupAllMember(GetGroupAllMemberReq) returns(GetGroupAllMemberResp);
|
||||||
|
|
||||||
rpc GetGroupByID(GetGroupByIDReq) returns(GetGroupByIDResp);
|
|
||||||
rpc GetGroup(GetGroupReq) returns(GetGroupResp);
|
|
||||||
rpc GetGroups(GetGroupsReq) returns(GetGroupsResp);
|
rpc GetGroups(GetGroupsReq) returns(GetGroupsResp);
|
||||||
rpc OperateUserRole(OperateUserRoleReq) returns(OperateUserRoleResp);
|
|
||||||
rpc GetGroupMembersCMS(GetGroupMembersCMSReq) returns(GetGroupMembersCMSResp);
|
rpc GetGroupMembersCMS(GetGroupMembersCMSReq) returns(GetGroupMembersCMSResp);
|
||||||
rpc RemoveGroupMembersCMS(RemoveGroupMembersCMSReq) returns(RemoveGroupMembersCMSResp);
|
|
||||||
rpc AddGroupMembersCMS(AddGroupMembersCMSReq) returns(AddGroupMembersCMSResp);
|
|
||||||
|
|
||||||
rpc DismissGroup(DismissGroupReq) returns(DismissGroupResp);
|
rpc DismissGroup(DismissGroupReq) returns(DismissGroupResp);
|
||||||
rpc MuteGroupMember(MuteGroupMemberReq) returns(MuteGroupMemberResp);
|
rpc MuteGroupMember(MuteGroupMemberReq) returns(MuteGroupMemberResp);
|
||||||
@ -459,7 +404,6 @@ service group{
|
|||||||
rpc CancelMuteGroup(CancelMuteGroupReq) returns(CancelMuteGroupResp);
|
rpc CancelMuteGroup(CancelMuteGroupReq) returns(CancelMuteGroupResp);
|
||||||
|
|
||||||
rpc SetGroupMemberNickname(SetGroupMemberNicknameReq) returns (SetGroupMemberNicknameResp);
|
rpc SetGroupMemberNickname(SetGroupMemberNicknameReq) returns (SetGroupMemberNicknameResp);
|
||||||
|
|
||||||
rpc GetJoinedSuperGroupList(GetJoinedSuperGroupListReq) returns (GetJoinedSuperGroupListResp);
|
rpc GetJoinedSuperGroupList(GetJoinedSuperGroupListReq) returns (GetJoinedSuperGroupListResp);
|
||||||
rpc GetSuperGroupsInfo(GetSuperGroupsInfoReq) returns (GetSuperGroupsInfoResp);
|
rpc GetSuperGroupsInfo(GetSuperGroupsInfoReq) returns (GetSuperGroupsInfoResp);
|
||||||
rpc SetGroupMemberInfo(SetGroupMemberInfoReq) returns (SetGroupMemberInfoResp);
|
rpc SetGroupMemberInfo(SetGroupMemberInfoReq) returns (SetGroupMemberInfoResp);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,71 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
import "Open_IM/pkg/proto/sdk_ws/ws.proto";
|
|
||||||
option go_package = "./message_cms;message_cms";
|
|
||||||
package message_cms;
|
|
||||||
|
|
||||||
message BoradcastMessageReq {
|
|
||||||
string Message = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message BoradcastMessageResp {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message MassSendMessageReq {
|
|
||||||
string Message = 1;
|
|
||||||
repeated string UserIds = 2;
|
|
||||||
string OperationID = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message MassSendMessageResp {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetChatLogsReq {
|
|
||||||
string Content = 1;
|
|
||||||
string UserId = 2;
|
|
||||||
string GroupId = 3;
|
|
||||||
string Date = 4;
|
|
||||||
int32 SessionType = 5;
|
|
||||||
int32 ContentType = 6;
|
|
||||||
server_api_params.RequestPagination Pagination = 7;
|
|
||||||
string OperationID = 8;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message ChatLogs {
|
|
||||||
int32 SessionType = 1;
|
|
||||||
int32 ContentType = 2;
|
|
||||||
string SenderNickName = 3;
|
|
||||||
string SenderId = 4;
|
|
||||||
string ReciverNickName = 5;
|
|
||||||
string ReciverId = 6;
|
|
||||||
string SearchContent = 7;
|
|
||||||
string WholeContent = 8;
|
|
||||||
string GroupId = 9;
|
|
||||||
string GroupName = 10;
|
|
||||||
string Date = 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetChatLogsResp {
|
|
||||||
repeated ChatLogs ChatLogs = 1;
|
|
||||||
server_api_params.ResponsePagination Pagination = 2;
|
|
||||||
int32 ChatLogsNum = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message WithdrawMessageReq {
|
|
||||||
string ServerMsgId = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message WithdrawMessageResp {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
service messageCMS {
|
|
||||||
rpc BoradcastMessage(BoradcastMessageReq) returns(BoradcastMessageResp);
|
|
||||||
rpc MassSendMessage(MassSendMessageReq) returns(MassSendMessageResp);
|
|
||||||
rpc GetChatLogs(GetChatLogsReq) returns(GetChatLogsResp);
|
|
||||||
rpc WithdrawMessage(WithdrawMessageReq) returns(WithdrawMessageResp);
|
|
||||||
}
|
|
@ -37,7 +37,7 @@ func (m *MsgDataToMQ) Reset() { *m = MsgDataToMQ{} }
|
|||||||
func (m *MsgDataToMQ) String() string { return proto.CompactTextString(m) }
|
func (m *MsgDataToMQ) String() string { return proto.CompactTextString(m) }
|
||||||
func (*MsgDataToMQ) ProtoMessage() {}
|
func (*MsgDataToMQ) ProtoMessage() {}
|
||||||
func (*MsgDataToMQ) Descriptor() ([]byte, []int) {
|
func (*MsgDataToMQ) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{0}
|
return fileDescriptor_msg_3997a326608d1183, []int{0}
|
||||||
}
|
}
|
||||||
func (m *MsgDataToMQ) XXX_Unmarshal(b []byte) error {
|
func (m *MsgDataToMQ) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_MsgDataToMQ.Unmarshal(m, b)
|
return xxx_messageInfo_MsgDataToMQ.Unmarshal(m, b)
|
||||||
@ -90,7 +90,7 @@ func (m *MsgDataToDB) Reset() { *m = MsgDataToDB{} }
|
|||||||
func (m *MsgDataToDB) String() string { return proto.CompactTextString(m) }
|
func (m *MsgDataToDB) String() string { return proto.CompactTextString(m) }
|
||||||
func (*MsgDataToDB) ProtoMessage() {}
|
func (*MsgDataToDB) ProtoMessage() {}
|
||||||
func (*MsgDataToDB) Descriptor() ([]byte, []int) {
|
func (*MsgDataToDB) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{1}
|
return fileDescriptor_msg_3997a326608d1183, []int{1}
|
||||||
}
|
}
|
||||||
func (m *MsgDataToDB) XXX_Unmarshal(b []byte) error {
|
func (m *MsgDataToDB) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_MsgDataToDB.Unmarshal(m, b)
|
return xxx_messageInfo_MsgDataToDB.Unmarshal(m, b)
|
||||||
@ -137,7 +137,7 @@ func (m *PushMsgDataToMQ) Reset() { *m = PushMsgDataToMQ{} }
|
|||||||
func (m *PushMsgDataToMQ) String() string { return proto.CompactTextString(m) }
|
func (m *PushMsgDataToMQ) String() string { return proto.CompactTextString(m) }
|
||||||
func (*PushMsgDataToMQ) ProtoMessage() {}
|
func (*PushMsgDataToMQ) ProtoMessage() {}
|
||||||
func (*PushMsgDataToMQ) Descriptor() ([]byte, []int) {
|
func (*PushMsgDataToMQ) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{2}
|
return fileDescriptor_msg_3997a326608d1183, []int{2}
|
||||||
}
|
}
|
||||||
func (m *PushMsgDataToMQ) XXX_Unmarshal(b []byte) error {
|
func (m *PushMsgDataToMQ) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_PushMsgDataToMQ.Unmarshal(m, b)
|
return xxx_messageInfo_PushMsgDataToMQ.Unmarshal(m, b)
|
||||||
@ -192,7 +192,7 @@ func (m *MsgDataToMongoByMQ) Reset() { *m = MsgDataToMongoByMQ{} }
|
|||||||
func (m *MsgDataToMongoByMQ) String() string { return proto.CompactTextString(m) }
|
func (m *MsgDataToMongoByMQ) String() string { return proto.CompactTextString(m) }
|
||||||
func (*MsgDataToMongoByMQ) ProtoMessage() {}
|
func (*MsgDataToMongoByMQ) ProtoMessage() {}
|
||||||
func (*MsgDataToMongoByMQ) Descriptor() ([]byte, []int) {
|
func (*MsgDataToMongoByMQ) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{3}
|
return fileDescriptor_msg_3997a326608d1183, []int{3}
|
||||||
}
|
}
|
||||||
func (m *MsgDataToMongoByMQ) XXX_Unmarshal(b []byte) error {
|
func (m *MsgDataToMongoByMQ) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_MsgDataToMongoByMQ.Unmarshal(m, b)
|
return xxx_messageInfo_MsgDataToMongoByMQ.Unmarshal(m, b)
|
||||||
@ -272,7 +272,7 @@ func (m *GetMaxAndMinSeqReq) Reset() { *m = GetMaxAndMinSeqReq{} }
|
|||||||
func (m *GetMaxAndMinSeqReq) String() string { return proto.CompactTextString(m) }
|
func (m *GetMaxAndMinSeqReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetMaxAndMinSeqReq) ProtoMessage() {}
|
func (*GetMaxAndMinSeqReq) ProtoMessage() {}
|
||||||
func (*GetMaxAndMinSeqReq) Descriptor() ([]byte, []int) {
|
func (*GetMaxAndMinSeqReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{4}
|
return fileDescriptor_msg_3997a326608d1183, []int{4}
|
||||||
}
|
}
|
||||||
func (m *GetMaxAndMinSeqReq) XXX_Unmarshal(b []byte) error {
|
func (m *GetMaxAndMinSeqReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_GetMaxAndMinSeqReq.Unmarshal(m, b)
|
return xxx_messageInfo_GetMaxAndMinSeqReq.Unmarshal(m, b)
|
||||||
@ -320,7 +320,7 @@ func (m *GetMaxAndMinSeqResp) Reset() { *m = GetMaxAndMinSeqResp{} }
|
|||||||
func (m *GetMaxAndMinSeqResp) String() string { return proto.CompactTextString(m) }
|
func (m *GetMaxAndMinSeqResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetMaxAndMinSeqResp) ProtoMessage() {}
|
func (*GetMaxAndMinSeqResp) ProtoMessage() {}
|
||||||
func (*GetMaxAndMinSeqResp) Descriptor() ([]byte, []int) {
|
func (*GetMaxAndMinSeqResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{5}
|
return fileDescriptor_msg_3997a326608d1183, []int{5}
|
||||||
}
|
}
|
||||||
func (m *GetMaxAndMinSeqResp) XXX_Unmarshal(b []byte) error {
|
func (m *GetMaxAndMinSeqResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_GetMaxAndMinSeqResp.Unmarshal(m, b)
|
return xxx_messageInfo_GetMaxAndMinSeqResp.Unmarshal(m, b)
|
||||||
@ -381,7 +381,7 @@ func (m *SendMsgReq) Reset() { *m = SendMsgReq{} }
|
|||||||
func (m *SendMsgReq) String() string { return proto.CompactTextString(m) }
|
func (m *SendMsgReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SendMsgReq) ProtoMessage() {}
|
func (*SendMsgReq) ProtoMessage() {}
|
||||||
func (*SendMsgReq) Descriptor() ([]byte, []int) {
|
func (*SendMsgReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{6}
|
return fileDescriptor_msg_3997a326608d1183, []int{6}
|
||||||
}
|
}
|
||||||
func (m *SendMsgReq) XXX_Unmarshal(b []byte) error {
|
func (m *SendMsgReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_SendMsgReq.Unmarshal(m, b)
|
return xxx_messageInfo_SendMsgReq.Unmarshal(m, b)
|
||||||
@ -437,7 +437,7 @@ func (m *SendMsgResp) Reset() { *m = SendMsgResp{} }
|
|||||||
func (m *SendMsgResp) String() string { return proto.CompactTextString(m) }
|
func (m *SendMsgResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SendMsgResp) ProtoMessage() {}
|
func (*SendMsgResp) ProtoMessage() {}
|
||||||
func (*SendMsgResp) Descriptor() ([]byte, []int) {
|
func (*SendMsgResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{7}
|
return fileDescriptor_msg_3997a326608d1183, []int{7}
|
||||||
}
|
}
|
||||||
func (m *SendMsgResp) XXX_Unmarshal(b []byte) error {
|
func (m *SendMsgResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_SendMsgResp.Unmarshal(m, b)
|
return xxx_messageInfo_SendMsgResp.Unmarshal(m, b)
|
||||||
@ -505,7 +505,7 @@ func (m *ClearMsgReq) Reset() { *m = ClearMsgReq{} }
|
|||||||
func (m *ClearMsgReq) String() string { return proto.CompactTextString(m) }
|
func (m *ClearMsgReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ClearMsgReq) ProtoMessage() {}
|
func (*ClearMsgReq) ProtoMessage() {}
|
||||||
func (*ClearMsgReq) Descriptor() ([]byte, []int) {
|
func (*ClearMsgReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{8}
|
return fileDescriptor_msg_3997a326608d1183, []int{8}
|
||||||
}
|
}
|
||||||
func (m *ClearMsgReq) XXX_Unmarshal(b []byte) error {
|
func (m *ClearMsgReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_ClearMsgReq.Unmarshal(m, b)
|
return xxx_messageInfo_ClearMsgReq.Unmarshal(m, b)
|
||||||
@ -558,7 +558,7 @@ func (m *ClearMsgResp) Reset() { *m = ClearMsgResp{} }
|
|||||||
func (m *ClearMsgResp) String() string { return proto.CompactTextString(m) }
|
func (m *ClearMsgResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ClearMsgResp) ProtoMessage() {}
|
func (*ClearMsgResp) ProtoMessage() {}
|
||||||
func (*ClearMsgResp) Descriptor() ([]byte, []int) {
|
func (*ClearMsgResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{9}
|
return fileDescriptor_msg_3997a326608d1183, []int{9}
|
||||||
}
|
}
|
||||||
func (m *ClearMsgResp) XXX_Unmarshal(b []byte) error {
|
func (m *ClearMsgResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_ClearMsgResp.Unmarshal(m, b)
|
return xxx_messageInfo_ClearMsgResp.Unmarshal(m, b)
|
||||||
@ -607,7 +607,7 @@ func (m *SetMsgMinSeqReq) Reset() { *m = SetMsgMinSeqReq{} }
|
|||||||
func (m *SetMsgMinSeqReq) String() string { return proto.CompactTextString(m) }
|
func (m *SetMsgMinSeqReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SetMsgMinSeqReq) ProtoMessage() {}
|
func (*SetMsgMinSeqReq) ProtoMessage() {}
|
||||||
func (*SetMsgMinSeqReq) Descriptor() ([]byte, []int) {
|
func (*SetMsgMinSeqReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{10}
|
return fileDescriptor_msg_3997a326608d1183, []int{10}
|
||||||
}
|
}
|
||||||
func (m *SetMsgMinSeqReq) XXX_Unmarshal(b []byte) error {
|
func (m *SetMsgMinSeqReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_SetMsgMinSeqReq.Unmarshal(m, b)
|
return xxx_messageInfo_SetMsgMinSeqReq.Unmarshal(m, b)
|
||||||
@ -674,7 +674,7 @@ func (m *SetMsgMinSeqResp) Reset() { *m = SetMsgMinSeqResp{} }
|
|||||||
func (m *SetMsgMinSeqResp) String() string { return proto.CompactTextString(m) }
|
func (m *SetMsgMinSeqResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SetMsgMinSeqResp) ProtoMessage() {}
|
func (*SetMsgMinSeqResp) ProtoMessage() {}
|
||||||
func (*SetMsgMinSeqResp) Descriptor() ([]byte, []int) {
|
func (*SetMsgMinSeqResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{11}
|
return fileDescriptor_msg_3997a326608d1183, []int{11}
|
||||||
}
|
}
|
||||||
func (m *SetMsgMinSeqResp) XXX_Unmarshal(b []byte) error {
|
func (m *SetMsgMinSeqResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_SetMsgMinSeqResp.Unmarshal(m, b)
|
return xxx_messageInfo_SetMsgMinSeqResp.Unmarshal(m, b)
|
||||||
@ -708,45 +708,53 @@ func (m *SetMsgMinSeqResp) GetErrMsg() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetSendMsgFailedFlagReq struct {
|
type SetSendMsgStatusReq struct {
|
||||||
OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"`
|
OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"`
|
||||||
|
Status int32 `protobuf:"varint,2,opt,name=status" json:"status,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SetSendMsgFailedFlagReq) Reset() { *m = SetSendMsgFailedFlagReq{} }
|
func (m *SetSendMsgStatusReq) Reset() { *m = SetSendMsgStatusReq{} }
|
||||||
func (m *SetSendMsgFailedFlagReq) String() string { return proto.CompactTextString(m) }
|
func (m *SetSendMsgStatusReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SetSendMsgFailedFlagReq) ProtoMessage() {}
|
func (*SetSendMsgStatusReq) ProtoMessage() {}
|
||||||
func (*SetSendMsgFailedFlagReq) Descriptor() ([]byte, []int) {
|
func (*SetSendMsgStatusReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{12}
|
return fileDescriptor_msg_3997a326608d1183, []int{12}
|
||||||
}
|
}
|
||||||
func (m *SetSendMsgFailedFlagReq) XXX_Unmarshal(b []byte) error {
|
func (m *SetSendMsgStatusReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_SetSendMsgFailedFlagReq.Unmarshal(m, b)
|
return xxx_messageInfo_SetSendMsgStatusReq.Unmarshal(m, b)
|
||||||
}
|
}
|
||||||
func (m *SetSendMsgFailedFlagReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
func (m *SetSendMsgStatusReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
return xxx_messageInfo_SetSendMsgFailedFlagReq.Marshal(b, m, deterministic)
|
return xxx_messageInfo_SetSendMsgStatusReq.Marshal(b, m, deterministic)
|
||||||
}
|
}
|
||||||
func (dst *SetSendMsgFailedFlagReq) XXX_Merge(src proto.Message) {
|
func (dst *SetSendMsgStatusReq) XXX_Merge(src proto.Message) {
|
||||||
xxx_messageInfo_SetSendMsgFailedFlagReq.Merge(dst, src)
|
xxx_messageInfo_SetSendMsgStatusReq.Merge(dst, src)
|
||||||
}
|
}
|
||||||
func (m *SetSendMsgFailedFlagReq) XXX_Size() int {
|
func (m *SetSendMsgStatusReq) XXX_Size() int {
|
||||||
return xxx_messageInfo_SetSendMsgFailedFlagReq.Size(m)
|
return xxx_messageInfo_SetSendMsgStatusReq.Size(m)
|
||||||
}
|
}
|
||||||
func (m *SetSendMsgFailedFlagReq) XXX_DiscardUnknown() {
|
func (m *SetSendMsgStatusReq) XXX_DiscardUnknown() {
|
||||||
xxx_messageInfo_SetSendMsgFailedFlagReq.DiscardUnknown(m)
|
xxx_messageInfo_SetSendMsgStatusReq.DiscardUnknown(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
var xxx_messageInfo_SetSendMsgFailedFlagReq proto.InternalMessageInfo
|
var xxx_messageInfo_SetSendMsgStatusReq proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *SetSendMsgFailedFlagReq) GetOperationID() string {
|
func (m *SetSendMsgStatusReq) GetOperationID() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.OperationID
|
return m.OperationID
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetSendMsgFailedFlagResp struct {
|
func (m *SetSendMsgStatusReq) GetStatus() int32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Status
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetSendMsgStatusResp struct {
|
||||||
ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"`
|
ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"`
|
||||||
ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"`
|
ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
@ -754,38 +762,38 @@ type SetSendMsgFailedFlagResp struct {
|
|||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SetSendMsgFailedFlagResp) Reset() { *m = SetSendMsgFailedFlagResp{} }
|
func (m *SetSendMsgStatusResp) Reset() { *m = SetSendMsgStatusResp{} }
|
||||||
func (m *SetSendMsgFailedFlagResp) String() string { return proto.CompactTextString(m) }
|
func (m *SetSendMsgStatusResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SetSendMsgFailedFlagResp) ProtoMessage() {}
|
func (*SetSendMsgStatusResp) ProtoMessage() {}
|
||||||
func (*SetSendMsgFailedFlagResp) Descriptor() ([]byte, []int) {
|
func (*SetSendMsgStatusResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{13}
|
return fileDescriptor_msg_3997a326608d1183, []int{13}
|
||||||
}
|
}
|
||||||
func (m *SetSendMsgFailedFlagResp) XXX_Unmarshal(b []byte) error {
|
func (m *SetSendMsgStatusResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_SetSendMsgFailedFlagResp.Unmarshal(m, b)
|
return xxx_messageInfo_SetSendMsgStatusResp.Unmarshal(m, b)
|
||||||
}
|
}
|
||||||
func (m *SetSendMsgFailedFlagResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
func (m *SetSendMsgStatusResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
return xxx_messageInfo_SetSendMsgFailedFlagResp.Marshal(b, m, deterministic)
|
return xxx_messageInfo_SetSendMsgStatusResp.Marshal(b, m, deterministic)
|
||||||
}
|
}
|
||||||
func (dst *SetSendMsgFailedFlagResp) XXX_Merge(src proto.Message) {
|
func (dst *SetSendMsgStatusResp) XXX_Merge(src proto.Message) {
|
||||||
xxx_messageInfo_SetSendMsgFailedFlagResp.Merge(dst, src)
|
xxx_messageInfo_SetSendMsgStatusResp.Merge(dst, src)
|
||||||
}
|
}
|
||||||
func (m *SetSendMsgFailedFlagResp) XXX_Size() int {
|
func (m *SetSendMsgStatusResp) XXX_Size() int {
|
||||||
return xxx_messageInfo_SetSendMsgFailedFlagResp.Size(m)
|
return xxx_messageInfo_SetSendMsgStatusResp.Size(m)
|
||||||
}
|
}
|
||||||
func (m *SetSendMsgFailedFlagResp) XXX_DiscardUnknown() {
|
func (m *SetSendMsgStatusResp) XXX_DiscardUnknown() {
|
||||||
xxx_messageInfo_SetSendMsgFailedFlagResp.DiscardUnknown(m)
|
xxx_messageInfo_SetSendMsgStatusResp.DiscardUnknown(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
var xxx_messageInfo_SetSendMsgFailedFlagResp proto.InternalMessageInfo
|
var xxx_messageInfo_SetSendMsgStatusResp proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *SetSendMsgFailedFlagResp) GetErrCode() int32 {
|
func (m *SetSendMsgStatusResp) GetErrCode() int32 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.ErrCode
|
return m.ErrCode
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SetSendMsgFailedFlagResp) GetErrMsg() string {
|
func (m *SetSendMsgStatusResp) GetErrMsg() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.ErrMsg
|
return m.ErrMsg
|
||||||
}
|
}
|
||||||
@ -803,7 +811,7 @@ func (m *GetSendMsgStatusReq) Reset() { *m = GetSendMsgStatusReq{} }
|
|||||||
func (m *GetSendMsgStatusReq) String() string { return proto.CompactTextString(m) }
|
func (m *GetSendMsgStatusReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetSendMsgStatusReq) ProtoMessage() {}
|
func (*GetSendMsgStatusReq) ProtoMessage() {}
|
||||||
func (*GetSendMsgStatusReq) Descriptor() ([]byte, []int) {
|
func (*GetSendMsgStatusReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{14}
|
return fileDescriptor_msg_3997a326608d1183, []int{14}
|
||||||
}
|
}
|
||||||
func (m *GetSendMsgStatusReq) XXX_Unmarshal(b []byte) error {
|
func (m *GetSendMsgStatusReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_GetSendMsgStatusReq.Unmarshal(m, b)
|
return xxx_messageInfo_GetSendMsgStatusReq.Unmarshal(m, b)
|
||||||
@ -843,7 +851,7 @@ func (m *GetSendMsgStatusResp) Reset() { *m = GetSendMsgStatusResp{} }
|
|||||||
func (m *GetSendMsgStatusResp) String() string { return proto.CompactTextString(m) }
|
func (m *GetSendMsgStatusResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetSendMsgStatusResp) ProtoMessage() {}
|
func (*GetSendMsgStatusResp) ProtoMessage() {}
|
||||||
func (*GetSendMsgStatusResp) Descriptor() ([]byte, []int) {
|
func (*GetSendMsgStatusResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{15}
|
return fileDescriptor_msg_3997a326608d1183, []int{15}
|
||||||
}
|
}
|
||||||
func (m *GetSendMsgStatusResp) XXX_Unmarshal(b []byte) error {
|
func (m *GetSendMsgStatusResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_GetSendMsgStatusResp.Unmarshal(m, b)
|
return xxx_messageInfo_GetSendMsgStatusResp.Unmarshal(m, b)
|
||||||
@ -898,7 +906,7 @@ func (m *DelSuperGroupMsgReq) Reset() { *m = DelSuperGroupMsgReq{} }
|
|||||||
func (m *DelSuperGroupMsgReq) String() string { return proto.CompactTextString(m) }
|
func (m *DelSuperGroupMsgReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*DelSuperGroupMsgReq) ProtoMessage() {}
|
func (*DelSuperGroupMsgReq) ProtoMessage() {}
|
||||||
func (*DelSuperGroupMsgReq) Descriptor() ([]byte, []int) {
|
func (*DelSuperGroupMsgReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{16}
|
return fileDescriptor_msg_3997a326608d1183, []int{16}
|
||||||
}
|
}
|
||||||
func (m *DelSuperGroupMsgReq) XXX_Unmarshal(b []byte) error {
|
func (m *DelSuperGroupMsgReq) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_DelSuperGroupMsgReq.Unmarshal(m, b)
|
return xxx_messageInfo_DelSuperGroupMsgReq.Unmarshal(m, b)
|
||||||
@ -958,7 +966,7 @@ func (m *DelSuperGroupMsgResp) Reset() { *m = DelSuperGroupMsgResp{} }
|
|||||||
func (m *DelSuperGroupMsgResp) String() string { return proto.CompactTextString(m) }
|
func (m *DelSuperGroupMsgResp) String() string { return proto.CompactTextString(m) }
|
||||||
func (*DelSuperGroupMsgResp) ProtoMessage() {}
|
func (*DelSuperGroupMsgResp) ProtoMessage() {}
|
||||||
func (*DelSuperGroupMsgResp) Descriptor() ([]byte, []int) {
|
func (*DelSuperGroupMsgResp) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_msg_110411abaacf415d, []int{17}
|
return fileDescriptor_msg_3997a326608d1183, []int{17}
|
||||||
}
|
}
|
||||||
func (m *DelSuperGroupMsgResp) XXX_Unmarshal(b []byte) error {
|
func (m *DelSuperGroupMsgResp) XXX_Unmarshal(b []byte) error {
|
||||||
return xxx_messageInfo_DelSuperGroupMsgResp.Unmarshal(m, b)
|
return xxx_messageInfo_DelSuperGroupMsgResp.Unmarshal(m, b)
|
||||||
@ -1005,8 +1013,8 @@ func init() {
|
|||||||
proto.RegisterType((*ClearMsgResp)(nil), "msg.ClearMsgResp")
|
proto.RegisterType((*ClearMsgResp)(nil), "msg.ClearMsgResp")
|
||||||
proto.RegisterType((*SetMsgMinSeqReq)(nil), "msg.SetMsgMinSeqReq")
|
proto.RegisterType((*SetMsgMinSeqReq)(nil), "msg.SetMsgMinSeqReq")
|
||||||
proto.RegisterType((*SetMsgMinSeqResp)(nil), "msg.SetMsgMinSeqResp")
|
proto.RegisterType((*SetMsgMinSeqResp)(nil), "msg.SetMsgMinSeqResp")
|
||||||
proto.RegisterType((*SetSendMsgFailedFlagReq)(nil), "msg.SetSendMsgFailedFlagReq")
|
proto.RegisterType((*SetSendMsgStatusReq)(nil), "msg.SetSendMsgStatusReq")
|
||||||
proto.RegisterType((*SetSendMsgFailedFlagResp)(nil), "msg.SetSendMsgFailedFlagResp")
|
proto.RegisterType((*SetSendMsgStatusResp)(nil), "msg.SetSendMsgStatusResp")
|
||||||
proto.RegisterType((*GetSendMsgStatusReq)(nil), "msg.GetSendMsgStatusReq")
|
proto.RegisterType((*GetSendMsgStatusReq)(nil), "msg.GetSendMsgStatusReq")
|
||||||
proto.RegisterType((*GetSendMsgStatusResp)(nil), "msg.GetSendMsgStatusResp")
|
proto.RegisterType((*GetSendMsgStatusResp)(nil), "msg.GetSendMsgStatusResp")
|
||||||
proto.RegisterType((*DelSuperGroupMsgReq)(nil), "msg.DelSuperGroupMsgReq")
|
proto.RegisterType((*DelSuperGroupMsgReq)(nil), "msg.DelSuperGroupMsgReq")
|
||||||
@ -1031,7 +1039,7 @@ type MsgClient interface {
|
|||||||
DelSuperGroupMsg(ctx context.Context, in *DelSuperGroupMsgReq, opts ...grpc.CallOption) (*DelSuperGroupMsgResp, error)
|
DelSuperGroupMsg(ctx context.Context, in *DelSuperGroupMsgReq, opts ...grpc.CallOption) (*DelSuperGroupMsgResp, error)
|
||||||
ClearMsg(ctx context.Context, in *ClearMsgReq, opts ...grpc.CallOption) (*ClearMsgResp, error)
|
ClearMsg(ctx context.Context, in *ClearMsgReq, opts ...grpc.CallOption) (*ClearMsgResp, error)
|
||||||
SetMsgMinSeq(ctx context.Context, in *SetMsgMinSeqReq, opts ...grpc.CallOption) (*SetMsgMinSeqResp, error)
|
SetMsgMinSeq(ctx context.Context, in *SetMsgMinSeqReq, opts ...grpc.CallOption) (*SetMsgMinSeqResp, error)
|
||||||
SetSendMsgFailedFlag(ctx context.Context, in *SetSendMsgFailedFlagReq, opts ...grpc.CallOption) (*SetSendMsgFailedFlagResp, error)
|
SetSendMsgStatus(ctx context.Context, in *SetSendMsgStatusReq, opts ...grpc.CallOption) (*SetSendMsgStatusResp, error)
|
||||||
GetSendMsgStatus(ctx context.Context, in *GetSendMsgStatusReq, opts ...grpc.CallOption) (*GetSendMsgStatusResp, error)
|
GetSendMsgStatus(ctx context.Context, in *GetSendMsgStatusReq, opts ...grpc.CallOption) (*GetSendMsgStatusResp, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,9 +1114,9 @@ func (c *msgClient) SetMsgMinSeq(ctx context.Context, in *SetMsgMinSeqReq, opts
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *msgClient) SetSendMsgFailedFlag(ctx context.Context, in *SetSendMsgFailedFlagReq, opts ...grpc.CallOption) (*SetSendMsgFailedFlagResp, error) {
|
func (c *msgClient) SetSendMsgStatus(ctx context.Context, in *SetSendMsgStatusReq, opts ...grpc.CallOption) (*SetSendMsgStatusResp, error) {
|
||||||
out := new(SetSendMsgFailedFlagResp)
|
out := new(SetSendMsgStatusResp)
|
||||||
err := grpc.Invoke(ctx, "/msg.msg/SetSendMsgFailedFlag", in, out, c.cc, opts...)
|
err := grpc.Invoke(ctx, "/msg.msg/SetSendMsgStatus", in, out, c.cc, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1134,7 +1142,7 @@ type MsgServer interface {
|
|||||||
DelSuperGroupMsg(context.Context, *DelSuperGroupMsgReq) (*DelSuperGroupMsgResp, error)
|
DelSuperGroupMsg(context.Context, *DelSuperGroupMsgReq) (*DelSuperGroupMsgResp, error)
|
||||||
ClearMsg(context.Context, *ClearMsgReq) (*ClearMsgResp, error)
|
ClearMsg(context.Context, *ClearMsgReq) (*ClearMsgResp, error)
|
||||||
SetMsgMinSeq(context.Context, *SetMsgMinSeqReq) (*SetMsgMinSeqResp, error)
|
SetMsgMinSeq(context.Context, *SetMsgMinSeqReq) (*SetMsgMinSeqResp, error)
|
||||||
SetSendMsgFailedFlag(context.Context, *SetSendMsgFailedFlagReq) (*SetSendMsgFailedFlagResp, error)
|
SetSendMsgStatus(context.Context, *SetSendMsgStatusReq) (*SetSendMsgStatusResp, error)
|
||||||
GetSendMsgStatus(context.Context, *GetSendMsgStatusReq) (*GetSendMsgStatusResp, error)
|
GetSendMsgStatus(context.Context, *GetSendMsgStatusReq) (*GetSendMsgStatusResp, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1268,20 +1276,20 @@ func _Msg_SetMsgMinSeq_Handler(srv interface{}, ctx context.Context, dec func(in
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _Msg_SetSendMsgFailedFlag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _Msg_SetSendMsgStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(SetSendMsgFailedFlagReq)
|
in := new(SetSendMsgStatusReq)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if interceptor == nil {
|
if interceptor == nil {
|
||||||
return srv.(MsgServer).SetSendMsgFailedFlag(ctx, in)
|
return srv.(MsgServer).SetSendMsgStatus(ctx, in)
|
||||||
}
|
}
|
||||||
info := &grpc.UnaryServerInfo{
|
info := &grpc.UnaryServerInfo{
|
||||||
Server: srv,
|
Server: srv,
|
||||||
FullMethod: "/msg.msg/SetSendMsgFailedFlag",
|
FullMethod: "/msg.msg/SetSendMsgStatus",
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(MsgServer).SetSendMsgFailedFlag(ctx, req.(*SetSendMsgFailedFlagReq))
|
return srv.(MsgServer).SetSendMsgStatus(ctx, req.(*SetSendMsgStatusReq))
|
||||||
}
|
}
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
@ -1337,8 +1345,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
|
|||||||
Handler: _Msg_SetMsgMinSeq_Handler,
|
Handler: _Msg_SetMsgMinSeq_Handler,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "SetSendMsgFailedFlag",
|
MethodName: "SetSendMsgStatus",
|
||||||
Handler: _Msg_SetSendMsgFailedFlag_Handler,
|
Handler: _Msg_SetSendMsgStatus_Handler,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "GetSendMsgStatus",
|
MethodName: "GetSendMsgStatus",
|
||||||
@ -1349,62 +1357,61 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
|
|||||||
Metadata: "msg/msg.proto",
|
Metadata: "msg/msg.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("msg/msg.proto", fileDescriptor_msg_110411abaacf415d) }
|
func init() { proto.RegisterFile("msg/msg.proto", fileDescriptor_msg_3997a326608d1183) }
|
||||||
|
|
||||||
var fileDescriptor_msg_110411abaacf415d = []byte{
|
var fileDescriptor_msg_3997a326608d1183 = []byte{
|
||||||
// 850 bytes of a gzipped FileDescriptorProto
|
// 833 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x6f, 0x1b, 0x55,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4d, 0x6f, 0xeb, 0x44,
|
||||||
0x10, 0xd7, 0xc6, 0xb1, 0xd3, 0xcc, 0x26, 0xb2, 0x79, 0x35, 0x61, 0x59, 0x15, 0xc9, 0x5d, 0x01,
|
0x14, 0x95, 0xe3, 0x26, 0x79, 0xb9, 0x6e, 0x95, 0x30, 0x0d, 0x95, 0xb1, 0x58, 0xe4, 0x59, 0x80,
|
||||||
0xb2, 0x00, 0xd9, 0x92, 0x41, 0xe2, 0x90, 0x0b, 0xb8, 0x6e, 0x43, 0xa4, 0x2e, 0x6d, 0x76, 0xc3,
|
0x22, 0x40, 0x89, 0x14, 0x90, 0x58, 0xbc, 0x0d, 0xe4, 0xe5, 0x29, 0x54, 0xc2, 0xb4, 0xb5, 0xcb,
|
||||||
0x85, 0x8b, 0xbb, 0xd4, 0x4f, 0xaf, 0xab, 0xec, 0xc7, 0xf3, 0xce, 0x9a, 0xb4, 0x70, 0xe6, 0xc8,
|
0x86, 0x4d, 0x6a, 0x9a, 0xd1, 0x34, 0x6a, 0x6c, 0x4f, 0x3c, 0x0e, 0x6d, 0x61, 0xcd, 0x92, 0x1f,
|
||||||
0x1f, 0xc0, 0x89, 0x1b, 0x47, 0xfe, 0x46, 0xf4, 0x3e, 0x6c, 0xef, 0x57, 0x88, 0xe5, 0x43, 0x8f,
|
0xc0, 0x0a, 0x89, 0x05, 0xbf, 0x13, 0xcd, 0x47, 0x92, 0xf1, 0x47, 0xd5, 0x10, 0x21, 0x96, 0xf7,
|
||||||
0x33, 0x3b, 0x6f, 0xe6, 0xf7, 0x9b, 0xf9, 0xbd, 0x79, 0x0b, 0xa7, 0x31, 0xb2, 0x71, 0x8c, 0x6c,
|
0xfa, 0xfa, 0xdc, 0x73, 0xee, 0x9c, 0xb9, 0x36, 0x9c, 0x44, 0x8c, 0x0c, 0x23, 0x46, 0x06, 0x34,
|
||||||
0xc4, 0xb3, 0x34, 0x4f, 0x49, 0x2b, 0x46, 0x66, 0x3f, 0x7e, 0xc1, 0x69, 0x32, 0xbf, 0x74, 0xc7,
|
0x4d, 0xb2, 0x04, 0x99, 0x11, 0x23, 0xce, 0xeb, 0x0b, 0x8a, 0xe3, 0xd9, 0xb9, 0x37, 0xa4, 0xf7,
|
||||||
0xfc, 0x86, 0x8d, 0xa5, 0x7f, 0x8c, 0x8b, 0x9b, 0xf9, 0x2d, 0x8e, 0x6f, 0x51, 0xc5, 0x39, 0xbf,
|
0x64, 0x28, 0xf2, 0x43, 0x36, 0xbf, 0x9f, 0x3d, 0xb0, 0xe1, 0x03, 0x93, 0x75, 0xee, 0xaf, 0x60,
|
||||||
0x83, 0xe9, 0x22, 0x9b, 0x05, 0x79, 0x70, 0x9d, 0xba, 0x57, 0xa4, 0x0f, 0xed, 0x3c, 0xbd, 0xa1,
|
0x79, 0x8c, 0x4c, 0xc2, 0x2c, 0xbc, 0x4e, 0xbc, 0x2b, 0xd4, 0x85, 0x7a, 0x96, 0xdc, 0xe3, 0xd8,
|
||||||
0x89, 0x65, 0x0c, 0x8c, 0xe1, 0xb1, 0xa7, 0x0c, 0x32, 0x00, 0x33, 0xe5, 0x34, 0x0b, 0xf2, 0x30,
|
0x36, 0x7a, 0x46, 0xbf, 0xe5, 0xcb, 0x00, 0xf5, 0xc0, 0x4a, 0x28, 0x4e, 0xc3, 0x6c, 0x91, 0xc4,
|
||||||
0x4d, 0x2e, 0x67, 0xd6, 0x81, 0xfc, 0x56, 0x74, 0x91, 0x6f, 0xe0, 0x28, 0x56, 0x69, 0xac, 0xd6,
|
0xe7, 0x13, 0xbb, 0x26, 0x9e, 0xe9, 0x29, 0xf4, 0x25, 0x34, 0x23, 0x09, 0x63, 0x9b, 0x3d, 0xa3,
|
||||||
0xc0, 0x18, 0x9a, 0x13, 0x7b, 0x84, 0x34, 0xfb, 0x95, 0x66, 0xf3, 0x80, 0x87, 0x73, 0x1e, 0x64,
|
0x6f, 0x8d, 0x9c, 0x01, 0xc3, 0xe9, 0xcf, 0x38, 0x9d, 0x85, 0x74, 0x31, 0xa3, 0x61, 0x1a, 0x46,
|
||||||
0x41, 0x8c, 0x23, 0x5d, 0xc8, 0x5b, 0x87, 0x3a, 0xb4, 0x50, 0x7c, 0x36, 0x2d, 0x26, 0x31, 0x76,
|
0x6c, 0xa0, 0x1a, 0xf9, 0x9b, 0x52, 0x17, 0x6b, 0xcd, 0x27, 0x63, 0x1d, 0xc4, 0xd8, 0x1b, 0xe4,
|
||||||
0x4e, 0x72, 0x3f, 0x38, 0xe7, 0x4f, 0x03, 0xba, 0x2f, 0x57, 0xf8, 0xa6, 0x48, 0x74, 0x00, 0xe6,
|
0x65, 0x72, 0xee, 0xef, 0x06, 0xb4, 0x2f, 0xd7, 0xec, 0x4e, 0x17, 0xda, 0x03, 0xeb, 0x42, 0x7b,
|
||||||
0x8b, 0xc2, 0x29, 0x45, 0xb7, 0xe8, 0x2a, 0xa2, 0x39, 0xd8, 0x1d, 0x8d, 0x03, 0x27, 0x7c, 0x85,
|
0x4b, 0xca, 0xd5, 0x53, 0x3a, 0x9b, 0xda, 0xfe, 0x6c, 0x5c, 0x38, 0xa6, 0x6b, 0x76, 0x77, 0x9d,
|
||||||
0x6f, 0xae, 0xd3, 0x9f, 0x90, 0x66, 0x97, 0x33, 0xd9, 0x8d, 0x63, 0xaf, 0xe4, 0x73, 0xfe, 0x31,
|
0xfc, 0xc0, 0x70, 0x7a, 0x3e, 0x11, 0xd3, 0x68, 0xf9, 0xb9, 0x9c, 0xfb, 0xb7, 0x01, 0x68, 0xc7,
|
||||||
0x80, 0x6c, 0xb1, 0xa4, 0x09, 0x4b, 0xa7, 0xef, 0xdc, 0x2b, 0x62, 0xc1, 0x51, 0x14, 0x60, 0xee,
|
0x25, 0x89, 0x49, 0x32, 0x7e, 0xf2, 0xae, 0x90, 0x0d, 0xcd, 0x65, 0xc8, 0xb2, 0x00, 0xaf, 0x04,
|
||||||
0xd3, 0xa5, 0x84, 0x73, 0xe8, 0xad, 0x4d, 0xf2, 0x29, 0x9c, 0x06, 0x8c, 0x65, 0x94, 0x95, 0x49,
|
0x9d, 0x23, 0x7f, 0x13, 0xa2, 0x8f, 0xe0, 0x24, 0x24, 0x24, 0xc5, 0x24, 0x2f, 0x32, 0x9f, 0x44,
|
||||||
0x96, 0x9d, 0x64, 0x02, 0x66, 0x4c, 0x11, 0x03, 0x46, 0x9f, 0x87, 0x98, 0x5b, 0xad, 0x41, 0x6b,
|
0x23, 0xb0, 0x22, 0xcc, 0x58, 0x48, 0xf0, 0x77, 0x0b, 0x96, 0xd9, 0x66, 0xcf, 0xec, 0x5b, 0xa3,
|
||||||
0x68, 0x4e, 0x7a, 0x23, 0xa1, 0x89, 0x02, 0x73, 0xaf, 0x18, 0x44, 0x1e, 0xc1, 0x71, 0x9e, 0x85,
|
0xce, 0x80, 0x7b, 0x42, 0x53, 0xee, 0xeb, 0x45, 0xe8, 0x43, 0x68, 0x65, 0xe9, 0x82, 0x10, 0xc1,
|
||||||
0x8c, 0x49, 0xac, 0x87, 0x32, 0xeb, 0xd6, 0xe1, 0xfc, 0x08, 0xe4, 0x82, 0xe6, 0x6e, 0xf0, 0xf6,
|
0xf5, 0x48, 0xa0, 0xee, 0x12, 0xee, 0xf7, 0x80, 0xa6, 0x38, 0xf3, 0xc2, 0xc7, 0x6f, 0xe2, 0xb9,
|
||||||
0xfb, 0x64, 0xe1, 0x86, 0x89, 0x4f, 0x97, 0x1e, 0x5d, 0x92, 0x33, 0xe8, 0x68, 0x72, 0xaa, 0x6b,
|
0xb7, 0x88, 0x03, 0xbc, 0xf2, 0xf1, 0x0a, 0x9d, 0x41, 0x43, 0x89, 0x93, 0x53, 0x53, 0x51, 0x71,
|
||||||
0xda, 0xaa, 0xb6, 0xf4, 0xa0, 0xd6, 0x52, 0xe7, 0x16, 0x1e, 0xd6, 0xf2, 0x21, 0x17, 0xc4, 0x9f,
|
0xa4, 0xb5, 0xd2, 0x48, 0xdd, 0x07, 0x38, 0x2d, 0xe1, 0x31, 0xca, 0x85, 0xbf, 0x4b, 0xd3, 0xb7,
|
||||||
0x66, 0xd9, 0x93, 0x74, 0x41, 0x65, 0xc6, 0xb6, 0xb7, 0x36, 0x45, 0xa9, 0xa7, 0x59, 0xe6, 0x22,
|
0xc9, 0x1c, 0x0b, 0xc4, 0xba, 0xbf, 0x09, 0x79, 0xab, 0x77, 0x69, 0xea, 0x31, 0xa2, 0xd0, 0x54,
|
||||||
0xd3, 0xd9, 0xb4, 0x25, 0xfc, 0x6e, 0xf0, 0x56, 0x74, 0x4a, 0xf4, 0xf7, 0xd4, 0xd3, 0x96, 0xf4,
|
0xc4, 0xf3, 0x5e, 0xf8, 0xc8, 0x27, 0xc5, 0xe7, 0x7b, 0xe2, 0xab, 0x48, 0xe4, 0x05, 0xae, 0xd0,
|
||||||
0xcb, 0xbc, 0x92, 0x8b, 0xf0, 0x4b, 0xcb, 0xf9, 0x0d, 0xc0, 0xa7, 0xc9, 0xc2, 0x45, 0x26, 0x08,
|
0xc2, 0xf3, 0x22, 0x72, 0x7f, 0x01, 0x08, 0x70, 0x3c, 0xf7, 0x18, 0xe1, 0x02, 0xfe, 0x5f, 0x93,
|
||||||
0xbc, 0x5f, 0x91, 0xff, 0x6d, 0x80, 0xb9, 0x29, 0xae, 0xd8, 0xd2, 0x32, 0x5b, 0xba, 0x65, 0x4b,
|
0xff, 0x69, 0x80, 0xb5, 0x6d, 0x2e, 0xd5, 0xe2, 0xbc, 0x5a, 0xbc, 0x53, 0x8b, 0x73, 0x6a, 0x65,
|
||||||
0x4b, 0x6c, 0x95, 0x25, 0x90, 0xa9, 0x3a, 0x2e, 0xb2, 0xcd, 0x98, 0x8a, 0x2e, 0x11, 0xf1, 0x3a,
|
0xc4, 0x99, 0xc9, 0x3e, 0x1e, 0x23, 0xdb, 0x63, 0xd2, 0x53, 0xbc, 0xe2, 0x76, 0xb9, 0xc0, 0x71,
|
||||||
0x0a, 0x69, 0x92, 0xab, 0x88, 0xb6, 0x8a, 0x28, 0xb8, 0x88, 0x0d, 0x0f, 0x90, 0x26, 0x8b, 0xeb,
|
0x26, 0x2b, 0xea, 0xb2, 0x42, 0x4b, 0x21, 0x07, 0x5e, 0x31, 0x1c, 0xcf, 0xaf, 0x17, 0x11, 0xb6,
|
||||||
0x30, 0xa6, 0x56, 0x67, 0x60, 0x0c, 0x5b, 0xde, 0xc6, 0x76, 0x5e, 0x83, 0xf9, 0x24, 0xa2, 0x41,
|
0x1b, 0x3d, 0xa3, 0x6f, 0xfa, 0xdb, 0xd8, 0xbd, 0x05, 0xeb, 0xed, 0x12, 0x87, 0xa9, 0x1a, 0xcf,
|
||||||
0xa6, 0xdb, 0x73, 0x06, 0x9d, 0x55, 0x69, 0xbe, 0xca, 0x12, 0x29, 0x52, 0xae, 0x27, 0xaf, 0x00,
|
0x19, 0x34, 0xd6, 0xb9, 0xf3, 0x95, 0x11, 0x87, 0x48, 0xa8, 0x3a, 0x79, 0x49, 0x70, 0x1b, 0x17,
|
||||||
0x6e, 0xec, 0x6a, 0xf3, 0x5a, 0xf5, 0x4b, 0xf8, 0x1d, 0x9c, 0x6c, 0x8b, 0xec, 0xd3, 0x06, 0xe7,
|
0x87, 0x67, 0x96, 0x2f, 0xe1, 0xd7, 0x70, 0xbc, 0x6b, 0x72, 0xc8, 0x18, 0xdc, 0x3f, 0x0c, 0x68,
|
||||||
0x2f, 0x03, 0xba, 0x3e, 0x15, 0x7c, 0x4a, 0x5a, 0x6c, 0xc4, 0x6a, 0xc1, 0x11, 0xcb, 0xd2, 0x15,
|
0x07, 0x98, 0xeb, 0xc9, 0x79, 0xb1, 0x92, 0xab, 0x0d, 0x4d, 0x92, 0x26, 0x6b, 0xba, 0xa5, 0xba,
|
||||||
0xdf, 0x40, 0x5d, 0x9b, 0xe2, 0x44, 0xac, 0x24, 0xa2, 0xa5, 0xa3, 0xac, 0x2a, 0x83, 0xc3, 0xfa,
|
0x09, 0xf9, 0x1b, 0x91, 0xb4, 0x88, 0xb2, 0x8e, 0x8c, 0x8a, 0x0a, 0x8e, 0xca, 0xc7, 0xaf, 0xeb,
|
||||||
0xf8, 0x8b, 0xfc, 0xdb, 0x65, 0xfe, 0xce, 0x0c, 0x7a, 0x65, 0x68, 0x7b, 0x31, 0x3c, 0x87, 0x8f,
|
0xaf, 0xe7, 0xf5, 0xbb, 0x13, 0xe8, 0xe4, 0xa9, 0x1d, 0xa4, 0xf0, 0x02, 0x4e, 0x03, 0x9c, 0x29,
|
||||||
0x7c, 0x9a, 0x6b, 0xb1, 0x3c, 0x0b, 0xc2, 0x88, 0x2e, 0x9e, 0x45, 0x81, 0x1c, 0x4a, 0x05, 0x9e,
|
0xb3, 0x04, 0x59, 0x98, 0xad, 0x99, 0x5f, 0xa6, 0x66, 0x94, 0xa9, 0x9d, 0x41, 0x83, 0x89, 0x72,
|
||||||
0x51, 0x6f, 0xf0, 0x73, 0xb0, 0x9a, 0x0f, 0xef, 0x05, 0xe5, 0x5b, 0x79, 0x55, 0x75, 0x36, 0x3f,
|
0x01, 0x58, 0xf7, 0x55, 0xe4, 0x7e, 0x0b, 0xdd, 0x32, 0xe0, 0x41, 0xd4, 0xbe, 0x12, 0x57, 0xf7,
|
||||||
0x0f, 0xf2, 0x15, 0xee, 0x06, 0xe3, 0x15, 0xf4, 0xeb, 0x07, 0xf7, 0x92, 0xfd, 0x19, 0x74, 0x50,
|
0xdf, 0x53, 0x73, 0x6f, 0xa0, 0x3b, 0xfd, 0x4f, 0x28, 0x68, 0x22, 0xcd, 0x9c, 0xc8, 0xdf, 0x0c,
|
||||||
0x9e, 0x97, 0x93, 0x6a, 0x7b, 0xda, 0x72, 0xfe, 0x30, 0xe0, 0xe1, 0x8c, 0x46, 0xfe, 0x8a, 0xd3,
|
0x38, 0x9d, 0xe0, 0x65, 0xb0, 0xa6, 0x38, 0x9d, 0xf2, 0x53, 0x56, 0x3e, 0xd6, 0xcf, 0xcb, 0x28,
|
||||||
0xec, 0x42, 0x4c, 0x55, 0xeb, 0xb6, 0x38, 0x1f, 0xa3, 0xa2, 0xcf, 0xad, 0x4e, 0x0e, 0xee, 0xd2,
|
0xf8, 0x75, 0xe7, 0x9b, 0xda, 0x73, 0xbe, 0x31, 0xf3, 0xbe, 0x79, 0xd1, 0x1f, 0x7c, 0xd8, 0x65,
|
||||||
0x49, 0xab, 0xac, 0x93, 0x7b, 0xf5, 0xe0, 0xfc, 0x00, 0xfd, 0x3a, 0x8c, 0x7d, 0x98, 0x4e, 0xfe,
|
0x1a, 0x87, 0x28, 0x1d, 0xfd, 0x55, 0x07, 0xfe, 0xfd, 0x46, 0x37, 0xd0, 0x2e, 0xec, 0x4b, 0xf4,
|
||||||
0x6d, 0x83, 0x78, 0xaf, 0xc9, 0x2b, 0xe8, 0x56, 0xf6, 0x23, 0xf9, 0xac, 0x61, 0xc5, 0xd4, 0x77,
|
0x71, 0xc5, 0xca, 0x29, 0xef, 0x68, 0xe7, 0x93, 0x7d, 0xca, 0x18, 0x45, 0x09, 0x74, 0x2f, 0xd7,
|
||||||
0xb2, 0xfd, 0xf9, 0x2e, 0x61, 0xc8, 0x49, 0x0a, 0xfd, 0x97, 0xab, 0x28, 0x72, 0xd5, 0x13, 0x30,
|
0xcb, 0xa5, 0x27, 0x3f, 0x09, 0xe3, 0xa7, 0x00, 0xaf, 0xc4, 0x77, 0xe1, 0xd3, 0x8a, 0xf7, 0xab,
|
||||||
0x7d, 0xe7, 0xd3, 0xa5, 0x7c, 0x07, 0xbe, 0x68, 0x38, 0xdf, 0x14, 0x28, 0x6a, 0x7d, 0xb9, 0x73,
|
0x0a, 0x79, 0xaf, 0xcf, 0xf6, 0xae, 0x65, 0x14, 0x7d, 0x0e, 0x4d, 0xe5, 0x05, 0xd4, 0x16, 0x9f,
|
||||||
0x2c, 0x72, 0xf2, 0x15, 0x1c, 0x69, 0x2d, 0x90, 0xae, 0x7c, 0x8a, 0xb6, 0x7b, 0xd8, 0xee, 0x95,
|
0xa6, 0xdd, 0x5e, 0x76, 0x3a, 0xf9, 0x04, 0xa3, 0xe8, 0x0a, 0x60, 0x82, 0x97, 0x1e, 0x23, 0x82,
|
||||||
0x1d, 0xc8, 0xc9, 0x15, 0xc0, 0x8c, 0x46, 0x2e, 0x32, 0x09, 0x6a, 0xd0, 0x50, 0x68, 0xfb, 0x59,
|
0x54, 0xaf, 0xa2, 0xd1, 0xee, 0x31, 0x47, 0x78, 0xfd, 0x42, 0x05, 0xa3, 0x68, 0x0a, 0x9d, 0xe2,
|
||||||
0x64, 0x78, 0x7c, 0x4f, 0x04, 0x72, 0x72, 0x01, 0xbd, 0xea, 0x94, 0x88, 0x25, 0x0b, 0x37, 0x68,
|
0x29, 0x21, 0x5b, 0x34, 0xae, 0xf0, 0x90, 0xf3, 0xc1, 0x33, 0x4f, 0x18, 0x45, 0x43, 0x78, 0xb5,
|
||||||
0xc8, 0xfe, 0xf8, 0x8e, 0x2f, 0xc8, 0xc9, 0x18, 0x1e, 0xac, 0x17, 0x18, 0x51, 0xc8, 0x0b, 0x4b,
|
0x59, 0x68, 0x48, 0x32, 0xd7, 0x96, 0xa8, 0xf3, 0x5e, 0x21, 0xc3, 0x28, 0x7a, 0x03, 0xc7, 0xfa,
|
||||||
0xd3, 0xfe, 0xa0, 0xe2, 0x41, 0x4e, 0xce, 0xe1, 0xa4, 0xb8, 0x13, 0x48, 0x5f, 0xd3, 0x2d, 0x6d,
|
0x8e, 0x40, 0x5d, 0x25, 0x37, 0xb7, 0xd1, 0x9c, 0xf7, 0x2b, 0xb2, 0x92, 0x76, 0xf1, 0x26, 0x2b,
|
||||||
0x30, 0xfb, 0xc3, 0x06, 0x2f, 0x72, 0xe2, 0x43, 0xbf, 0xe9, 0x36, 0x93, 0x47, 0xeb, 0xf0, 0xa6,
|
0xda, 0x15, 0x1b, 0x43, 0xd1, 0xae, 0xbc, 0xfa, 0x53, 0xe8, 0x4c, 0xab, 0x81, 0xa6, 0xcf, 0x02,
|
||||||
0x2d, 0x61, 0x7f, 0xf2, 0x3f, 0x5f, 0x55, 0x2f, 0xaa, 0x77, 0x53, 0xf7, 0xa2, 0xe1, 0xae, 0xeb,
|
0x55, 0x5d, 0xe0, 0xb1, 0xf5, 0x63, 0x6b, 0xc0, 0x7f, 0x38, 0xdf, 0x44, 0x8c, 0xfc, 0xd4, 0x10,
|
||||||
0x5e, 0x34, 0x5d, 0xe6, 0xa9, 0xf9, 0xf3, 0xf1, 0x48, 0xfc, 0x6c, 0x9e, 0xc7, 0xc8, 0x7e, 0xe9,
|
0x7f, 0x93, 0x5f, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x68, 0x86, 0x7d, 0x0a, 0x86, 0x0a, 0x00,
|
||||||
0xc8, 0x3f, 0xc9, 0xaf, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xcc, 0x3b, 0xac, 0x82, 0x0a,
|
0x00,
|
||||||
0x00, 0x00,
|
|
||||||
}
|
}
|
||||||
|
@ -102,11 +102,12 @@ message SetMsgMinSeqResp{
|
|||||||
string errMsg = 2;
|
string errMsg = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SetSendMsgFailedFlagReq{
|
message SetSendMsgStatusReq{
|
||||||
string operationID = 1;
|
string operationID = 1;
|
||||||
|
int32 status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SetSendMsgFailedFlagResp{
|
message SetSendMsgStatusResp{
|
||||||
int32 errCode = 1;
|
int32 errCode = 1;
|
||||||
string errMsg = 2;
|
string errMsg = 2;
|
||||||
}
|
}
|
||||||
@ -138,6 +139,6 @@ service msg {
|
|||||||
rpc DelSuperGroupMsg(DelSuperGroupMsgReq) returns(DelSuperGroupMsgResp);
|
rpc DelSuperGroupMsg(DelSuperGroupMsgReq) returns(DelSuperGroupMsgResp);
|
||||||
rpc ClearMsg(ClearMsgReq) returns(ClearMsgResp);
|
rpc ClearMsg(ClearMsgReq) returns(ClearMsgResp);
|
||||||
rpc SetMsgMinSeq(SetMsgMinSeqReq) returns(SetMsgMinSeqResp);
|
rpc SetMsgMinSeq(SetMsgMinSeqReq) returns(SetMsgMinSeqResp);
|
||||||
rpc SetSendMsgFailedFlag(SetSendMsgFailedFlagReq) returns(SetSendMsgFailedFlagResp);
|
rpc SetSendMsgStatus(SetSendMsgStatusReq) returns(SetSendMsgStatusResp);
|
||||||
rpc GetSendMsgStatus(GetSendMsgStatusReq) returns(GetSendMsgStatusResp);
|
rpc GetSendMsgStatus(GetSendMsgStatusReq) returns(GetSendMsgStatusResp);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -72,15 +72,9 @@ message UserInfo{
|
|||||||
uint32 birth = 6;
|
uint32 birth = 6;
|
||||||
string email = 7;
|
string email = 7;
|
||||||
string ex = 8;
|
string ex = 8;
|
||||||
string createIp = 9;
|
uint32 createTime = 9;
|
||||||
uint32 createTime = 10;
|
int32 appMangerLevel = 10;
|
||||||
string LastLoginIp =11;
|
int32 globalRecvMsgOpt = 11;
|
||||||
uint32 LastLoginTime = 12;
|
|
||||||
int32 LoginTimes = 13;
|
|
||||||
int32 LoginLimit = 14;
|
|
||||||
int32 appMangerLevel = 15;
|
|
||||||
int32 globalRecvMsgOpt = 16;
|
|
||||||
string invitationCode = 17;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message FriendInfo{
|
message FriendInfo{
|
||||||
@ -494,6 +488,9 @@ message UserInfoUpdatedTips{
|
|||||||
message ConversationUpdateTips{
|
message ConversationUpdateTips{
|
||||||
string UserID = 1;
|
string UserID = 1;
|
||||||
repeated string conversationIDList = 2;
|
repeated string conversationIDList = 2;
|
||||||
|
int64 updateUnreadCountTime = 3;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ConversationSetPrivateTips{
|
message ConversationSetPrivateTips{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,93 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
// import "Open_IM/pkg/proto/sdk_ws/ws.proto";
|
|
||||||
option go_package = "./statistics;statistics";
|
|
||||||
package statistics;
|
|
||||||
|
|
||||||
message StatisticsReq {
|
|
||||||
string from = 1;
|
|
||||||
string to = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetActiveUserReq{
|
|
||||||
StatisticsReq StatisticsReq = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UserResp{
|
|
||||||
string NickName = 1;
|
|
||||||
string UserId = 2;
|
|
||||||
int32 MessageNum = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetActiveUserResp {
|
|
||||||
repeated UserResp Users = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetActiveGroupReq{
|
|
||||||
StatisticsReq StatisticsReq = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GroupResp {
|
|
||||||
string GroupName = 1;
|
|
||||||
string GroupId = 2;
|
|
||||||
int32 MessageNum = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetActiveGroupResp {
|
|
||||||
repeated GroupResp Groups = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DateNumList {
|
|
||||||
string Date = 1;
|
|
||||||
int32 Num = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
message GetMessageStatisticsReq {
|
|
||||||
StatisticsReq StatisticsReq = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
message GetMessageStatisticsResp {
|
|
||||||
int32 PrivateMessageNum = 1;
|
|
||||||
int32 GroupMessageNum = 2;
|
|
||||||
repeated DateNumList PrivateMessageNumList = 3;
|
|
||||||
repeated DateNumList GroupMessageNumList = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetGroupStatisticsReq {
|
|
||||||
StatisticsReq StatisticsReq = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
message GetGroupStatisticsResp {
|
|
||||||
int32 IncreaseGroupNum = 1;
|
|
||||||
int32 TotalGroupNum = 2;
|
|
||||||
repeated DateNumList IncreaseGroupNumList = 3;
|
|
||||||
repeated DateNumList TotalGroupNumList = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetUserStatisticsReq {
|
|
||||||
StatisticsReq StatisticsReq = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetUserStatisticsResp {
|
|
||||||
int32 IncreaseUserNum = 1;
|
|
||||||
int32 ActiveUserNum = 2;
|
|
||||||
int32 TotalUserNum = 3;
|
|
||||||
repeated DateNumList IncreaseUserNumList = 4;
|
|
||||||
repeated DateNumList ActiveUserNumList = 5;
|
|
||||||
repeated DateNumList TotalUserNumList = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
service user {
|
|
||||||
rpc GetActiveUser(GetActiveUserReq) returns(GetActiveUserResp);
|
|
||||||
rpc GetActiveGroup(GetActiveGroupReq) returns(GetActiveGroupResp);
|
|
||||||
rpc GetMessageStatistics(GetMessageStatisticsReq) returns(GetMessageStatisticsResp);
|
|
||||||
rpc GetGroupStatistics(GetGroupStatisticsReq) returns(GetGroupStatisticsResp);
|
|
||||||
rpc GetUserStatistics(GetUserStatisticsReq) returns(GetUserStatisticsResp);
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -9,16 +9,6 @@ message CommonResp{
|
|||||||
string errMsg = 2;
|
string errMsg = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message DeleteUsersReq{
|
|
||||||
repeated string DeleteUserIDList = 2;
|
|
||||||
string OpUserID = 3;
|
|
||||||
string OperationID = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteUsersResp{
|
|
||||||
CommonResp CommonResp = 1;
|
|
||||||
repeated string FailedUserIDList = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
message GetAllUserIDReq{
|
message GetAllUserIDReq{
|
||||||
@ -143,94 +133,30 @@ message BatchSetConversationsResp{
|
|||||||
repeated string Failed = 3;
|
repeated string Failed = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ResignUserReq{
|
|
||||||
string UserId = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ResignUserResp{
|
|
||||||
CommonResp commonResp = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetUserByIdReq{
|
|
||||||
string UserId = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message User{
|
|
||||||
string ProfilePhoto = 1;
|
|
||||||
string Nickname = 2;
|
|
||||||
string UserId = 3;
|
|
||||||
string CreateTime = 4;
|
|
||||||
string PhoneNumber = 5;
|
|
||||||
string Email = 6;
|
|
||||||
string Birth = 7;
|
|
||||||
string CreateIp = 8;
|
|
||||||
string LastLoginTime = 9;
|
|
||||||
string LastLoginIp = 10;
|
|
||||||
int32 LoginTimes = 11;
|
|
||||||
int32 Gender = 12;
|
|
||||||
int32 LoginLimit = 13;
|
|
||||||
bool IsBlock = 14;
|
|
||||||
string RegisterIp = 15;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetUserByIdResp{
|
|
||||||
CommonResp CommonResp = 1;
|
|
||||||
User user = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetUsersByNameReq {
|
|
||||||
string UserName = 1;
|
|
||||||
server_api_params.RequestPagination Pagination = 2;
|
|
||||||
string OperationID = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetUsersByNameResp {
|
|
||||||
repeated User users = 1;
|
|
||||||
server_api_params.ResponsePagination Pagination = 2;
|
|
||||||
int32 UserNums = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AlterUserReq{
|
|
||||||
string UserId = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
string PhoneNumber = 3;
|
|
||||||
string Nickname = 4;
|
|
||||||
string Email = 5;
|
|
||||||
string Gender = 6;
|
|
||||||
string Birth =7;
|
|
||||||
string Photo = 8;
|
|
||||||
string OpUserId = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
message AlterUserResp{
|
|
||||||
CommonResp CommonResp = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetUsersReq {
|
message GetUsersReq {
|
||||||
string OperationID = 1;
|
string operationID = 1;
|
||||||
server_api_params.RequestPagination Pagination = 2;
|
server_api_params.RequestPagination pagination = 2;
|
||||||
string UserName = 3;
|
string userName = 3;
|
||||||
|
string userID = 4;
|
||||||
|
string content = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CmsUser {
|
||||||
|
server_api_params.UserInfo user = 1;
|
||||||
|
bool isBlock = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetUsersResp{
|
message GetUsersResp{
|
||||||
CommonResp CommonResp = 1;
|
CommonResp commonResp = 1;
|
||||||
repeated User user = 2;
|
repeated CmsUser userList = 2;
|
||||||
server_api_params.ResponsePagination Pagination = 3;
|
server_api_params.ResponsePagination Pagination = 3;
|
||||||
int32 UserNums = 4;
|
int32 totalNums = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AddUserReq{
|
message AddUserReq{
|
||||||
string OperationID = 1;
|
server_api_params.UserInfo userInfo = 1;
|
||||||
string PhoneNumber = 2;
|
string operationID = 2;
|
||||||
string UserId = 3;
|
|
||||||
string name = 4;
|
|
||||||
string Email = 5;
|
|
||||||
string Gender = 6;
|
|
||||||
string Birth =7;
|
|
||||||
string Photo = 8;
|
|
||||||
string OpUserId = 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message AddUserResp{
|
message AddUserResp{
|
||||||
@ -239,10 +165,10 @@ message AddUserResp{
|
|||||||
|
|
||||||
|
|
||||||
message BlockUserReq{
|
message BlockUserReq{
|
||||||
string UserId = 1;
|
string userID = 1;
|
||||||
string EndDisableTime = 2;
|
string endDisableTime = 2;
|
||||||
string OperationID = 3;
|
string operationID = 3;
|
||||||
string OpUserId = 4;
|
string opUserID = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message BlockUserResp{
|
message BlockUserResp{
|
||||||
@ -250,9 +176,9 @@ message BlockUserResp{
|
|||||||
}
|
}
|
||||||
|
|
||||||
message UnBlockUserReq{
|
message UnBlockUserReq{
|
||||||
string UserId = 1;
|
string userID = 1;
|
||||||
string OperationID = 2;
|
string operationID = 2;
|
||||||
string OpUserId = 3;
|
string opUserID = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UnBlockUserResp{
|
message UnBlockUserResp{
|
||||||
@ -260,13 +186,14 @@ message UnBlockUserResp{
|
|||||||
}
|
}
|
||||||
|
|
||||||
message GetBlockUsersReq{
|
message GetBlockUsersReq{
|
||||||
server_api_params.RequestPagination Pagination = 1;
|
server_api_params.RequestPagination pagination = 1;
|
||||||
string OperationID = 2;
|
string operationID = 2;
|
||||||
int32 BlockUserNum = 3;
|
string userID = 3;
|
||||||
|
int32 totalBlockUserNum = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message BlockUser {
|
message BlockUser {
|
||||||
User User = 1;
|
server_api_params.UserInfo UserInfo = 1;
|
||||||
string BeginDisableTime = 2;
|
string BeginDisableTime = 2;
|
||||||
string EndDisableTime = 3;
|
string EndDisableTime = 3;
|
||||||
}
|
}
|
||||||
@ -278,32 +205,11 @@ message GetBlockUsersResp{
|
|||||||
int32 UserNums = 4;
|
int32 UserNums = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetBlockUserByIdReq {
|
|
||||||
string User_id = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetBlockUserByIdResp {
|
|
||||||
BlockUser BlockUser = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteUserReq {
|
|
||||||
string User_id = 1;
|
|
||||||
string OperationID = 2;
|
|
||||||
string OpUserId = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteUserResp {
|
|
||||||
CommonResp CommonResp = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
service user {
|
service user {
|
||||||
rpc GetUserInfo(GetUserInfoReq) returns(GetUserInfoResp);
|
rpc GetUserInfo(GetUserInfoReq) returns(GetUserInfoResp);
|
||||||
rpc UpdateUserInfo(UpdateUserInfoReq) returns(UpdateUserInfoResp);
|
rpc UpdateUserInfo(UpdateUserInfoReq) returns(UpdateUserInfoResp);
|
||||||
rpc SetGlobalRecvMessageOpt(SetGlobalRecvMessageOptReq) returns(SetGlobalRecvMessageOptResp);
|
rpc SetGlobalRecvMessageOpt(SetGlobalRecvMessageOptReq) returns(SetGlobalRecvMessageOptResp);
|
||||||
rpc DeleteUsers(DeleteUsersReq)returns(DeleteUsersResp);
|
|
||||||
rpc GetAllUserID(GetAllUserIDReq)returns(GetAllUserIDResp);
|
rpc GetAllUserID(GetAllUserIDReq)returns(GetAllUserIDResp);
|
||||||
|
|
||||||
rpc AccountCheck(AccountCheckReq)returns(AccountCheckResp);
|
rpc AccountCheck(AccountCheckReq)returns(AccountCheckResp);
|
||||||
@ -314,15 +220,13 @@ service user {
|
|||||||
rpc SetConversation(SetConversationReq)returns(SetConversationResp);
|
rpc SetConversation(SetConversationReq)returns(SetConversationResp);
|
||||||
rpc SetRecvMsgOpt(SetRecvMsgOptReq)returns(SetRecvMsgOptResp);
|
rpc SetRecvMsgOpt(SetRecvMsgOptReq)returns(SetRecvMsgOptResp);
|
||||||
|
|
||||||
rpc GetUserById(GetUserByIdReq) returns (GetUserByIdResp);
|
|
||||||
rpc GetUsersByName(GetUsersByNameReq) returns (GetUsersByNameResp);
|
|
||||||
rpc ResignUser(ResignUserReq) returns (ResignUserResp);
|
|
||||||
rpc AlterUser(AlterUserReq) returns (AlterUserResp);
|
|
||||||
rpc GetUsers(GetUsersReq) returns (GetUsersResp);
|
rpc GetUsers(GetUsersReq) returns (GetUsersResp);
|
||||||
|
|
||||||
rpc AddUser(AddUserReq) returns (AddUserResp);
|
rpc AddUser(AddUserReq) returns (AddUserResp);
|
||||||
|
|
||||||
rpc BlockUser(BlockUserReq) returns (BlockUserResp);
|
rpc BlockUser(BlockUserReq) returns (BlockUserResp);
|
||||||
rpc UnBlockUser(UnBlockUserReq) returns (UnBlockUserResp);
|
rpc UnBlockUser(UnBlockUserReq) returns (UnBlockUserResp);
|
||||||
rpc GetBlockUsers(GetBlockUsersReq) returns (GetBlockUsersResp);
|
rpc GetBlockUsers(GetBlockUsersReq) returns (GetBlockUsersResp);
|
||||||
rpc GetBlockUserById(GetBlockUserByIdReq) returns (GetBlockUserByIdResp);
|
|
||||||
rpc DeleteUser(DeleteUserReq) returns (DeleteUserResp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ service_port_name=(
|
|||||||
openImGroupPort
|
openImGroupPort
|
||||||
openImAuthPort
|
openImAuthPort
|
||||||
openImPushPort
|
openImPushPort
|
||||||
openImStatisticsPort
|
|
||||||
openImMessageCmsPort
|
|
||||||
openImAdminCmsPort
|
openImAdminCmsPort
|
||||||
openImOfficePort
|
openImOfficePort
|
||||||
openImOrganizationPort
|
openImOrganizationPort
|
||||||
|
@ -46,8 +46,6 @@ service_source_root=(
|
|||||||
../cmd/rpc/open_im_group/
|
../cmd/rpc/open_im_group/
|
||||||
../cmd/rpc/open_im_auth/
|
../cmd/rpc/open_im_auth/
|
||||||
../cmd/rpc/open_im_admin_cms/
|
../cmd/rpc/open_im_admin_cms/
|
||||||
../cmd/rpc/open_im_message_cms/
|
|
||||||
../cmd/rpc/open_im_statistics/
|
|
||||||
../cmd/rpc/open_im_office/
|
../cmd/rpc/open_im_office/
|
||||||
../cmd/rpc/open_im_organization/
|
../cmd/rpc/open_im_organization/
|
||||||
../cmd/rpc/open_im_conversation/
|
../cmd/rpc/open_im_conversation/
|
||||||
@ -71,8 +69,6 @@ service_names=(
|
|||||||
open_im_group
|
open_im_group
|
||||||
open_im_auth
|
open_im_auth
|
||||||
open_im_admin_cms
|
open_im_admin_cms
|
||||||
open_im_message_cms
|
|
||||||
open_im_statistics
|
|
||||||
open_im_office
|
open_im_office
|
||||||
open_im_organization
|
open_im_organization
|
||||||
open_im_conversation
|
open_im_conversation
|
||||||
|
@ -15,8 +15,6 @@ service_filename=(
|
|||||||
open_im_group
|
open_im_group
|
||||||
open_im_auth
|
open_im_auth
|
||||||
open_im_admin_cms
|
open_im_admin_cms
|
||||||
open_im_message_cms
|
|
||||||
open_im_statistics
|
|
||||||
${msg_name}
|
${msg_name}
|
||||||
open_im_office
|
open_im_office
|
||||||
open_im_organization
|
open_im_organization
|
||||||
@ -35,8 +33,6 @@ service_port_name=(
|
|||||||
openImGroupPort
|
openImGroupPort
|
||||||
openImAuthPort
|
openImAuthPort
|
||||||
openImAdminCmsPort
|
openImAdminCmsPort
|
||||||
openImMessageCmsPort
|
|
||||||
openImStatisticsPort
|
|
||||||
openImMessagePort
|
openImMessagePort
|
||||||
openImOfficePort
|
openImOfficePort
|
||||||
openImOrganizationPort
|
openImOrganizationPort
|
||||||
|
Loading…
x
Reference in New Issue
Block a user