mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 19:22:46 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
commit
c9ab2b507b
@ -97,6 +97,7 @@ func main() {
|
|||||||
{
|
{
|
||||||
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
|
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
|
||||||
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
|
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
|
||||||
|
authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //1
|
||||||
}
|
}
|
||||||
//Third service
|
//Third service
|
||||||
thirdGroup := r.Group("/third")
|
thirdGroup := r.Group("/third")
|
||||||
@ -122,6 +123,7 @@ func main() {
|
|||||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||||
managementGroup.POST("/account_check", manage.AccountCheck) //1
|
managementGroup.POST("/account_check", manage.AccountCheck) //1
|
||||||
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||||
|
|
||||||
}
|
}
|
||||||
//Conversation
|
//Conversation
|
||||||
conversationGroup := r.Group("/conversation")
|
conversationGroup := r.Group("/conversation")
|
||||||
|
@ -98,7 +98,8 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
|||||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
|
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
|
||||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
|
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
|
||||||
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
||||||
bucket: openim
|
bucket: openim # 存储内容桶
|
||||||
|
appBucket: app # 存储app的桶
|
||||||
location: us-east-1
|
location: us-east-1
|
||||||
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的
|
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的
|
||||||
endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写
|
endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写
|
||||||
|
@ -25,10 +25,10 @@ func DelMsg(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
msgClient := pbChat.NewChatClient(grpcConn)
|
msgClient := pbChat.NewChatClient(grpcConn)
|
||||||
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
||||||
@ -39,5 +39,6 @@ func DelMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp.ErrCode = respPb.ErrCode
|
resp.ErrCode = respPb.ErrCode
|
||||||
resp.ErrMsg = respPb.ErrMsg
|
resp.ErrMsg = respPb.ErrMsg
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@ func SetConversation(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.Conversation = &pbUser.Conversation{}
|
reqPb.Conversation = &pbUser.Conversation{}
|
||||||
err := utils.CopyStructFields(&reqPb, req)
|
err := utils.CopyStructFields(&reqPb, req)
|
||||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||||
@ -56,13 +56,13 @@ func ModifyConversationField(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.Conversation = &pbConversation.Conversation{}
|
reqPb.Conversation = &pbConversation.Conversation{}
|
||||||
err := utils.CopyStructFields(&reqPb, req)
|
err := utils.CopyStructFields(&reqPb, req)
|
||||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName)
|
||||||
client := pbConversation.NewConversationClient(etcdConn)
|
client := pbConversation.NewConversationClient(etcdConn)
|
||||||
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
|
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
|
||||||
@ -88,10 +88,10 @@ func BatchSetConversations(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
||||||
@ -120,10 +120,10 @@ func GetAllConversations(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
||||||
@ -152,10 +152,10 @@ func GetConversation(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
||||||
@ -184,10 +184,10 @@ func GetConversations(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
||||||
@ -216,10 +216,10 @@ func SetRecvMsgOpt(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
minioClient *minio.Client
|
MinioClient *minio.Client
|
||||||
)
|
)
|
||||||
|
|
||||||
func MinioInit() {
|
func MinioInit() {
|
||||||
@ -31,7 +31,7 @@ func MinioInit() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
|
||||||
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
|
MinioClient, err = minio.New(minioUrl.Host, &minio.Options{
|
||||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||||
Secure: false,
|
Secure: false,
|
||||||
})
|
})
|
||||||
@ -44,10 +44,25 @@ func MinioInit() {
|
|||||||
Region: config.Config.Credential.Minio.Location,
|
Region: config.Config.Credential.Minio.Location,
|
||||||
ObjectLocking: false,
|
ObjectLocking: false,
|
||||||
}
|
}
|
||||||
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
|
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
||||||
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||||
|
if err == nil && exists {
|
||||||
|
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
||||||
|
} else {
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
}
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// make app bucket
|
||||||
|
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.AppBucket, opt)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
||||||
|
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||||
if err == nil && exists {
|
if err == nil && exists {
|
||||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
||||||
} else {
|
} else {
|
||||||
@ -59,7 +74,7 @@ func MinioInit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 自动化桶public的代码
|
// 自动化桶public的代码
|
||||||
err = minioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
|
err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewDebug("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
log.NewDebug("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
||||||
return
|
return
|
||||||
|
@ -33,7 +33,7 @@ func MinioUploadFile(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
var errInfo string
|
||||||
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
@ -61,7 +61,7 @@ func MinioUploadFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
|
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
|
||||||
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
|
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile 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()})
|
||||||
@ -72,6 +72,7 @@ func MinioUploadFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
file, err := c.FormFile("file")
|
file, err := c.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "FormFile failed", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -83,10 +84,10 @@ func MinioUploadFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
|
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType)
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType)
|
||||||
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
|
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "upload file error")
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "upload file error" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.NewName = newName
|
resp.NewName = newName
|
||||||
@ -106,7 +107,7 @@ func MinioStorageCredential(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
var errInfo string
|
||||||
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
@ -26,21 +26,18 @@ func GetUsersInfoFromCache(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(params.OperationID, "GetUsersInfoFromCache req: ", params)
|
||||||
req := &rpc.GetUserInfoReq{}
|
req := &rpc.GetUserInfoReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
var errInfo string
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := rpc.NewUserClient(etcdConn)
|
client := rpc.NewUserClient(etcdConn)
|
||||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||||
@ -54,117 +51,12 @@ func GetUsersInfoFromCache(c *gin.Context) {
|
|||||||
publicUserInfoList = append(publicUserInfoList,
|
publicUserInfoList = append(publicUserInfoList,
|
||||||
&open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
|
&open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
|
resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
|
||||||
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
|
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
|
||||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//func GetUsersInfoFromCache(c *gin.Context) {
|
|
||||||
// params := api.GetUsersInfoReq{}
|
|
||||||
// if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
// log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// getUserInfoReq := &rpc.GetUserInfoReq{}
|
|
||||||
// getUserInfoReq.OperationID = params.OperationID
|
|
||||||
// var ok bool
|
|
||||||
// ok, getUserInfoReq.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), getUserInfoReq.OperationID)
|
|
||||||
// if !ok {
|
|
||||||
// log.NewError(getUserInfoReq.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
|
||||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// log.NewInfo(params.OperationID, "GetUserInfo args ", getUserInfoReq.String())
|
|
||||||
// reqCacheGetUserInfo := &cacheRpc.GetUserInfoFromCacheReq{}
|
|
||||||
// utils.CopyStructFields(reqCacheGetUserInfo, ¶ms)
|
|
||||||
// var userInfoList []*open_im_sdk.UserInfo
|
|
||||||
// var publicUserInfoList []*open_im_sdk.PublicUserInfo
|
|
||||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
|
||||||
// cacheClient := cacheRpc.NewCacheClient(etcdConn)
|
|
||||||
// cacheResp, err := cacheClient.GetUserInfoFromCache(context.Background(), reqCacheGetUserInfo)
|
|
||||||
// if err != nil {
|
|
||||||
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", err.Error())
|
|
||||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed: " + err.Error()})
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if cacheResp.CommonResp.ErrCode != 0 {
|
|
||||||
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", cacheResp.CommonResp)
|
|
||||||
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}
|
|
||||||
// resp.Data = []map[string]interface{}{}
|
|
||||||
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
|
|
||||||
// c.JSON(http.StatusOK, resp)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// log.NewInfo(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "cacheResp:", cacheResp.String())
|
|
||||||
// userInfoList = cacheResp.UserInfoList
|
|
||||||
// var needCacheUserIDList []string
|
|
||||||
// for _, userID := range reqCacheGetUserInfo.UserIDList {
|
|
||||||
// isGetUserInfoFromCache := false
|
|
||||||
// for _, cacheUser := range userInfoList {
|
|
||||||
// if cacheUser.UserID == userID {
|
|
||||||
// isGetUserInfoFromCache = true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if !isGetUserInfoFromCache {
|
|
||||||
// needCacheUserIDList = append(needCacheUserIDList, userID)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if len(needCacheUserIDList) == 0 {
|
|
||||||
// log.NewInfo(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "get all userInfo from cache success")
|
|
||||||
// for _, v := range userInfoList {
|
|
||||||
// publicUserInfoList = append(publicUserInfoList,
|
|
||||||
// &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
|
|
||||||
// }
|
|
||||||
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
|
|
||||||
// resp.Data = jsonData.JsonDataList(resp.UserInfoList)
|
|
||||||
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
|
|
||||||
// c.JSON(http.StatusOK, resp)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// log.NewDebug(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "need cache user list", needCacheUserIDList)
|
|
||||||
// getUserInfoReq.UserIDList = needCacheUserIDList
|
|
||||||
// etcdConn = getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
|
||||||
// client := rpc.NewUserClient(etcdConn)
|
|
||||||
// rpcResp, err := client.GetUserInfo(context.Background(), getUserInfoReq)
|
|
||||||
// if err != nil {
|
|
||||||
// log.NewError(getUserInfoReq.OperationID, "GetUserInfo failed ", err.Error(), getUserInfoReq.String())
|
|
||||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed" + err.Error()})
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if rpcResp.CommonResp.ErrCode != 0 {
|
|
||||||
// log.NewError(getUserInfoReq.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed", cacheResp.CommonResp)
|
|
||||||
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: cacheResp.CommonResp.ErrCode, ErrMsg: cacheResp.CommonResp.ErrMsg}}
|
|
||||||
// resp.Data = []map[string]interface{}{}
|
|
||||||
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
|
|
||||||
// c.JSON(http.StatusOK, resp)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// userInfoList = append(userInfoList, rpcResp.UserInfoList...)
|
|
||||||
// cacheUpdateUserInfoReq := &cacheRpc.UpdateUserInfoToCacheReq{
|
|
||||||
// UserInfoList: rpcResp.UserInfoList,
|
|
||||||
// OperationID: getUserInfoReq.OperationID,
|
|
||||||
// }
|
|
||||||
// _, err = cacheClient.UpdateUserInfoToCache(context.Background(), cacheUpdateUserInfoReq)
|
|
||||||
// if err != nil {
|
|
||||||
// log.NewError(getUserInfoReq.OperationID, "GetUserInfo failed ", err.Error())
|
|
||||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// userInfoList = rpcResp.UserInfoList
|
|
||||||
// for _, v := range userInfoList {
|
|
||||||
// publicUserInfoList = append(publicUserInfoList,
|
|
||||||
// &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
|
|
||||||
// }
|
|
||||||
// resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
|
|
||||||
// resp.Data = jsonData.JsonDataList(resp.UserInfoList)
|
|
||||||
// log.NewInfo(getUserInfoReq.OperationID, "GetUserInfo api return ", resp)
|
|
||||||
// c.JSON(http.StatusOK, resp)
|
|
||||||
//}
|
|
||||||
|
|
||||||
func GetFriendIDListFromCache(c *gin.Context) {
|
func GetFriendIDListFromCache(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req api.GetFriendIDListFromCacheReq
|
req api.GetFriendIDListFromCacheReq
|
||||||
@ -177,18 +69,17 @@ func GetFriendIDListFromCache(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||||
reqPb.OperationID = req.OperationID
|
reqPb.OperationID = req.OperationID
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
var errInfo string
|
||||||
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
||||||
client := cacheRpc.NewCacheClient(etcdConn)
|
client := cacheRpc.NewCacheClient(etcdConn)
|
||||||
respPb, err := client.GetFriendIDListFromCache(context.Background(), &reqPb)
|
respPb, err := client.GetFriendIDListFromCache(context.Background(), &reqPb)
|
||||||
@ -214,8 +105,8 @@ func GetBlackIDListFromCache(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.OperationID = req.OperationID
|
reqPb.OperationID = req.OperationID
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
var errInfo string
|
||||||
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
@ -225,7 +116,6 @@ func GetBlackIDListFromCache(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
|
||||||
}
|
}
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
||||||
client := cacheRpc.NewCacheClient(etcdConn)
|
client := cacheRpc.NewCacheClient(etcdConn)
|
||||||
respPb, err := client.GetBlackIDListFromCache(context.Background(), &reqPb)
|
respPb, err := client.GetBlackIDListFromCache(context.Background(), &reqPb)
|
||||||
|
@ -1,25 +1,29 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"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"
|
"Open_IM/pkg/common/constant"
|
||||||
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
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"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"Open_IM/internal/api/third"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// register
|
// register
|
||||||
func AdminLogin(c *gin.Context) {
|
func AdminLogin(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.AdminLoginRequest
|
req apiStruct.AdminLoginRequest
|
||||||
resp cms_api_struct.AdminLoginResponse
|
resp apiStruct.AdminLoginResponse
|
||||||
reqPb pbAdmin.AdminLoginReq
|
reqPb pbAdmin.AdminLoginReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
@ -40,3 +44,87 @@ func AdminLogin(c *gin.Context) {
|
|||||||
resp.Token = respPb.Token
|
resp.Token = respPb.Token
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UploadUpdateApp(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apiStruct.UploadUpdateAppReq
|
||||||
|
resp apiStruct.UploadUpdateAppResp
|
||||||
|
)
|
||||||
|
if err := c.Bind(&req); err != nil {
|
||||||
|
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
newFileName, newYamlName, err := utils.GetUploadAppNewName(req.Type, req.Version)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUploadAppNewName failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file type" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fileObj, err := req.File.Open()
|
||||||
|
yamlObj, err := req.Yaml.Open()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file path" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "name: ", newFileName, newYamlName)
|
||||||
|
// v2.0.9_app_linux v2.0.9_yaml_linux
|
||||||
|
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newFileName, fileObj, req.File.Size, minio.PutObjectOptions{})
|
||||||
|
_, err = apiThird.MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, newYamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{})
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateAppVersion error", err.Error())
|
||||||
|
resp.ErrCode = http.StatusInternalServerError
|
||||||
|
resp.ErrMsg = err.Error()
|
||||||
|
c.JSON(http.StatusInternalServerError, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName())
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetDownloadURL(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req apiStruct.GetDownloadURLReq
|
||||||
|
resp apiStruct.GetDownloadURLResp
|
||||||
|
)
|
||||||
|
defer func() {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
}()
|
||||||
|
if err := c.Bind(&req); err != nil {
|
||||||
|
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
fileName, yamlName, err := utils.GetUploadAppNewName(req.Type, req.Version)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUploadAppNewName failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "invalid file type" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
app, err := imdb.GetNewestVersion(req.Type)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "getNewestVersion failed" + err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if app.Version != req.Version {
|
||||||
|
resp.Data.HasNewVersion = true
|
||||||
|
if app.ForceUpdate == true {
|
||||||
|
resp.Data.ForceUpdate = true
|
||||||
|
}
|
||||||
|
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + yamlName
|
||||||
|
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + fileName
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
} else {
|
||||||
|
resp.Data.HasNewVersion = false
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,6 +28,7 @@ func GetGroupById(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
@ -44,6 +45,7 @@ func GetGroupById(c *gin.Context) {
|
|||||||
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
||||||
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
||||||
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
|
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +60,7 @@ func GetGroups(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
@ -83,6 +86,7 @@ func GetGroups(c *gin.Context) {
|
|||||||
resp.GroupNums = int(respPb.GroupNum)
|
resp.GroupNums = int(respPb.GroupNum)
|
||||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +101,7 @@ func GetGroupByName(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupName = req.GroupName
|
reqPb.GroupName = req.GroupName
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||||
@ -123,6 +128,7 @@ func GetGroupByName(c *gin.Context) {
|
|||||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.GroupNums = int(respPb.GroupNums)
|
resp.GroupNums = int(respPb.GroupNums)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +143,7 @@ func CreateGroup(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
||||||
reqPb.GroupInfo.GroupName = req.GroupName
|
reqPb.GroupInfo.GroupName = req.GroupName
|
||||||
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
||||||
@ -169,6 +176,7 @@ func BanGroupChat(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.Status = constant.GroupBanChat
|
reqPb.Status = constant.GroupBanChat
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
@ -193,6 +201,7 @@ func BanPrivateChat(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.Status = constant.GroupBanPrivateChat
|
reqPb.Status = constant.GroupBanPrivateChat
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
@ -216,6 +225,7 @@ func OpenGroupChat(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.Status = constant.GroupOk
|
reqPb.Status = constant.GroupOk
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
@ -239,6 +249,7 @@ func OpenPrivateChat(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.Status = constant.GroupOk
|
reqPb.Status = constant.GroupOk
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
@ -263,6 +274,7 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{
|
reqPb.Pagination = &commonPb.RequestPagination{
|
||||||
PageNumber: int32(req.PageNumber),
|
PageNumber: int32(req.PageNumber),
|
||||||
ShowNumber: int32(req.ShowNumber),
|
ShowNumber: int32(req.ShowNumber),
|
||||||
@ -290,6 +302,7 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
|
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +317,7 @@ func AddGroupMembers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.UserIds = req.Members
|
reqPb.UserIds = req.Members
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
@ -316,6 +330,7 @@ func AddGroupMembers(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp.Success = respPb.Success
|
resp.Success = respPb.Success
|
||||||
resp.Failed = respPb.Failed
|
resp.Failed = respPb.Failed
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,6 +345,7 @@ func RemoveGroupMembers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.UserIds = req.Members
|
reqPb.UserIds = req.Members
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
@ -342,6 +358,7 @@ func RemoveGroupMembers(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp.Success = respPb.Success
|
resp.Success = respPb.Success
|
||||||
resp.Failed = respPb.Failed
|
resp.Failed = respPb.Failed
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,6 +373,7 @@ func DeleteGroup(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
@ -379,6 +397,7 @@ func SetGroupMaster(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.UserId = req.UserId
|
reqPb.UserId = req.UserId
|
||||||
reqPb.RoleLevel = constant.GroupOwner
|
reqPb.RoleLevel = constant.GroupOwner
|
||||||
@ -404,6 +423,7 @@ func SetGroupOrdinaryUsers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.UserId = req.UserId
|
reqPb.UserId = req.UserId
|
||||||
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
||||||
@ -424,6 +444,7 @@ func AlterGroupInfo(c *gin.Context) {
|
|||||||
_ cms_api_struct.SetGroupMasterResponse
|
_ cms_api_struct.SetGroupMasterResponse
|
||||||
reqPb pbGroup.SetGroupInfoReq
|
reqPb pbGroup.SetGroupInfoReq
|
||||||
)
|
)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
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)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
|
@ -78,6 +78,7 @@ func GetChatLogs(c *gin.Context) {
|
|||||||
ShowNumber: int32(req.ShowNumber),
|
ShowNumber: int32(req.ShowNumber),
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||||
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
||||||
@ -105,5 +106,6 @@ func GetChatLogs(c *gin.Context) {
|
|||||||
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("", utils.GetSelfFuncName(), "resp", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ func NewGinRouter() *gin.Engine {
|
|||||||
adminRouterGroup := router.Group("/admin")
|
adminRouterGroup := router.Group("/admin")
|
||||||
{
|
{
|
||||||
adminRouterGroup.POST("/login", admin.AdminLogin)
|
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||||||
|
adminRouterGroup.POST("/upload_update_app", admin.UploadUpdateApp)
|
||||||
|
adminRouterGroup.POST("/get_download_url", admin.GetDownloadURL)
|
||||||
}
|
}
|
||||||
r2 := router.Group("")
|
r2 := router.Group("")
|
||||||
r2.Use(middleware.JWTAuth())
|
r2.Use(middleware.JWTAuth())
|
||||||
|
@ -27,6 +27,7 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -57,6 +58,7 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
MessageNum: int(v.Num),
|
MessageNum: int(v.Num),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +74,7 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -112,6 +115,7 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
TotalUserNum: int(v.Num),
|
TotalUserNum: int(v.Num),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +131,7 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -160,6 +165,7 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +181,7 @@ func GetActiveUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -185,6 +192,7 @@ func GetActiveUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +208,7 @@ func GetActiveGroup(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -220,5 +229,6 @@ func GetActiveGroup(c *gin.Context) {
|
|||||||
MessageNum: int(group.MessageNum),
|
MessageNum: int(group.MessageNum),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ func GetUserById(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -43,6 +44,7 @@ func GetUserById(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(&resp, respPb.User)
|
utils.CopyStructFields(&resp, respPb.User)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +54,7 @@ func GetUsersByName(c *gin.Context) {
|
|||||||
resp cms_api_struct.GetUsersByNameResponse
|
resp cms_api_struct.GetUsersByNameResponse
|
||||||
reqPb pb.GetUsersByNameReq
|
reqPb pb.GetUsersByNameReq
|
||||||
)
|
)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&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, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
@ -74,6 +77,7 @@ func GetUsersByName(c *gin.Context) {
|
|||||||
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.UserNums = respPb.UserNums
|
resp.UserNums = respPb.UserNums
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +93,7 @@ func GetUsers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
utils.CopyStructFields(&reqPb.Pagination, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -101,6 +106,7 @@ func GetUsers(c *gin.Context) {
|
|||||||
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.UserNums = respPb.UserNums
|
resp.UserNums = respPb.UserNums
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -116,14 +122,15 @@ func ResignUser(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
fmt.Println(reqPb.UserId)
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.ResignUser(context.Background(), &reqPb)
|
_, err := client.ResignUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
openIMHttp.RespHttp200(c, err, resp)
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +145,7 @@ func AlterUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -159,6 +167,7 @@ func AddUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -182,6 +191,7 @@ func BlockUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -205,6 +215,7 @@ func UnblockUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -213,6 +224,7 @@ func UnblockUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, err, resp)
|
openIMHttp.RespHttp200(c, err, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,6 +241,7 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
utils.CopyStructFields(&reqPb.Pagination, &req)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
@ -255,6 +268,7 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
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.UserNums = respPb.UserNums
|
resp.UserNums = respPb.UserNums
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +283,7 @@ func GetBlockUserById(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.UserId = req.UserId
|
reqPb.UserId = req.UserId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
@ -281,6 +296,7 @@ func GetBlockUserById(c *gin.Context) {
|
|||||||
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
|
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
|
||||||
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
|
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
|
||||||
utils.CopyStructFields(&resp, respPb.BlockUser.User)
|
utils.CopyStructFields(&resp, respPb.BlockUser.User)
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,6 +310,7 @@ func DeleteUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||||
reqPb.UserId = req.UserId
|
reqPb.UserId = req.UserId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
|
@ -95,5 +95,6 @@ func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLogi
|
|||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
||||||
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
|
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
21
internal/rpc/cache/cache.go
vendored
21
internal/rpc/cache/cache.go
vendored
@ -89,6 +89,7 @@ func SyncDB2Cache() error {
|
|||||||
var err error
|
var err error
|
||||||
log.NewInfo("0", utils.GetSelfFuncName())
|
log.NewInfo("0", utils.GetSelfFuncName())
|
||||||
userList, err := imdb.GetAllUser()
|
userList, err := imdb.GetAllUser()
|
||||||
|
log.NewDebug("", utils.GetSelfFuncName(), "userList", userList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return utils.Wrap(err, "")
|
return utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
@ -117,10 +118,10 @@ func updateAllUserToCache(userList []db.User) error {
|
|||||||
}
|
}
|
||||||
m, err := utils.Pb2Map(userInfoPb)
|
m, err := utils.Pb2Map(userInfoPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", utils.GetSelfFuncName(), err.Error())
|
log.NewWarn("", utils.GetSelfFuncName(), err.Error())
|
||||||
}
|
}
|
||||||
if err := db.DB.SetUserInfoToCache(userInfo.UserID, m); err != nil {
|
if err := db.DB.SetUserInfoToCache(userInfo.UserID, m); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error())
|
log.NewWarn("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.NewInfo("0", utils.GetSelfFuncName(), "ok")
|
log.NewInfo("0", utils.GetSelfFuncName(), "ok")
|
||||||
@ -131,19 +132,19 @@ func updateAllGroupMemberListToCache() error {
|
|||||||
log.NewInfo("0", utils.GetSelfFuncName())
|
log.NewInfo("0", utils.GetSelfFuncName())
|
||||||
groupIDList, err := imdb.GetAllGroupIDList()
|
groupIDList, err := imdb.GetAllGroupIDList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "getAllGroupIDList failed", err.Error())
|
log.NewWarn("0", utils.GetSelfFuncName(), "getAllGroupIDList failed", err.Error())
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
for _, groupID := range groupIDList {
|
for _, groupID := range groupIDList {
|
||||||
groupMemberIDList, err := imdb.GetGroupMemberIDListByGroupID(groupID)
|
groupMemberIDList, err := imdb.GetGroupMemberIDListByGroupID(groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error())
|
log.NewWarn("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//log.NewDebug("", utils.GetSelfFuncName(), "groupMemberIDList", groupMemberIDList)
|
//log.NewDebug("", utils.GetSelfFuncName(), "groupMemberIDList", groupMemberIDList)
|
||||||
if len(groupMemberIDList) > 0 {
|
if len(groupMemberIDList) > 0 {
|
||||||
if err := db.DB.AddGroupMemberToCache(groupID, groupMemberIDList...); err != nil {
|
if err := db.DB.AddGroupMemberToCache(groupID, groupMemberIDList...); err != nil {
|
||||||
log.NewError("", utils.GetSelfFuncName(), "AddGroupMemberToCache", err.Error())
|
log.NewWarn("", utils.GetSelfFuncName(), "AddGroupMemberToCache", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,13 +157,12 @@ func updateAllFriendToCache(userList []db.User) error {
|
|||||||
for _, user := range userList {
|
for _, user := range userList {
|
||||||
friendIDList, err := imdb.GetFriendIDListByUserID(user.UserID)
|
friendIDList, err := imdb.GetFriendIDListByUserID(user.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewWarn("0", utils.GetSelfFuncName(), err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//log.NewDebug("", utils.GetSelfFuncName(), "friendIDList", user.UserID, friendIDList)
|
|
||||||
if len(friendIDList) > 0 {
|
if len(friendIDList) > 0 {
|
||||||
if err := db.DB.AddFriendToCache(user.UserID, friendIDList...); err != nil {
|
if err := db.DB.AddFriendToCache(user.UserID, friendIDList...); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error(), friendIDList, user.UserID)
|
log.NewWarn("0", utils.GetSelfFuncName(), err.Error(), friendIDList, user.UserID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,13 +175,12 @@ func updateAllBlackListToCache(userList []db.User) error {
|
|||||||
for _, user := range userList {
|
for _, user := range userList {
|
||||||
blackIDList, err := imdb.GetBlackIDListByUserID(user.UserID)
|
blackIDList, err := imdb.GetBlackIDListByUserID(user.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", utils.GetSelfFuncName(), err.Error())
|
log.NewWarn("", utils.GetSelfFuncName(), err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//log.NewDebug("", utils.GetSelfFuncName(), "updateAllBlackListToCache", user.UserID, blackIDList)
|
|
||||||
if len(blackIDList) > 0 {
|
if len(blackIDList) > 0 {
|
||||||
if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList...); err != nil {
|
if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList...); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewWarn("0", utils.GetSelfFuncName(), err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp := pbGroup.GetGroupsInfoResp{GroupInfoList: groupsInfoList}
|
resp := pbGroup.GetGroupsInfoResp{GroupInfoList: groupsInfoList}
|
||||||
log.NewInfo(req.OperationID, "GetGroupsInfo rpc return ", resp)
|
log.NewInfo(req.OperationID, "GetGroupsInfo rpc return ", resp.String())
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,7 +990,8 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
|
|||||||
for _, v := range groups {
|
for _, v := range groups {
|
||||||
groupMember, err := imdb.GetGroupMaster(v.GroupID)
|
groupMember, err := imdb.GetGroupMaster(v.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
|
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
|
||||||
GroupInfo: &open_im_sdk.GroupInfo{
|
GroupInfo: &open_im_sdk.GroupInfo{
|
||||||
@ -1006,7 +1007,7 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
|
|||||||
GroupMasterName: groupMember.Nickname,
|
GroupMasterName: groupMember.Nickname,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,6 +1087,7 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
|
|||||||
CurrentPage: req.Pagination.PageNumber,
|
CurrentPage: req.Pagination.PageNumber,
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
ShowNumber: req.Pagination.ShowNumber,
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
|
|||||||
chatLog.RecvID = req.GroupId
|
chatLog.RecvID = req.GroupId
|
||||||
chatLog.SendID = req.UserId
|
chatLog.SendID = req.UserId
|
||||||
}
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
|
||||||
nums, err := imdb.GetChatLogCount(chatLog)
|
nums, err := imdb.GetChatLogCount(chatLog)
|
||||||
resp.ChatLogsNum = int32(nums)
|
resp.ChatLogsNum = int32(nums)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -12,13 +12,6 @@ import (
|
|||||||
func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (*commonPb.DelMsgListResp, error) {
|
func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (*commonPb.DelMsgListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &commonPb.DelMsgListResp{}
|
resp := &commonPb.DelMsgListResp{}
|
||||||
//if err := db.DB.DelMsgLogic(req.UserID, req.SeqList, req.OperationID); err != nil {
|
|
||||||
// log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
|
|
||||||
// resp.ErrMsg = constant.ErrDB.ErrMsg
|
|
||||||
// resp.ErrCode = constant.ErrDB.ErrCode
|
|
||||||
// return resp, nil
|
|
||||||
//}
|
|
||||||
|
|
||||||
if err := db.DB.DelMsgBySeqList(req.UserID, req.SeqList, req.OperationID); err != nil {
|
if err := db.DB.DelMsgBySeqList(req.UserID, req.SeqList, req.OperationID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
|
||||||
resp.ErrMsg = constant.ErrDB.ErrMsg
|
resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
@ -146,10 +146,10 @@ func (s *officeServer) DeleteTag(_ context.Context, req *pbOffice.DeleteTagReq)
|
|||||||
func (s *officeServer) SetTag(_ context.Context, req *pbOffice.SetTagReq) (resp *pbOffice.SetTagResp, err error) {
|
func (s *officeServer) SetTag(_ context.Context, req *pbOffice.SetTagReq) (resp *pbOffice.SetTagResp, err error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp = &pbOffice.SetTagResp{CommonResp: &pbOffice.CommonResp{}}
|
resp = &pbOffice.SetTagResp{CommonResp: &pbOffice.CommonResp{}}
|
||||||
IncreaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
|
increaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
|
||||||
reduceUserIDList := utils.RemoveRepeatedStringInList(req.ReduceUserIDList)
|
reduceUserIDList := utils.RemoveRepeatedStringInList(req.ReduceUserIDList)
|
||||||
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, IncreaseUserIDList, reduceUserIDList); err != nil {
|
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, increaseUserIDList, reduceUserIDList); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", increaseUserIDList, reduceUserIDList, err.Error())
|
||||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -174,13 +174,13 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
|
|||||||
for _, groupID := range req.GroupList {
|
for _, groupID := range req.GroupList {
|
||||||
userIDList, err := im_mysql_model.GetGroupMemberIDListByGroupID(groupID)
|
userIDList, err := im_mysql_model.GetGroupMemberIDListByGroupID(groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID failed", err.Error(), groupID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userIDList)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userIDList)
|
||||||
groupUserIDList = append(groupUserIDList, userIDList...)
|
groupUserIDList = append(groupUserIDList, userIDList...)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
|
||||||
var userIDList []string
|
var userIDList []string
|
||||||
userIDList = append(userIDList, tagUserIDList...)
|
userIDList = append(userIDList, tagUserIDList...)
|
||||||
userIDList = append(userIDList, groupUserIDList...)
|
userIDList = append(userIDList, groupUserIDList...)
|
||||||
@ -191,13 +191,13 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
|
|||||||
userIDList = append(userIDList[:i], userIDList[i+1:]...)
|
userIDList = append(userIDList[:i], userIDList[i+1:]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
|
||||||
us, err := imdb.GetUserByUserID(req.SendID)
|
user, err := imdb.GetUserByUserID(req.SendID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.SendID)
|
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.SendID)
|
||||||
}
|
}
|
||||||
for _, userID := range userIDList {
|
for _, userID := range userIDList {
|
||||||
msg.TagSendMessage(req.OperationID, us, userID, req.Content, req.SenderPlatformID)
|
msg.TagSendMessage(req.OperationID, user, userID, req.Content, req.SenderPlatformID)
|
||||||
}
|
}
|
||||||
var tagSendLogs db.TagSendLog
|
var tagSendLogs db.TagSendLog
|
||||||
for _, userID := range userIDList {
|
for _, userID := range userIDList {
|
||||||
@ -216,7 +216,7 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
|
|||||||
tagSendLogs.SenderPlatformID = req.SenderPlatformID
|
tagSendLogs.SenderPlatformID = req.SenderPlatformID
|
||||||
tagSendLogs.SendTime = time.Now().Unix()
|
tagSendLogs.SendTime = time.Now().Unix()
|
||||||
if err := db.DB.SaveTagSendLog(&tagSendLogs); err != nil {
|
if err := db.DB.SaveTagSendLog(&tagSendLogs); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", tagSendLogs, err.Error())
|
||||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
@ -88,13 +88,14 @@ func (s *statisticsServer) Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.GetActiveGroupReq) (*pbStatistics.GetActiveGroupResp, error) {
|
func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.GetActiveGroupReq) (*pbStatistics.GetActiveGroupResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
|
||||||
resp := &pbStatistics.GetActiveGroupResp{}
|
resp := &pbStatistics.GetActiveGroupResp{}
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
return resp, errors.WrapError(constant.ErrArgs)
|
||||||
}
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||||
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
||||||
@ -108,6 +109,7 @@ func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.G
|
|||||||
MessageNum: int32(activeGroup.MessageNum),
|
MessageNum: int32(activeGroup.MessageNum),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +121,7 @@ func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.Ge
|
|||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, errors.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||||
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
|
||||||
@ -133,6 +136,7 @@ func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.Ge
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +236,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
|
|||||||
}
|
}
|
||||||
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, errors.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
totalGroupNum, err := imdb.GetTotalGroupNum()
|
totalGroupNum, err := imdb.GetTotalGroupNum()
|
||||||
@ -243,7 +247,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
|
|||||||
resp.IncreaseGroupNum = increaseGroupNum
|
resp.IncreaseGroupNum = increaseGroupNum
|
||||||
resp.TotalGroupNum = totalGroupNum
|
resp.TotalGroupNum = totalGroupNum
|
||||||
times := GetRangeDate(fromTime, toTime)
|
times := GetRangeDate(fromTime, toTime)
|
||||||
log.NewInfo(req.OperationID, "times:", times)
|
log.NewDebug(req.OperationID, "times:", times)
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
resp.IncreaseGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
resp.IncreaseGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
||||||
resp.TotalGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
resp.TotalGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
||||||
@ -270,6 +274,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
|
|||||||
}(wg, i, v)
|
}(wg, i, v)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,6 +282,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
resp := &pbStatistics.GetMessageStatisticsResp{}
|
resp := &pbStatistics.GetMessageStatisticsResp{}
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
return resp, errors.WrapError(constant.ErrArgs)
|
||||||
@ -291,6 +297,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
|
|||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, errors.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
|
||||||
resp.PrivateMessageNum = privateMessageNum
|
resp.PrivateMessageNum = privateMessageNum
|
||||||
resp.GroupMessageNum = groupMessageNum
|
resp.GroupMessageNum = groupMessageNum
|
||||||
times := GetRangeDate(fromTime, toTime)
|
times := GetRangeDate(fromTime, toTime)
|
||||||
@ -325,7 +332,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistics.GetUserStatisticsReq) (*pbStatistics.GetUserStatisticsResp, error) {
|
func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistics.GetUserStatisticsReq) (*pbStatistics.GetUserStatisticsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbStatistics.GetUserStatisticsResp{}
|
resp := &pbStatistics.GetUserStatisticsResp{}
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -387,5 +394,6 @@ func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistic
|
|||||||
}(wg, i, v)
|
}(wg, i, v)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import (
|
|||||||
pbUser "Open_IM/pkg/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -170,6 +169,7 @@ func (s *userServer) GetAllConversations(ctx context.Context, req *pbUser.GetAll
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetAllConversationsResp{Conversations: []*pbUser.Conversation{}}
|
resp := &pbUser.GetAllConversationsResp{Conversations: []*pbUser.Conversation{}}
|
||||||
conversations, err := imdb.GetUserAllConversations(req.OwnerUserID)
|
conversations, err := imdb.GetUserAllConversations(req.OwnerUserID)
|
||||||
|
log.NewDebug(req.OperationID, "conversations: ", conversations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
@ -187,6 +187,7 @@ func (s *userServer) GetConversation(ctx context.Context, req *pbUser.GetConvers
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetConversationResp{Conversation: &pbUser.Conversation{}}
|
resp := &pbUser.GetConversationResp{Conversation: &pbUser.Conversation{}}
|
||||||
conversation, err := imdb.GetConversation(req.OwnerUserID, req.ConversationID)
|
conversation, err := imdb.GetConversation(req.OwnerUserID, req.ConversationID)
|
||||||
|
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
|
||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
@ -204,6 +205,7 @@ func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConver
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetConversationsResp{Conversations: []*pbUser.Conversation{}}
|
resp := &pbUser.GetConversationsResp{Conversations: []*pbUser.Conversation{}}
|
||||||
conversations, err := imdb.GetConversations(req.OwnerUserID, req.ConversationIDs)
|
conversations, err := imdb.GetConversations(req.OwnerUserID, req.ConversationIDs)
|
||||||
|
log.NewDebug("", utils.GetSelfFuncName(), "conversations", conversations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
@ -231,6 +233,7 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
if groupInfo.Status == constant.GroupStatusDismissed && !req.Conversation.IsNotInGroup {
|
if groupInfo.Status == constant.GroupStatusDismissed && !req.Conversation.IsNotInGroup {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "group status is dismissed", groupInfo)
|
||||||
errMsg := "group status is dismissed"
|
errMsg := "group status is dismissed"
|
||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -443,6 +446,7 @@ func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByN
|
|||||||
CurrentPage: req.Pagination.PageNumber,
|
CurrentPage: req.Pagination.PageNumber,
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
ShowNumber: req.Pagination.ShowNumber,
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,6 +470,7 @@ func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq
|
|||||||
CreateTime: user.CreateTime.String(),
|
CreateTime: user.CreateTime.String(),
|
||||||
IsBlock: isBlock,
|
IsBlock: isBlock,
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,6 +479,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
|||||||
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
|
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
|
||||||
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", err.Error())
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, errors.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
for _, v := range users {
|
for _, v := range users {
|
||||||
@ -487,16 +493,19 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
|||||||
IsBlock: isBlock,
|
IsBlock: isBlock,
|
||||||
}
|
}
|
||||||
resp.User = append(resp.User, user)
|
resp.User = append(resp.User, user)
|
||||||
|
} else {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UserIsBlock failed", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user := db.User{}
|
user := db.User{}
|
||||||
nums, err := imdb.GetUsersCount(user)
|
nums, err := imdb.GetUsersCount(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error(), user)
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, errors.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
resp.UserNums = nums
|
resp.UserNums = nums
|
||||||
resp.Pagination = &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}
|
resp.Pagination = &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +515,7 @@ func (s *userServer) ResignUser(ctx context.Context, req *pbUser.ResignUserReq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
|
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
|
||||||
log.NewInfo(req.OperationID, "AlterUser args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.AlterUserResp{}
|
resp := &pbUser.AlterUserResp{}
|
||||||
user := db.User{
|
user := db.User{
|
||||||
PhoneNumber: strconv.FormatInt(req.PhoneNumber, 10),
|
PhoneNumber: strconv.FormatInt(req.PhoneNumber, 10),
|
||||||
@ -519,11 +528,12 @@ func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*
|
|||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, errors.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
chat.UserInfoUpdatedNotification(req.OperationID, req.UserId, req.OpUserId)
|
chat.UserInfoUpdatedNotification(req.OperationID, req.UserId, req.OpUserId)
|
||||||
|
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, "AddUser args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.AddUserResp{}
|
resp := &pbUser.AddUserResp{}
|
||||||
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name)
|
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -534,8 +544,7 @@ func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUs
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, "BlockUser args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
fmt.Println("BlockUser args ", req.String())
|
|
||||||
resp := &pbUser.BlockUserResp{}
|
resp := &pbUser.BlockUserResp{}
|
||||||
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
|
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -546,7 +555,7 @@ func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, "UnBlockUser args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.UnBlockUserResp{}
|
resp := &pbUser.UnBlockUserResp{}
|
||||||
err := imdb.UnBlockUser(req.UserId)
|
err := imdb.UnBlockUser(req.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -557,7 +566,7 @@ func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
|
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
|
||||||
log.NewInfo(req.OperationID, "GetBlockUsers args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetBlockUsersResp{}
|
resp := &pbUser.GetBlockUsersResp{}
|
||||||
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -585,11 +594,12 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
|
|||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, errors.WrapError(constant.ErrDB)
|
||||||
}
|
}
|
||||||
resp.UserNums = nums
|
resp.UserNums = nums
|
||||||
|
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) {
|
func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUserByIdReq) (*pbUser.GetBlockUserByIdResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetBlockUserByIdResp{}
|
resp := &pbUser.GetBlockUserByIdResp{}
|
||||||
user, err := imdb.GetBlockUserById(req.UserId)
|
user, err := imdb.GetBlockUserById(req.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -606,6 +616,7 @@ func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUse
|
|||||||
BeginDisableTime: (user.BeginDisableTime).String(),
|
BeginDisableTime: (user.BeginDisableTime).String(),
|
||||||
EndDisableTime: (user.EndDisableTime).String(),
|
EndDisableTime: (user.EndDisableTime).String(),
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
|
import (
|
||||||
|
apiStruct "Open_IM/pkg/base_info"
|
||||||
|
"mime/multipart"
|
||||||
|
)
|
||||||
|
|
||||||
type AdminLoginRequest struct {
|
type AdminLoginRequest struct {
|
||||||
AdminName string `json:"admin_name" binding:"required"`
|
AdminName string `json:"admin_name" binding:"required"`
|
||||||
Secret string `json:"secret" binding:"required"`
|
Secret string `json:"secret" binding:"required"`
|
||||||
@ -8,3 +13,32 @@ type AdminLoginRequest struct {
|
|||||||
type AdminLoginResponse struct {
|
type AdminLoginResponse struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UploadUpdateAppReq struct {
|
||||||
|
OperationID string `form:"operationID" binding:"required"`
|
||||||
|
Type int `form:"type" binding:"required"`
|
||||||
|
Version string `form:"version" binding:"required"`
|
||||||
|
File multipart.FileHeader `form:"file" binding:"required"`
|
||||||
|
Yaml multipart.FileHeader `form:"yaml" binding:"required"`
|
||||||
|
ForceUpdate bool `form:"forceUpdate" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadUpdateAppResp struct {
|
||||||
|
apiStruct.CommResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetDownloadURLReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
Type int `json:"type" binding:"required"`
|
||||||
|
Version string `json:"version" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetDownloadURLResp struct {
|
||||||
|
apiStruct.CommResp
|
||||||
|
Data struct {
|
||||||
|
HasNewVersion bool `json:"hasNewVersion"`
|
||||||
|
ForceUpdate bool `json:"forceUpdate"`
|
||||||
|
FileURL string `json:"fileURL"`
|
||||||
|
YamlURL string `json:"yamlURL"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
@ -63,6 +63,7 @@ type config struct {
|
|||||||
}
|
}
|
||||||
Minio struct {
|
Minio struct {
|
||||||
Bucket string `yaml:"bucket"`
|
Bucket string `yaml:"bucket"`
|
||||||
|
AppBucket string `yaml:"appBucket"`
|
||||||
Location string `yaml:"location"`
|
Location string `yaml:"location"`
|
||||||
Endpoint string `yaml:"endpoint"`
|
Endpoint string `yaml:"endpoint"`
|
||||||
AccessKeyID string `yaml:"accessKeyID"`
|
AccessKeyID string `yaml:"accessKeyID"`
|
||||||
|
@ -272,3 +272,14 @@ type DepartmentMember struct {
|
|||||||
func (DepartmentMember) TableName() string {
|
func (DepartmentMember) TableName() string {
|
||||||
return "department_members"
|
return "department_members"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AppVersion struct {
|
||||||
|
Version string `gorm:"column:user_id;size:64"`
|
||||||
|
Type int `gorm:"column:user_id;primary_key"`
|
||||||
|
UpdateTime int `gorm:"column:update_time"`
|
||||||
|
ForceUpdate bool `gorm:"column:force_update"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (AppVersion) TableName() string {
|
||||||
|
return "app_version"
|
||||||
|
}
|
||||||
|
@ -119,7 +119,10 @@ func initMysqlDB() {
|
|||||||
fmt.Println("CreateTable DepartmentMember")
|
fmt.Println("CreateTable DepartmentMember")
|
||||||
db.CreateTable(&DepartmentMember{})
|
db.CreateTable(&DepartmentMember{})
|
||||||
}
|
}
|
||||||
|
if !db.HasTable(&AppVersion{}) {
|
||||||
|
fmt.Println("CreateTable DepartmentMember")
|
||||||
|
db.CreateTable(&AppVersion{})
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
pkg/common/db/mysql_model/im_mysql_model/file_model.go
Normal file
38
pkg/common/db/mysql_model/im_mysql_model/file_model.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package im_mysql_model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/db"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UpdateAppVersion(appType int, version string, forceUpdate bool) error {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
app := db.AppVersion{
|
||||||
|
Version: version,
|
||||||
|
Type: appType,
|
||||||
|
UpdateTime: int(time.Now().Unix()),
|
||||||
|
ForceUpdate: forceUpdate,
|
||||||
|
}
|
||||||
|
result := dbConn.Model(db.AppVersion{}).Where("app_type = ?", appType).Updates(&app)
|
||||||
|
if result.Error != nil {
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
|
if result.RowsAffected == 0 {
|
||||||
|
err := dbConn.Create(&app).Error
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetNewestVersion(appType int) (*db.AppVersion, error) {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dbConn.LogMode(true)
|
||||||
|
app := db.AppVersion{}
|
||||||
|
return &app, dbConn.Model(db.AppVersion{}).First(&app, appType).Error
|
||||||
|
}
|
@ -2,6 +2,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
@ -37,3 +38,33 @@ func GetNewFileNameAndContentType(fileName string, fileType int) (string, string
|
|||||||
}
|
}
|
||||||
return newName, contentType
|
return newName, contentType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUploadAppNewName(appType int, version string) (string, string, error) {
|
||||||
|
var newFileName, newYamlName = version + "_app_", version + "_yaml_"
|
||||||
|
switch appType {
|
||||||
|
case constant.IOSPlatformID:
|
||||||
|
newFileName += constant.IOSPlatformStr
|
||||||
|
newYamlName += constant.IOSPlatformStr
|
||||||
|
case constant.AndroidPlatformID:
|
||||||
|
newFileName += constant.AndroidPlatformStr
|
||||||
|
newYamlName += constant.AndroidPlatformStr
|
||||||
|
case constant.WindowsPlatformID:
|
||||||
|
newFileName += constant.WindowsPlatformStr
|
||||||
|
newYamlName += constant.WindowsPlatformStr
|
||||||
|
case constant.OSXPlatformID:
|
||||||
|
newFileName += constant.OSXPlatformStr
|
||||||
|
newYamlName += constant.OSXPlatformStr
|
||||||
|
case constant.WebPlatformID:
|
||||||
|
newFileName += constant.WebPlatformStr
|
||||||
|
newYamlName += constant.WebPlatformStr
|
||||||
|
case constant.MiniWebPlatformID:
|
||||||
|
newFileName += constant.MiniWebPlatformStr
|
||||||
|
newYamlName += constant.MiniWebPlatformStr
|
||||||
|
case constant.LinuxPlatformID:
|
||||||
|
newFileName += constant.LinuxPlatformStr
|
||||||
|
newYamlName += constant.LinuxPlatformStr
|
||||||
|
default:
|
||||||
|
return "", "", errors.New("invalid app type")
|
||||||
|
}
|
||||||
|
return newFileName, newYamlName, nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user