mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-29 06:49:19 +08:00
Compare commits
1 Commits
v2.3.0-rc0
..
v2.0.8
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cc4e30bae |
@@ -1,5 +1,4 @@
|
||||
# Open-IM-Server
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
+1
-1
Submodule cmd/Open-IM-SDK-Core updated: 3cf486771b...539290887a
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+19
-56
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "Open_IM/cmd/open_im_api/docs"
|
||||
apiAuth "Open_IM/internal/api/auth"
|
||||
apiChat "Open_IM/internal/api/chat"
|
||||
"Open_IM/internal/api/conversation"
|
||||
@@ -17,9 +16,6 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
//_ "github.com/razeencheng/demo-go/swaggo-gin/docs"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -29,38 +25,23 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
)
|
||||
|
||||
// @title open-IM-Server API
|
||||
// @version 1.0
|
||||
// @description open-IM-Server 的API服务器文档, 文档中所有请求都有一个operationID字段用于链路追踪
|
||||
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
// @BasePath /
|
||||
func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
f, _ := os.Create("../logs/api.log")
|
||||
gin.DefaultWriter = io.MultiWriter(f)
|
||||
gin.SetMode(gin.DebugMode)
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
|
||||
log.Info("load config: ", config.Config)
|
||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
log.Info("load config: ", config.Config)
|
||||
// user routing group, which handles user registration and login services
|
||||
userRouterGroup := r.Group("/user")
|
||||
{
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||
userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt)
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
|
||||
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
|
||||
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1
|
||||
userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache)
|
||||
userRouterGroup.POST("/get_user_friend_from_cache", user.GetFriendIDListFromCache)
|
||||
userRouterGroup.POST("/get_black_list_from_cache", user.GetBlackIDListFromCache)
|
||||
userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||
userRouterGroup.POST("/account_check", manage.AccountCheck) //1
|
||||
// userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||
}
|
||||
//friend routing group
|
||||
friendRouterGroup := r.Group("/friend")
|
||||
@@ -86,7 +67,7 @@ func main() {
|
||||
{
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
||||
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
||||
groupRouterGroup.POST("/join_group", group.JoinGroup) //1
|
||||
groupRouterGroup.POST("join_group", group.JoinGroup) //1
|
||||
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
||||
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
|
||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
||||
@@ -98,27 +79,21 @@ func main() {
|
||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList)
|
||||
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
||||
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
||||
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
|
||||
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
|
||||
groupRouterGroup.POST("/mute_group", group.MuteGroup)
|
||||
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
|
||||
|
||||
groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname)
|
||||
groupRouterGroup.POST("/set_group_member_info", group.SetGroupMemberInfo)
|
||||
}
|
||||
superGroupRouterGroup := r.Group("/super_group")
|
||||
{
|
||||
superGroupRouterGroup.POST("/get_joined_group_list", group.GetJoinedSuperGroupList)
|
||||
superGroupRouterGroup.POST("/get_groups_info", group.GetSuperGroupsInfo)
|
||||
|
||||
}
|
||||
//certificate
|
||||
authRouterGroup := r.Group("/auth")
|
||||
{
|
||||
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
|
||||
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
|
||||
authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //1
|
||||
authRouterGroup.POST("/force_logout", apiAuth.ForceLogout) //1
|
||||
}
|
||||
//Third service
|
||||
thirdGroup := r.Group("/third")
|
||||
@@ -127,10 +102,6 @@ func main() {
|
||||
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
|
||||
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
|
||||
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
|
||||
thirdGroup.POST("/upload_update_app", apiThird.UploadUpdateApp)
|
||||
thirdGroup.POST("/get_download_url", apiThird.GetDownloadURL)
|
||||
thirdGroup.POST("/get_rtc_invitation_info", apiThird.GetRTCInvitationInfo)
|
||||
thirdGroup.POST("/get_rtc_invitation_start_app", apiThird.GetRTCInvitationInfoStartApp)
|
||||
}
|
||||
//Message
|
||||
chatGroup := r.Group("/msg")
|
||||
@@ -139,16 +110,16 @@ func main() {
|
||||
chatGroup.POST("/send_msg", apiChat.SendMsg)
|
||||
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
|
||||
chatGroup.POST("/del_msg", apiChat.DelMsg)
|
||||
chatGroup.POST("/del_super_group_msg", apiChat.DelSuperGroupMsg)
|
||||
chatGroup.POST("/clear_msg", apiChat.ClearMsg)
|
||||
chatGroup.POST("/manage_send_msg", manage.ManagementSendMsg)
|
||||
chatGroup.POST("/batch_send_msg", manage.ManagementBatchSendMsg)
|
||||
}
|
||||
//Manager
|
||||
//managementGroup := r.Group("/manager")
|
||||
//{
|
||||
// managementGroup.POST("/delete_user", manage.DeleteUser) //1
|
||||
//}
|
||||
managementGroup := r.Group("/manager")
|
||||
{
|
||||
managementGroup.POST("/delete_user", manage.DeleteUser) //1
|
||||
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||
managementGroup.POST("/account_check", manage.AccountCheck) //1
|
||||
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||
}
|
||||
//Conversation
|
||||
conversationGroup := r.Group("/conversation")
|
||||
{ //1
|
||||
@@ -158,7 +129,6 @@ func main() {
|
||||
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
||||
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
|
||||
}
|
||||
// office
|
||||
officeGroup := r.Group("/office")
|
||||
@@ -179,7 +149,6 @@ func main() {
|
||||
officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments)
|
||||
officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments)
|
||||
officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel)
|
||||
officeGroup.POST("/delete_comment", office.DeleteComment)
|
||||
}
|
||||
|
||||
organizationGroup := r.Group("/organization")
|
||||
@@ -204,16 +173,10 @@ func main() {
|
||||
}
|
||||
|
||||
go apiThird.MinioInit()
|
||||
defaultPorts := config.Config.Api.GinPort
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10002 as port")
|
||||
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
||||
flag.Parse()
|
||||
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
|
||||
if config.Config.Api.ListenIP != "" {
|
||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
}
|
||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
fmt.Println("start api server, address: ", address)
|
||||
err := r.Run(address)
|
||||
fmt.Println("start api server, port: ", *ginPort)
|
||||
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||
if err != nil {
|
||||
log.Error("", "run failed ", *ginPort, err.Error())
|
||||
}
|
||||
|
||||
@@ -3,11 +3,8 @@ package main
|
||||
import (
|
||||
"Open_IM/internal/cms_api"
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"Open_IM/pkg/common/config"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -15,14 +12,6 @@ func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
router := cms_api.NewGinRouter()
|
||||
router.Use(utils.CorsHandler())
|
||||
defaultPorts := config.Config.CmsApi.GinPort
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10006 as port")
|
||||
flag.Parse()
|
||||
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
|
||||
if config.Config.Api.ListenIP != "" {
|
||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
}
|
||||
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
fmt.Println("start cms api server, address: ", address)
|
||||
router.Run(address)
|
||||
fmt.Println("start cms api server, port: ", 8000)
|
||||
router.Run(":" + "8000")
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -24,7 +23,7 @@ func main() {
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
|
||||
authRouterGroup := r.Group("/demo")
|
||||
authRouterGroup := r.Group("/auth")
|
||||
{
|
||||
authRouterGroup.POST("/code", register.SendVerificationCode)
|
||||
authRouterGroup.POST("/verify", register.Verify)
|
||||
@@ -32,25 +31,11 @@ func main() {
|
||||
authRouterGroup.POST("/login", register.Login)
|
||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
}
|
||||
demoRouterGroup := r.Group("/auth")
|
||||
{
|
||||
demoRouterGroup.POST("/code", register.SendVerificationCode)
|
||||
demoRouterGroup.POST("/verify", register.Verify)
|
||||
demoRouterGroup.POST("/password", register.SetPassword)
|
||||
demoRouterGroup.POST("/login", register.Login)
|
||||
demoRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
}
|
||||
defaultPorts := config.Config.Demo.Port
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 42233 as port")
|
||||
|
||||
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start demo api server, port: ", *ginPort)
|
||||
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
|
||||
if config.Config.Api.ListenIP != "" {
|
||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
}
|
||||
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
fmt.Println("start demo api server address: ", address)
|
||||
err := r.Run(address)
|
||||
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||
if err != nil {
|
||||
log.Error("", "run failed ", *ginPort, err.Error())
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/msg_gateway/gate"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"flag"
|
||||
@@ -12,10 +11,8 @@ import (
|
||||
|
||||
func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
defaultRpcPorts := config.Config.RpcPort.OpenImMessageGatewayPort
|
||||
defaultWsPorts := config.Config.LongConnSvr.WebsocketPort
|
||||
rpcPort := flag.Int("rpc_port", defaultRpcPorts[0], "rpc listening port")
|
||||
wsPort := flag.Int("ws_port", defaultWsPorts[0], "ws listening port")
|
||||
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
|
||||
wsPort := flag.Int("ws_port", 17778, "ws listening port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push/logic"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"flag"
|
||||
@@ -11,8 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImPushPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
rpcPort := flag.Int("port", 10700, "rpc listening port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_cache
|
||||
BIN_DIR=../../../bin/
|
||||
BINARY_NAME=open_im_timer_task
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
@@ -22,3 +22,4 @@ install:
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
//for {
|
||||
// fmt.Println("start delete mongodb expired record")
|
||||
// timeUnixBegin := time.Now().Unix()
|
||||
// count, _ := db.DB.MgoUserCount()
|
||||
// fmt.Println("mongodb record count: ", count)
|
||||
// for i := 0; i < count; i++ {
|
||||
// time.Sleep(1 * time.Millisecond)
|
||||
// uid, _ := db.DB.MgoSkipUID(i)
|
||||
// fmt.Println("operate uid: ", uid)
|
||||
// err := db.DB.DelUserChat(uid)
|
||||
// if err != nil {
|
||||
// fmt.Println("operate uid failed: ", uid, err.Error())
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// timeUnixEnd := time.Now().Unix()
|
||||
// costTime := timeUnixEnd - timeUnixBegin
|
||||
// if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) {
|
||||
// continue
|
||||
// } else {
|
||||
// sleepTime := 0
|
||||
// if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 {
|
||||
// sleepTime = 24 * 3600
|
||||
// } else {
|
||||
// sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime)
|
||||
// }
|
||||
// fmt.Println("sleep: ", sleepTime)
|
||||
// time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||
// }
|
||||
//}
|
||||
//for {
|
||||
// uidList, err := im_mysql_model.SelectAllUserID()
|
||||
// if err != nil {
|
||||
// //log.NewError("999999", err.Error())
|
||||
// } else {
|
||||
// for _, v := range uidList {
|
||||
// minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
|
||||
// if err != nil {
|
||||
// //log.NewError("999999", "get user minSeq err", err.Error(), v)
|
||||
// continue
|
||||
// } else {
|
||||
// err := commonDB.DB.SetUserMinSeq(v, minSeq)
|
||||
// if err != nil {
|
||||
// //log.NewError("999999", "set user minSeq err", err.Error(), v)
|
||||
// }
|
||||
// }
|
||||
// time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImAdminCmsPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
rpcPort := flag.Int("port", 11000, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start cms rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
|
||||
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
rpcAuth "Open_IM/internal/rpc/auth"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImAuthPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
||||
rpcPort := flag.Int("port", 10600, "RpcToken default listen port 10800")
|
||||
flag.Parse()
|
||||
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort)
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcCache "Open_IM/internal/rpc/cache"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImCachePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
||||
flag.Parse()
|
||||
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcCache.NewCacheServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_conversation
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcConversation "Open_IM/internal/rpc/conversation"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImConversationPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcConversation default listen port 11300")
|
||||
flag.Parse()
|
||||
fmt.Println("start conversation rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
||||
@@ -2,14 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImFriendPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcFriendPort from cmd,default 12000 as port")
|
||||
|
||||
rpcPort := flag.Int("port", 10200, "get RpcFriendPort from cmd,default 12000 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start friend rpc server, port: ", *rpcPort)
|
||||
rpcServer := friend.NewFriendServer(*rpcPort)
|
||||
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImGroupPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcGroupPort from cmd,default 16000 as port")
|
||||
rpcPort := flag.Int("port", 10500, "get RpcGroupPort from cmd,default 16000 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start group rpc server, port: ", *rpcPort)
|
||||
rpcServer := group.NewGroupServer(*rpcPort)
|
||||
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImMessageCmsPort[0]
|
||||
rpcPort := flag.Int("port", defaultPorts, "rpc listening port")
|
||||
rpcPort := flag.Int("port", 10900, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
||||
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
rpcChat "Open_IM/internal/rpc/msg"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImMessagePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
rpcPort := flag.Int("port", 10300, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start msg rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
|
||||
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
rpc "Open_IM/internal/rpc/office"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImOfficePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
rpcPort := flag.Int("port", 11100, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start office rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpc.NewOfficeServer(*rpcPort)
|
||||
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/organization"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImOrganizationPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcOrganizationPort from cmd,default 11200 as port")
|
||||
rpcPort := flag.Int("port", 11200, "get RpcOrganizationPort from cmd,default 11200 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start organization rpc server, port: ", *rpcPort)
|
||||
rpcServer := organization.NewServer(*rpcPort)
|
||||
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/statistics"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImStatisticsPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
rpcPort := flag.Int("port", 10800, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start statistics rpc server, port: ", *rpcPort)
|
||||
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
||||
|
||||
@@ -2,14 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/user"
|
||||
"Open_IM/pkg/common/config"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImUserPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
rpcPort := flag.Int("port", 10100, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start user rpc server, port: ", *rpcPort)
|
||||
rpcServer := user.NewUserServer(*rpcPort)
|
||||
|
||||
+41
-109
@@ -1,15 +1,12 @@
|
||||
# The class cannot be named by Pascal or camel case.
|
||||
# The class cannot be named by Pascal or camel case.
|
||||
# If it is not used, the corresponding structure will not be set,
|
||||
# and it will not be read naturally.
|
||||
serverversion: 2.0.0
|
||||
#---------------Infrastructure configuration---------------------#
|
||||
etcd:
|
||||
etcdSchema: openim #默认即可
|
||||
etcdSchema: openIM #默认即可
|
||||
etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可
|
||||
|
||||
k8sMod: false #开启k8s模式 使用pod里面环境变量请求services调用服务 而并非etcd
|
||||
|
||||
mysql:
|
||||
dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可
|
||||
dbMysqlUserName: root #mysql用户名,建议修改
|
||||
@@ -23,41 +20,32 @@ mysql:
|
||||
|
||||
mongo:
|
||||
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||
dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||
dbAddress: [ 127.0.0.1:37017 ] #mongo地址 目前仅支持单机,默认即可
|
||||
dbDirect: false
|
||||
dbTimeout: 60
|
||||
dbTimeout: 10
|
||||
dbDatabase: openIM #mongo db 默认即可
|
||||
dbSource: admin
|
||||
dbUserName: #mongo用户名,建议先不设置
|
||||
dbPassword: #mongo密码,建议先不设置
|
||||
dbMaxPoolSize: 100
|
||||
dbUserName: #mongo用户名,建议先不设置
|
||||
dbPassword: #mongo密码,建议先不设置
|
||||
dbMaxPoolSize: 20
|
||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||
|
||||
redis:
|
||||
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
|
||||
dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可
|
||||
dbMaxIdle: 128
|
||||
dbMaxActive: 0
|
||||
dbIdleTimeout: 120
|
||||
dbUserName: #only redis version 6.0+ need username
|
||||
dbPassWord: openIM #redis密码 建议修改
|
||||
enableCluster: false #如果外部redis以集群方式启动,需要打开此开关
|
||||
|
||||
kafka:
|
||||
ws2mschat:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ws2ms_chat"
|
||||
ws2mschatoffline:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ws2ms_chat_offline"
|
||||
msgtomongo:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "msg_to_mongo"
|
||||
ms2pschat:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ms2ps_chat"
|
||||
consumergroupid:
|
||||
msgToTransfer: mongo
|
||||
msgToMongo: mongo_ex
|
||||
msgToMongo: mongo
|
||||
msgToMySql: mysql
|
||||
msgToPush: push
|
||||
|
||||
@@ -71,11 +59,6 @@ kafka:
|
||||
#如果是单机模式,用0.0.0.0或者不填,默认即可
|
||||
serverip: 0.0.0.0
|
||||
|
||||
#作为rpc时,注册到etcd的地址,单机默认即可,如果是集群部署,需要修改(具体使用内网地址还是外网地址,要依情况而定,目的是api/gateway能访问到)
|
||||
rpcRegisterIP: 127.0.0.1
|
||||
#默认即可
|
||||
listenIP: 0.0.0.0
|
||||
|
||||
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
|
||||
endpoints:
|
||||
api: openim_api
|
||||
@@ -93,28 +76,24 @@ endpoints:
|
||||
rpc_office: openim_rpc_office
|
||||
|
||||
api:
|
||||
openImApiPort: [ 10002 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
listenIP: 0.0.0.0
|
||||
openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
cmsapi:
|
||||
openImCmsApiPort: [ 10006 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
listenIP: 0.0.0.0
|
||||
openImCmsApiPort: [ 8000 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
sdk:
|
||||
openImSdkWsPort: [ 10003 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||
dataDir: [ ../db/sdk/ ]
|
||||
openImSdkWsPort: [ 30000 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
||||
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
||||
tencent:
|
||||
appID: 1302656840
|
||||
region: ap-chengdu
|
||||
bucket: echat-1302656840
|
||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
|
||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
|
||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
||||
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
||||
bucket: openim # 存储内容桶
|
||||
appBucket: app # 存储app的桶
|
||||
bucket: openim
|
||||
location: us-east-1
|
||||
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的
|
||||
endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写
|
||||
endpoint: http://127.0.0.1:9000 #minio外网ip 这个ip是给客户端访问的
|
||||
endpointInner: http://127.0.0.1:9000 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写
|
||||
endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问
|
||||
accessKeyID: user12345
|
||||
secretAccessKey: key12345
|
||||
@@ -132,20 +111,18 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
||||
|
||||
|
||||
rpcport: #rpc服务端口 默认即可
|
||||
openImUserPort: [ 10110 ]
|
||||
openImFriendPort: [ 10120 ]
|
||||
openImMessagePort: [ 10130 ]
|
||||
openImMessageGatewayPort: [ 10140 ]
|
||||
openImGroupPort: [ 10150 ]
|
||||
openImAuthPort: [ 10160 ]
|
||||
openImPushPort: [ 10170 ]
|
||||
openImStatisticsPort: [ 10180 ]
|
||||
openImMessageCmsPort: [ 10190 ]
|
||||
openImAdminCmsPort: [ 10200 ]
|
||||
openImOfficePort: [ 10210 ]
|
||||
openImOrganizationPort: [ 10220 ]
|
||||
openImConversationPort: [ 10230 ]
|
||||
openImCachePort: [10240]
|
||||
openImUserPort: [ 10100 ]
|
||||
openImFriendPort: [ 10200 ]
|
||||
openImOfflineMessagePort: [ 10300 ]
|
||||
openImOnlineRelayPort: [ 10400 ]
|
||||
openImGroupPort: [ 10500 ]
|
||||
openImAuthPort: [ 10600 ]
|
||||
openImPushPort: [ 10700 ]
|
||||
openImStatisticsPort: [ 10800 ]
|
||||
openImMessageCmsPort: [ 10900 ]
|
||||
openImAdminCmsPort: [ 11000 ]
|
||||
openImOfficePort: [ 11100 ]
|
||||
openImOrganizationPort: [ 11200 ]
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
switch: false
|
||||
@@ -164,18 +141,16 @@ rpcregistername: #rpc注册服务名,默认即可
|
||||
openImOnlineMessageRelayName: OnlineMessageRelay
|
||||
openImGroupName: Group
|
||||
openImAuthName: Auth
|
||||
openImStatisticsName: Statistics
|
||||
openImMessageCMSName: MessageCMS
|
||||
OpenImStatisticsName: Statistics
|
||||
OpenImMessageCMSName: MessageCMS
|
||||
openImAdminCMSName: AdminCMS
|
||||
openImOfficeName: Office
|
||||
openImOrganizationName: Organization
|
||||
openImConversationName: Conversation
|
||||
openImCacheName: Cache
|
||||
openImRealTimeCommName: RealTimeComm
|
||||
|
||||
log:
|
||||
storageLocation: ../logs/
|
||||
rotationTime: 24
|
||||
remainRotationCount: 2 #日志数量
|
||||
remainRotationCount: 3 #日志数量
|
||||
#日志级别 6表示全都打印,测试阶段建议设置为6
|
||||
remainLogLevel: 6
|
||||
elasticSearchSwitch: false
|
||||
@@ -189,7 +164,7 @@ modulename: #日志文件按模块命名,默认即可
|
||||
pushName: push
|
||||
|
||||
longconnsvr:
|
||||
openImWsPort: [ 10001 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
|
||||
openImWsPort: [ 17778 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
|
||||
websocketMaxConnNum: 10000
|
||||
websocketMaxMsgLen: 4096
|
||||
websocketTimeOut: 10
|
||||
@@ -223,7 +198,6 @@ manager:
|
||||
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
||||
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
||||
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
|
||||
appSysNotificationName: "系统通知"
|
||||
|
||||
secret: tuoyun
|
||||
# 多端互踢策略
|
||||
@@ -231,15 +205,7 @@ secret: tuoyun
|
||||
multiloginpolicy: 1
|
||||
|
||||
#chat log insert to db
|
||||
chatpersistencemysql: true
|
||||
#可靠性存储
|
||||
reliablestorage: false
|
||||
#消息缓存时间
|
||||
msgCacheTimeout: 86400
|
||||
#群聊已读开启
|
||||
groupMessageHasReadReceiptEnable: true
|
||||
#单聊已读开启
|
||||
singleMessageHasReadReceiptEnable: true
|
||||
chatPersistenceMysql: true
|
||||
|
||||
#token config
|
||||
tokenpolicy:
|
||||
@@ -262,13 +228,12 @@ messageverify:
|
||||
iospush:
|
||||
pushSound: "xxx"
|
||||
badgeCount: true
|
||||
production: false
|
||||
|
||||
callback:
|
||||
# callback url 需要自行更换callback url
|
||||
callbackUrl : "http://127.0.0.1:8080/callback"
|
||||
# 开启关闭操作前后回调的配置
|
||||
callbackBeforeSendSingleMsg:
|
||||
callbackbeforeSendSingleMsg:
|
||||
enable: false # 回调是否启用
|
||||
callbackTimeOut: 2 # 回调超时时间
|
||||
callbackFailedContinue: true # 回调超时是否继续执行代码
|
||||
@@ -286,16 +251,7 @@ callback:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true
|
||||
callbackUserOnline:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackUserOffline:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackOfflinePush:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true # 回调超时是否继续离线推送
|
||||
|
||||
|
||||
notification:
|
||||
groupCreated:
|
||||
@@ -669,53 +625,29 @@ notification:
|
||||
openTips: "burn after reading was opened"
|
||||
closeTips: "burn after reading was closed"
|
||||
|
||||
###################organization################
|
||||
joinDepartmentNotification:
|
||||
conversation:
|
||||
reliabilityLevel: 3
|
||||
unreadCount: true
|
||||
offlinePush:
|
||||
switch: false
|
||||
title: "welcome user join department"
|
||||
desc: "welcome user join department"
|
||||
ext: "welcome user join department"
|
||||
defaultTips:
|
||||
tips: "welcome user join department"
|
||||
|
||||
#---------------demo configuration---------------------#
|
||||
#The following configuration items are applied to openIM Demo configuration
|
||||
#是否启动demo,如果自身没有账号体系,设置为true
|
||||
demoswitch: true
|
||||
demo:
|
||||
listenIP: 0.0.0.0
|
||||
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
openImDemoPort: [ 10004 ]
|
||||
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,enable为true则必须修改,阿里云为默认短信验证方式
|
||||
openImDemoPort: [ 42233 ]
|
||||
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,必须修改
|
||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
|
||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
|
||||
signName: 托云信息技术
|
||||
verificationCodeTemplateCode: SMS_226810164
|
||||
enable: false
|
||||
tencentsms: #腾讯云短信配置,在腾讯云申请成功后,修改以下选项,enable为true则必须修改
|
||||
appID: 2400000648
|
||||
region: "ap-singapore"
|
||||
secretID: IKIDra4JPGsFMDwQedMq42lESQBgwwgBQQAe
|
||||
secretKey: HI6fz4uUotjJdiX6QUIrAE2buxlKdgU2
|
||||
signName: ""
|
||||
verificationCodeTemplateCode: 2902877
|
||||
enable: true
|
||||
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
|
||||
# second
|
||||
codeTTL: 60
|
||||
useSuperCode: true
|
||||
codeTTL: 300
|
||||
mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改
|
||||
title: "openIM"
|
||||
senderMail: "765567899@qq.com"
|
||||
senderAuthorizationCode: "gxyausfoevlzbfag"
|
||||
smtpAddr: "smtp.qq.com"
|
||||
smtpPort: 25 #需开放此端口 出口方向
|
||||
testDepartMentID: 001
|
||||
imAPIURL: http://127.0.0.1:10002
|
||||
|
||||
rtc:
|
||||
signalTimeout: 35
|
||||
port: 11300
|
||||
address: 127.0.0.1
|
||||
@@ -6,7 +6,6 @@ ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_api $WORKDIR/main
|
||||
COPY ./start_api.sh $$WORKDIR
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
||||
@@ -14,4 +13,4 @@ RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
||||
|
||||
|
||||
WORKDIR $WORKDIR
|
||||
CMD ./start_api.sh
|
||||
CMD ./main
|
||||
@@ -1,20 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_admin_cms $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config", "/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: admin-cms-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: admin-cms # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: admin-cms # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-cms
|
||||
image: openim/admin_cms:v2.1.0
|
||||
# imagePullPolicy: Always #每次启动都重新拉取镜像
|
||||
ports:
|
||||
- containerPort: 10200
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_api $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,45 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: api-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: api # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: api # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: api
|
||||
image: openim/api:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10002
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: api
|
||||
spec:
|
||||
ports:
|
||||
- name: api-port
|
||||
protocol: TCP
|
||||
port: 10002
|
||||
targetPort: 10002
|
||||
selector:
|
||||
app: api
|
||||
type: NodePort
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_auth $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: auth-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: auth # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: auth # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: auth
|
||||
image: openim/auth:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10160
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,30 +0,0 @@
|
||||
#/bin/sh
|
||||
source ./path_info.cfg
|
||||
|
||||
# images version
|
||||
version=v2.1.0
|
||||
git pull
|
||||
cd ../script/; ./build_all_service.sh
|
||||
cd ../deploy_k8s/
|
||||
|
||||
for i in ${service[*]}
|
||||
do
|
||||
mv ../bin/open_im_${i} ./${i}/
|
||||
done
|
||||
|
||||
echo "move success"
|
||||
|
||||
echo "start to build images"
|
||||
|
||||
for i in ${service[*]}
|
||||
do
|
||||
echo "start to build images" $i
|
||||
cd $i
|
||||
image="openim/${i}:$version"
|
||||
docker build -t $image . -f ./${i}.Dockerfile
|
||||
echo "build ${dockerfile} success"
|
||||
docker push $image
|
||||
echo "push ${image} success "
|
||||
cd ..
|
||||
done
|
||||
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_cache $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: cache-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cache # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: cache # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: cache
|
||||
image: openim/cache:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10240
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,18 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_cms_api $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,45 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: cms-api-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cms-api # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: cms-api # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: cms-api
|
||||
image: openim/cms_api:v2.1.0
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10006
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: cms-api
|
||||
spec:
|
||||
ports:
|
||||
- name: cms-api-port
|
||||
protocol: TCP
|
||||
port: 10006
|
||||
targetPort: 10006
|
||||
selector:
|
||||
app: cms-api
|
||||
type: NodePort
|
||||
@@ -1,18 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_conversation $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: conversation-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: conversation # 选择这个指定标签执行
|
||||
replicas: 2 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: conversation # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: conversation
|
||||
image: openim/conversation:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10230
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_demo $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,45 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: demo-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: demo # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: demo # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: demo
|
||||
image: openim/demo:v2.1.0
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10004
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: demo
|
||||
spec:
|
||||
ports:
|
||||
- name: demo
|
||||
protocol: TCP
|
||||
port: 10004
|
||||
targetPort: 10004
|
||||
selector:
|
||||
app: demo
|
||||
type: NodePort
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: friend-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: friend # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: friend # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: friend
|
||||
image: openim/friend:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10120
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_friend $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: group-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: group # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: group # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: group
|
||||
image: openim/group:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10150
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_group $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,101 +0,0 @@
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "nginx"
|
||||
nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
|
||||
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
|
||||
name: sdk-server-ingress
|
||||
spec:
|
||||
rules:
|
||||
- host: sdk-server.openim.xxx.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: sdk-server
|
||||
port:
|
||||
number: 10003
|
||||
path: /
|
||||
pathType: Prefix
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "nginx"
|
||||
nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
|
||||
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
|
||||
name: msg-gateway-ingress
|
||||
spec:
|
||||
rules:
|
||||
- host: msg-gateway.openim.xxx.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: msg-gateway
|
||||
port:
|
||||
number: 10001
|
||||
path: /
|
||||
pathType: Prefix
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "nginx"
|
||||
name: api-ingress
|
||||
spec:
|
||||
rules:
|
||||
- host: api.openim.xxx.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: api
|
||||
port:
|
||||
number: 10002
|
||||
path: /
|
||||
pathType: Prefix
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "nginx"
|
||||
name: demo-ingress
|
||||
spec:
|
||||
rules:
|
||||
- host: demo.openim.xxx.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: demo
|
||||
port:
|
||||
number: 10004
|
||||
path: /
|
||||
pathType: Prefix
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "nginx"
|
||||
name: cms-api-ingress
|
||||
spec:
|
||||
rules:
|
||||
- host: cms-api.openim.xxx.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: cms-api
|
||||
port:
|
||||
number: 10006
|
||||
path: /
|
||||
pathType: Prefix
|
||||
@@ -1,99 +0,0 @@
|
||||
#### openIM k8s部署文档
|
||||
### 1. 修改配置文件
|
||||
在Open-IM-SERVER根目录下修改config/config.yaml配置文件, 请确保以下修改的所有地址必须保证k8s pod能够访问
|
||||
1. 修改ETCD配置为自己的ETCD ip地址, 最好和k8s本身使用的ETCD分开
|
||||
2. 修改MySQL配置
|
||||
3. 修改Mongo配置
|
||||
4. 修改Redis配置
|
||||
5. 修改Kafka配置
|
||||
6. 将rpcRegisterIP修改为空, 此地址为每个rpc注册到ETCD的地址, 置空每个rpc将会将pod地址注册到ETCD, 才能正确rpc请求(重要)
|
||||
7. 如果使用minio作为对象存储, 还需要修改minio的地址
|
||||
8. 其他如果使用离线推送,需要修改push离线推送配置
|
||||
9. 修改demo中的imAPIURL字段为openIM api的ingress或者service地址, 需要让demo的pod能正确请求到(重要)
|
||||
10. 其他非必须配置修改, 如短信,推送等
|
||||
|
||||
### 2. 项目根目录创建im configMap到k8s openim namespace
|
||||
1. 为open-IM项目创建单独命名空间
|
||||
```
|
||||
kubectl create namespace openim
|
||||
```
|
||||
2. 在项目根目录通过config/config.yaml
|
||||
```
|
||||
kubectl -n openim create configmap config --from-file=config/config.yaml
|
||||
```
|
||||
查看configmap
|
||||
```
|
||||
kubectl -n openim get configmap
|
||||
```
|
||||
|
||||
### 3(可选). 修改每个deployment.yml
|
||||
每个rpc的deployment在Open-IM-SERVER根目录deploy_k8s下
|
||||
给需要调度的node打上标签
|
||||
```
|
||||
kubectl get nodes
|
||||
kubectl label node k8s-node1 role=openIMworker
|
||||
```
|
||||
在deployment的spec.template.spec加上
|
||||
```
|
||||
nodeSelector:
|
||||
role: openIMworker
|
||||
```
|
||||
创建资源清单时添加上nodeSelector属性对应即可,
|
||||
修改每种服务数量,建议至少每种2个rpc。
|
||||
如果修改了config/config.yaml某些配置比如端口,同时需要修改对应deployment端口和ingress端口
|
||||
|
||||
|
||||
### 4. 修改ingress.yaml配置文件
|
||||
1. 需要安装ingress controller, 这里使用的是ingress-nginx, 使用其他类型的ingress controller需要更改ingress.class, 将host改为自己部署服务的host
|
||||
|
||||
### 5. 执行./kubectl_start.sh脚本
|
||||
1. 脚本给予可执行权限
|
||||
```
|
||||
chmod +x ./kubectl_start.sh ./kubectl_stop.sh
|
||||
```
|
||||
2. 启动k8s service和deployment
|
||||
```
|
||||
./kubectl_start.sh
|
||||
```
|
||||
3. 启动k8s ingress
|
||||
```
|
||||
kubectl -n openim apply -f ingress.yaml
|
||||
```
|
||||
kubectl 启动所有deployment, services, ingress
|
||||
|
||||
### 6. 查看k8s deployment service ingress状态
|
||||
|
||||
```
|
||||
kubectl -n openim get services
|
||||
kubectl -n openim get deployment
|
||||
kubectl -n openim get ingress
|
||||
kubectl -n openim get pods
|
||||
```
|
||||
检测服务可达
|
||||
```
|
||||
telnet msg-gateway.openim.xxx.com {{your_ingress_port}}
|
||||
telnet sdk-server.openim.xxx.com {{your_ingress_port}}
|
||||
telnet api.openim.xxx.com {{your_ingress_port}}
|
||||
telnet cms-api.openim.xxx.com {{your_ingress_port}}
|
||||
telnet demo.openim.xxx.com {{your_ingress_port}}
|
||||
```
|
||||
|
||||
#### openIM k8s更新
|
||||
1. 暂存配置文件,拉取代码
|
||||
```
|
||||
git stash push config/config.yaml
|
||||
git pull
|
||||
```
|
||||
2. 合并配置文件, 解决冲突
|
||||
```
|
||||
git stash pop
|
||||
```
|
||||
3. 重新生成configmap
|
||||
```
|
||||
kubectl -n openim create configmap config --from-file=config/config.yaml
|
||||
```
|
||||
4.修改所有deployment文件的spec.template.spec.image 改为新版本后在/deploy_k8s下重新执行
|
||||
```
|
||||
./kubectl_stop.sh
|
||||
./kubectl_start.sh
|
||||
```
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./path_info.cfg
|
||||
|
||||
#mkdir -p /db/sdk #path for jssdk sqlite
|
||||
|
||||
for i in ${service[*]}
|
||||
do
|
||||
kubectl -n openim apply -f ./${i}/deployment.yaml
|
||||
done
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
service=(
|
||||
#api service file
|
||||
api
|
||||
cms-api
|
||||
#rpc service file
|
||||
user
|
||||
friend
|
||||
group
|
||||
auth
|
||||
admin-cms
|
||||
message-cms
|
||||
statistics
|
||||
office
|
||||
organization
|
||||
conversation
|
||||
cache
|
||||
msg-gateway
|
||||
msg-transfer
|
||||
msg
|
||||
push
|
||||
sdk-server
|
||||
demo
|
||||
)
|
||||
|
||||
for i in ${service[*]}
|
||||
do
|
||||
kubectl -n openim delete deployment "${i}-deployment"
|
||||
done
|
||||
|
||||
kubectl -n openim delete service api
|
||||
kubectl -n openim delete service cms-api
|
||||
kubectl -n openim delete service sdk-server
|
||||
kubectl -n openim delete service msg-gateway
|
||||
kubectl -n openim delete service demo
|
||||
|
||||
echo done
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: message-cms-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: message-cms # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: message-cms # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: message-cms
|
||||
image: openim/message_cms:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10190
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_message_cms $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: msg-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: msg
|
||||
image: openim/msg:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10130
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,20 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_msg $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,50 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: msg-gateway-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg-gateway # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg-gateway # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: msg-gateway
|
||||
image: openim/msg_gateway:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- name: rpc-port
|
||||
containerPort: 10140
|
||||
- name: ws-port
|
||||
containerPort: 10001
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: msg-gateway
|
||||
spec:
|
||||
ports:
|
||||
- name: msg-gateway-port
|
||||
protocol: TCP
|
||||
port: 10001
|
||||
targetPort: ws-port
|
||||
selector:
|
||||
app: msg-gateway
|
||||
type: NodePort
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_msg_gateway $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,29 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: msg-transfer-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg-transfer # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg-transfer # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: msg-transfer
|
||||
image: openim/msg_transfer:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_msg_transfer $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: office-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: office # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: office # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: office
|
||||
image: openim/office:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10210
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,20 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_office $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: organization-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: organization # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: organization # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: organization
|
||||
image: openim/organization:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10220
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,20 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_organization $WORKDIR/cmd/main
|
||||
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,24 +0,0 @@
|
||||
#/bin/sh
|
||||
service=(
|
||||
#api service file
|
||||
api
|
||||
cms_api
|
||||
#rpc service file
|
||||
user
|
||||
friend
|
||||
group
|
||||
auth
|
||||
admin_cms
|
||||
message_cms
|
||||
statistics
|
||||
office
|
||||
organization
|
||||
conversation
|
||||
cache
|
||||
msg_gateway
|
||||
msg_transfer
|
||||
msg
|
||||
push
|
||||
sdk_server
|
||||
demo
|
||||
)
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: push-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: push # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: push # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: push
|
||||
image: openim/push:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10170
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,20 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_push $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,54 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: sdk-server-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: sdk-server # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: sdk-server # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: sdk-server
|
||||
image: openim/sdk_server:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10003
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
- name: local-db
|
||||
mountPath: /db/sdk
|
||||
command: ["/Open-IM-Server/main"]
|
||||
args: ["-openIM_api_port", "10002", "-openIM_ws_port", "10001", "-sdk_ws_port", "10003", "-openIM_log_level", "6"]
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
- name: local-db
|
||||
hostPath:
|
||||
path: /db/sdk
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: sdk-server
|
||||
spec:
|
||||
ports:
|
||||
- name: sdk-server-port
|
||||
protocol: TCP
|
||||
port: 10003
|
||||
targetPort: 10003
|
||||
selector:
|
||||
app: sdk-server
|
||||
type: NodePort
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_sdk_server $WORKDIR/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
||||
chmod +x $WORKDIR/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: statistics-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: statistics # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: statistics # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: statistics
|
||||
image: openim/statistics:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10180
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_statistics $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,29 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: user-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: user # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: user # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: user
|
||||
image: openim/user:v2.1.0
|
||||
# imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_user $WORKDIR/cmd/main
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
||||
chmod +x $WORKDIR/cmd/main
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
||||
|
||||
|
||||
WORKDIR $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,139 +0,0 @@
|
||||
version: "3"
|
||||
#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/OpenIMSDK/Open-IM-Server.git
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- 13306:3306
|
||||
- 23306:33060
|
||||
container_name: mysql
|
||||
volumes:
|
||||
- ./components/mysql/data:/var/lib/mysql
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: openIM
|
||||
restart: always
|
||||
|
||||
mongos:
|
||||
image: mongo:latest
|
||||
ports:
|
||||
- 37017:27017
|
||||
container_name: mongos
|
||||
command: mongos --configdb config/103.116.45.174:27019 --bind_ip_all
|
||||
volumes:
|
||||
- ./components/mongos_mongodb/data/db:/data/db
|
||||
- ./components/mongos_mongodb/data/logs:/data/logs
|
||||
- ./components/mongos_mongodb/data/conf:/etc/mongo
|
||||
- ./components/mongos_mongodb/data/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# environment:
|
||||
# - MONGO_INITDB_ROOT_USERNAME=openIM
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||
|
||||
|
||||
#TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 16379:6379
|
||||
container_name: redis
|
||||
volumes:
|
||||
- ./components/redis/data:/data
|
||||
#redis config file
|
||||
- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
sysctls:
|
||||
net.core.somaxconn: 1024
|
||||
command: redis-server --requirepass openIM --appendonly yes
|
||||
|
||||
|
||||
zookeeper:
|
||||
image: wurstmeister/zookeeper
|
||||
ports:
|
||||
- 2181:2181
|
||||
container_name: zookeeper
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
|
||||
kafka:
|
||||
image: wurstmeister/kafka
|
||||
container_name: kafka
|
||||
restart: always
|
||||
ports:
|
||||
- 9092:9092
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
KAFKA_BROKER_ID: 0
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_CREATE_TOPICS: "ws2ms_chat:8:1,ms2ps_chat:8:1,msg_to_mongo:8:1"
|
||||
KAFKA_ADVERTISED_LISTENERS: INSIDE://127.0.0.1:9092,OUTSIDE://103.116.45.174:9092
|
||||
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9093
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
|
||||
depends_on:
|
||||
- zookeeper
|
||||
|
||||
etcd:
|
||||
image: quay.io/coreos/etcd
|
||||
ports:
|
||||
- 2379:2379
|
||||
- 2380:2380
|
||||
container_name: etcd
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
ETCDCTL_API: 3
|
||||
restart: always
|
||||
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
||||
|
||||
minio:
|
||||
image: minio/minio
|
||||
ports:
|
||||
- 10005:9000
|
||||
- 9090:9090
|
||||
container_name: minio
|
||||
volumes:
|
||||
- /mnt/data:/data
|
||||
- /mnt/config:/root/.minio
|
||||
environment:
|
||||
MINIO_ROOT_USER: user12345
|
||||
MINIO_ROOT_PASSWORD: key12345
|
||||
restart: always
|
||||
command: minio server /data --console-address ':9090'
|
||||
|
||||
open_im_server:
|
||||
image: openim/open_im_server:v2.2.0
|
||||
container_name: open_im_server
|
||||
volumes:
|
||||
- ./logs:/Open-IM-Server/logs
|
||||
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./db/sdk:/Open-IM-Server/db/sdk
|
||||
- ./script:/Open-IM-Server/script
|
||||
restart: always
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongos
|
||||
- redis
|
||||
- etcd
|
||||
- minio
|
||||
network_mode: "host"
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "1g"
|
||||
max-file: "2"
|
||||
@@ -1,113 +0,0 @@
|
||||
version: '3'
|
||||
networks:
|
||||
mongo-network:
|
||||
external: false
|
||||
services:
|
||||
# 配置服务器configsvr
|
||||
config:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: config
|
||||
restart: always
|
||||
ports:
|
||||
- 27019:27019
|
||||
command: --configsvr --replSet "config" --bind_ip_all
|
||||
volumes:
|
||||
- ./components/config_mongodb/data/db:/data/db
|
||||
- ./components/config_mongodb/data/logs:/data/logs
|
||||
- ./components/config_mongodb/data/conf:/etc/mongo
|
||||
- ./components/config_mongodb/data/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
|
||||
# shard分片1
|
||||
shard1:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard1
|
||||
restart: always
|
||||
ports:
|
||||
- 27118:27018
|
||||
command: --shardsvr --replSet "shard1" --bind_ip_all
|
||||
volumes:
|
||||
- /data01/mongo/shard1/db:/data/db
|
||||
- /data01/mongo/shard1/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
|
||||
# shard分片2
|
||||
shard2:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard2
|
||||
restart: always
|
||||
ports:
|
||||
- 27218:27018
|
||||
command: --shardsvr --replSet "shard2" --bind_ip_all
|
||||
volumes:
|
||||
- /data02/mongo/shard2/db:/data/db
|
||||
- /data02/mongo/shard2/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# - ${PWD}/key.file:/data/mongodb/key.file
|
||||
|
||||
# shard分片3
|
||||
shard3:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard3
|
||||
restart: always
|
||||
ports:
|
||||
- 27318:27018
|
||||
command: --shardsvr --replSet "shard3" --bind_ip_all
|
||||
volumes:
|
||||
- /data03/mongo/shard3/db:/data/db
|
||||
- /data03/mongo/shard3/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# shard分片4
|
||||
shard4:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard4
|
||||
restart: always
|
||||
ports:
|
||||
- 27418:27018
|
||||
command: --shardsvr --replSet "shard4" --bind_ip_all
|
||||
volumes:
|
||||
- /data04/mongo/shard4/db:/data/db
|
||||
- /data04/mongo/shard4/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# shard分片5
|
||||
shard5:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard5
|
||||
restart: always
|
||||
ports:
|
||||
- 27518:27018
|
||||
command: --shardsvr --replSet "shard5" --bind_ip_all
|
||||
volumes:
|
||||
- /data05/mongo/shard5/db:/data/db
|
||||
- /data05/mongo/shard5/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
+12
-33
@@ -20,21 +20,20 @@ services:
|
||||
ports:
|
||||
- 37017:27017
|
||||
container_name: mongo
|
||||
command: --wiredTigerCacheSizeGB 1
|
||||
volumes:
|
||||
- ./components/mongodb/data/db:/data/db
|
||||
- ./components/mongodb/data/logs:/data/logs
|
||||
- ./components/mongodb/data/conf:/etc/mongo
|
||||
# - ./script/mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# - MONGO_USERNAME=openIM
|
||||
# - MONGO_PASSWORD=openIM
|
||||
# - MONGO_INITDB_ROOT_USERNAME=root
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=root
|
||||
# - MONGO_INITDB_DATABASE=openIM
|
||||
# environment:
|
||||
# - MONGO_INITDB_ROOT_USERNAME=openIM
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||
|
||||
|
||||
#TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
redis:
|
||||
@@ -45,7 +44,7 @@ services:
|
||||
volumes:
|
||||
- ./components/redis/data:/data
|
||||
#redis config file
|
||||
- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
|
||||
#- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
@@ -70,17 +69,13 @@ services:
|
||||
image: wurstmeister/kafka
|
||||
container_name: kafka
|
||||
restart: always
|
||||
ports:
|
||||
- 9092:9092
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
KAFKA_BROKER_ID: 0
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_CREATE_TOPICS: "ws2ms_chat:8:1,ms2ps_chat:8:1,msg_to_mongo:8:1"
|
||||
KAFKA_ADVERTISED_LISTENERS: INSIDE://127.0.0.1:9092,OUTSIDE://103.116.45.174:9092
|
||||
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9093
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
|
||||
KAFKA_ZOOKEEPER_CONNECT: 127.0.0.1:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
|
||||
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
|
||||
network_mode: "host"
|
||||
depends_on:
|
||||
- zookeeper
|
||||
|
||||
@@ -98,23 +93,8 @@ services:
|
||||
restart: always
|
||||
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
||||
|
||||
minio:
|
||||
image: minio/minio
|
||||
ports:
|
||||
- 10005:9000
|
||||
- 9090:9090
|
||||
container_name: minio
|
||||
volumes:
|
||||
- /mnt/data:/data
|
||||
- /mnt/config:/root/.minio
|
||||
environment:
|
||||
MINIO_ROOT_USER: user12345
|
||||
MINIO_ROOT_PASSWORD: key12345
|
||||
restart: always
|
||||
command: minio server /data --console-address ':9090'
|
||||
|
||||
open_im_server:
|
||||
image: openim/open_im_server:v2.3.0-rc0
|
||||
image: openim/open_im_server:v2.0.8
|
||||
container_name: open_im_server
|
||||
volumes:
|
||||
- ./logs:/Open-IM-Server/logs
|
||||
@@ -128,7 +108,6 @@ services:
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
- minio
|
||||
network_mode: "host"
|
||||
logging:
|
||||
driver: json-file
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 208 KiB |
@@ -3,23 +3,29 @@ module Open_IM
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/Shopify/sarama v1.32.0
|
||||
github.com/Shopify/sarama v1.19.0
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
|
||||
github.com/alibabacloud-go/darabonba-openapi v0.1.11
|
||||
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8
|
||||
github.com/alibabacloud-go/sts-20150401 v1.1.0
|
||||
github.com/alibabacloud-go/tea v1.1.17
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
||||
github.com/bwmarrin/snowflake v0.3.0
|
||||
github.com/coreos/etcd v3.3.27+incompatible // indirect
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
|
||||
github.com/eapache/go-resiliency v1.2.0 // indirect
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
|
||||
github.com/eapache/queue v1.1.0 // indirect
|
||||
github.com/fatih/structs v1.1.0
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/go-openapi/spec v0.20.6 // indirect
|
||||
github.com/go-openapi/swag v0.21.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.11.0
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/frankban/quicktest v1.14.0 // indirect
|
||||
github.com/garyburd/redigo v1.6.2
|
||||
github.com/gin-gonic/gin v1.7.0
|
||||
github.com/go-playground/validator/v10 v10.4.1
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/jinzhu/copier v0.3.4
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
@@ -28,38 +34,36 @@ require (
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
|
||||
github.com/lestrrat-go/strftime v1.0.4 // indirect
|
||||
github.com/lib/pq v1.2.0 // indirect
|
||||
//github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231 // indirect
|
||||
//github.com/livekit/server-sdk-go v0.9.1
|
||||
github.com/mattn/go-sqlite3 v1.14.6 // indirect
|
||||
github.com/minio/minio-go/v7 v7.0.22
|
||||
github.com/mitchellh/mapstructure v1.4.2
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/olivere/elastic/v7 v7.0.23
|
||||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/stretchr/testify v1.7.2
|
||||
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe
|
||||
github.com/swaggo/gin-swagger v1.5.0
|
||||
github.com/swaggo/swag v1.8.3
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.428
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.428
|
||||
github.com/spf13/viper v1.9.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
|
||||
go.etcd.io/etcd/api/v3 v3.5.4
|
||||
go.etcd.io/etcd/client/v3 v3.5.4
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
|
||||
//go.etcd.io/etcd v3.3.27+incompatible
|
||||
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
|
||||
go.mongodb.org/mongo-driver v1.8.3
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305
|
||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 // indirect
|
||||
golang.org/x/tools v0.1.11 // indirect
|
||||
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 // indirect
|
||||
google.golang.org/grpc v1.45.0
|
||||
google.golang.org/protobuf v1.28.0
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
|
||||
google.golang.org/grpc v1.42.0
|
||||
google.golang.org/grpc/examples v0.0.0-20220311002955-722367c4a737 // indirect
|
||||
google.golang.org/protobuf v1.27.1
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
sigs.k8s.io/yaml v1.2.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/Shopify/sarama => github.com/Shopify/sarama v1.29.0
|
||||
replace google.golang.org/grpc => google.golang.org/grpc v1.29.0
|
||||
|
||||
+16
-153
@@ -4,36 +4,21 @@ import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/auth"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/fatih/structs"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 用户注册
|
||||
// @Description 用户注册
|
||||
// @Tags 鉴权认证
|
||||
// @ID UserRegister
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UserRegisterReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID <br> ex为拓展字段 <br> gender为性别, 0为女, 1为男"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UserRegisterResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /auth/user_register [post]
|
||||
func UserRegister(c *gin.Context) {
|
||||
params := api.UserRegisterReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -48,34 +33,26 @@ func UserRegister(c *gin.Context) {
|
||||
//copier.Copy(req.UserInfo, ¶ms)
|
||||
req.OperationID = params.OperationID
|
||||
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.UserRegister(context.Background(), req)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "UserRegister failed " + err.Error() + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "call rpc err ", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "internal service err"})
|
||||
return
|
||||
}
|
||||
if reply.CommonResp.ErrCode != 0 {
|
||||
errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "UserRegister failed ", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg})
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "UserToken failed ", err.Error(), pbDataToken)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp := api.UserRegisterResp{CommResp: api.CommResp{ErrCode: replyToken.CommonResp.ErrCode, ErrMsg: replyToken.CommonResp.ErrMsg},
|
||||
@@ -85,48 +62,27 @@ func UserRegister(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
// @Summary 用户登录
|
||||
// @Description 获取用户的token
|
||||
// @Tags 鉴权认证
|
||||
// @ID UserToken
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UserTokenReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UserTokenResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /auth/user_token [post]
|
||||
func UserToken(c *gin.Context) {
|
||||
params := api.UserTokenReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if params.Secret != config.Config.Secret {
|
||||
errMsg := params.OperationID + " params.Secret != config.Config.Secret "
|
||||
log.NewError(params.OperationID, "params.Secret != config.Config.Secret", params.Secret, config.Config.Secret)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": errMsg})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||
return
|
||||
}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
log.NewInfo(req.OperationID, "UserToken args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.UserToken(context.Background(), req)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " UserToken failed " + err.Error() + " req: " + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "UserToken failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
||||
@@ -134,96 +90,3 @@ func UserToken(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, "UserToken return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 解析当前用户token
|
||||
// @Description 解析当前用户token(token在请求头中传入)
|
||||
// @Tags 鉴权认证
|
||||
// @ID ParseToken
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.ParseTokenReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段<br>platform为平台ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ParseTokenResp{Data=api.ExpireTime}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /auth/parse_token [post]
|
||||
func ParseToken(c *gin.Context) {
|
||||
params := api.ParseTokenReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var expireTime int64
|
||||
ok, _, errInfo, expireTime = token_verify.GetUserIDFromTokenExpireTime(c.Request.Header.Get("token"), params.OperationID)
|
||||
if !ok {
|
||||
errMsg := params.OperationID + " " + "GetUserIDFromTokenExpireTime failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.ParseTokenResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, ExpireTime: api.ExpireTime{ExpireTimeSeconds: uint32(expireTime)}}
|
||||
resp.Data = structs.Map(&resp.ExpireTime)
|
||||
log.NewInfo(params.OperationID, "ParseToken return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 强制登出
|
||||
// @Description 对应的平台强制登出
|
||||
// @Tags 鉴权认证
|
||||
// @ID ForceLogout
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.ForceLogoutReq true "platform为平台ID <br> fromUserID为要执行强制登出的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ForceLogoutResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /auth/force_logout [post]
|
||||
func ForceLogout(c *gin.Context) {
|
||||
params := api.ForceLogoutReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
req := &rpc.ForceLogoutReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "ForceLogout args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.ForceLogout(context.Background(), req)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " UserToken failed " + err.Error() + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
resp := api.ForceLogoutResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), " return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
@@ -5,30 +5,16 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/chat"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 根据seq列表删除消息
|
||||
// @Description 根据seq列表删除消息
|
||||
// @Tags 消息相关
|
||||
// @ID DelMsg
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DelMsgReq true "userID为要删除的用户ID <br> seqList为seq列表"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DelMsgResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/del_msg [post]
|
||||
func DelMsg(c *gin.Context) {
|
||||
var (
|
||||
req api.DelMsgReq
|
||||
@@ -39,29 +25,12 @@ func DelMsg(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, req.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
msgClient := rpc.NewChatClient(grpcConn)
|
||||
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)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
||||
@@ -70,139 +39,5 @@ func DelMsg(c *gin.Context) {
|
||||
}
|
||||
resp.ErrCode = respPb.ErrCode
|
||||
resp.ErrMsg = respPb.ErrMsg
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
func DelSuperGroupMsg(c *gin.Context) {
|
||||
var (
|
||||
req api.DelSuperGroupMsgReq
|
||||
resp api.DelSuperGroupMsgResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
|
||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + opUserID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
options := make(map[string]bool, 5)
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
pbData := rpc.SendMsgReq{
|
||||
OperationID: req.OperationID,
|
||||
MsgData: &pbCommon.MsgData{
|
||||
SendID: req.UserID,
|
||||
RecvID: req.UserID,
|
||||
ClientMsgID: utils.GetMsgID(req.UserID),
|
||||
SessionType: constant.SingleChatType,
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: constant.MsgDeleteNotification,
|
||||
// ForceList: params.ForceList,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
},
|
||||
}
|
||||
var tips pbCommon.TipsComm
|
||||
deleteMsg := api.MsgDeleteNotificationElem{
|
||||
GroupID: req.GroupID,
|
||||
IsAllDelete: req.IsAllDelete,
|
||||
SeqList: req.SeqList,
|
||||
}
|
||||
tips.JsonDetail = utils.StructToJsonString(deleteMsg)
|
||||
var err error
|
||||
pbData.MsgData.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.Error(req.OperationID, "Marshal failed ", err.Error(), tips.String())
|
||||
resp.ErrCode = 400
|
||||
resp.ErrMsg = err.Error()
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call start..., [data: %s]", pbData.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewChatClient(etcdConn)
|
||||
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call, api call rpc...")
|
||||
|
||||
RpcResp, err := client.SendMsg(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||
resp.ErrCode = RpcResp.ErrCode
|
||||
resp.ErrMsg = RpcResp.ErrMsg
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 清空用户消息
|
||||
// @Description 清空用户消息
|
||||
// @Tags 消息相关
|
||||
// @ID ClearMsg
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CleanUpMsgReq true "userID为要清空的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CleanUpMsgResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/clear_msg [post]
|
||||
func ClearMsg(c *gin.Context) {
|
||||
params := api.CleanUpMsgReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
//
|
||||
req := &rpc.ClearMsgReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewChatClient(etcdConn)
|
||||
RpcResp, err := client.ClearMsg(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, " CleanUpMsg failed ", err.Error(), req.String(), RpcResp.ErrMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": RpcResp.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.CleanUpMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
@@ -32,18 +31,15 @@ func GetSeq(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := sdk_ws.GetMaxAndMinSeqReq{}
|
||||
pbData := pbMsg.GetMaxAndMinSeqReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + " getcdv3.GetConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", params)
|
||||
}
|
||||
msgClient := pbMsg.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "UserGetSeq rpc failed, ", params, err.Error())
|
||||
|
||||
@@ -51,20 +51,14 @@ func PullMsgBySeqList(c *gin.Context) {
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqList = params.SeqList
|
||||
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.Error(pbData.OperationID, "PullMessageBySeqList error", err.Error())
|
||||
log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo(pbData.OperationID, "rpc call success to PullMessageBySeqList", reply.String(), len(reply.List))
|
||||
log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), len(reply.List))
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
|
||||
@@ -62,22 +62,18 @@ func SendMsg(c *gin.Context) {
|
||||
params := paramsUserSendMsg{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
log.Error("0", "BindJSON failed ", err.Error())
|
||||
log.ErrorByKv("json unmarshal err", "", "err", err.Error(), "data", c.PostForm("data"))
|
||||
return
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
log.NewInfo(params.OperationID, "api call success to sendMsgReq", params)
|
||||
pbData := newUserSendMsgReq(token, ¶ms)
|
||||
log.Info(params.OperationID, "", "api SendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
pbData := newUserSendMsgReq(token, ¶ms)
|
||||
log.Info("", "", "api SendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
log.Info("", "", "api SendMsg call, api call rpc...")
|
||||
@@ -88,7 +84,7 @@ func SendMsg(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SendMsg rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info(params.OperationID, "", "api SendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
log.Info("", "", "api SendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@@ -25,20 +24,14 @@ func SetConversation(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.Conversation = &pbUser.Conversation{}
|
||||
err := utils.CopyStructFields(&reqPb, req)
|
||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||
if err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -51,43 +44,6 @@ func SetConversation(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
func ModifyConversationField(c *gin.Context) {
|
||||
var (
|
||||
req api.ModifyConversationFieldReq
|
||||
resp api.ModifyConversationFieldResp
|
||||
reqPb pbConversation.ModifyConversationFieldReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.Conversation = &pbConversation.Conversation{}
|
||||
err := utils.CopyStructFields(&reqPb, req)
|
||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||
if err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbConversation.NewConversationClient(etcdConn)
|
||||
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func BatchSetConversations(c *gin.Context) {
|
||||
var (
|
||||
@@ -100,17 +56,11 @@ func BatchSetConversations(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -127,18 +77,6 @@ func BatchSetConversations(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取用户所有会话
|
||||
// @Description 获取用户所有会话
|
||||
// @Tags 会话相关
|
||||
// @ID GetAllConversations
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetAllConversationsReq true "ownerUserID为要获取的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetAllConversationsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/get_all_conversations [post]
|
||||
func GetAllConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetAllConversationsReq
|
||||
@@ -150,17 +88,11 @@ func GetAllConversations(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -177,18 +109,6 @@ func GetAllConversations(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 根据会话ID获取会话
|
||||
// @Description 根据会话ID获取会话
|
||||
// @Tags 会话相关
|
||||
// @ID GetConversation
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetConversationReq true "ownerUserID为要获取的用户ID<br>conversationID为要获取的会话ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetConversationResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/get_conversation [post]
|
||||
func GetConversation(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationReq
|
||||
@@ -200,17 +120,11 @@ func GetConversation(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -227,18 +141,6 @@ func GetConversation(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 根据会话ID列表获取会话
|
||||
// @Description 根据会话ID列表获取会话
|
||||
// @Tags 会话相关
|
||||
// @ID GetConversations
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetConversationsReq true "ownerUserID为要获取的用户ID<br>conversationIDs为要获取的会话ID列表"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetConversationsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/get_conversations [post]
|
||||
func GetConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationsReq
|
||||
@@ -250,17 +152,11 @@ func GetConversations(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -288,17 +184,11 @@ func SetRecvMsgOpt(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
|
||||
+82
-304
@@ -16,18 +16,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 添加黑名单
|
||||
// @Description 添加黑名单
|
||||
// @Tags 好友相关
|
||||
// @ID AddBlack
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.AddBlacklistReq true "fromUserID为设置的用户 <br> toUserID为被设置的用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.AddBlacklistResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/add_black [post]
|
||||
func AddBlack(c *gin.Context) {
|
||||
params := api.AddBlacklistReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -38,17 +26,15 @@ func AddBlack(c *gin.Context) {
|
||||
req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "AddBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -61,18 +47,6 @@ func AddBlack(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 批量加好友
|
||||
// @Description 批量加好友
|
||||
// @Tags 好友相关
|
||||
// @ID ImportFriend
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.ImportFriendReq true "fromUserID批量加好友的用户ID<br> friendUserIDList为"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ImportFriendResp "data列表中对象的result-1为添加该用户失败<br>0为成功"
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/import_friend [post]
|
||||
func ImportFriend(c *gin.Context) {
|
||||
params := api.ImportFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -83,24 +57,15 @@ func ImportFriend(c *gin.Context) {
|
||||
req := &rpc.ImportFriendReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -121,18 +86,6 @@ func ImportFriend(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 添加好友
|
||||
// @Description 添加好友
|
||||
// @Tags 好友相关
|
||||
// @ID AddFriend
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.AddFriendReq true "reqMsg为申请信息 <br> fromUserID为申请用户 <br> toUserID为被添加用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.AddFriendResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/add_friend [post]
|
||||
func AddFriend(c *gin.Context) {
|
||||
params := api.AddFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -143,26 +96,16 @@ func AddFriend(c *gin.Context) {
|
||||
req := &rpc.AddFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.ReqMsg = params.ReqMsg
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -176,18 +119,6 @@ func AddFriend(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 同意/拒绝好友请求
|
||||
// @Description 同意/拒绝好友请求
|
||||
// @Tags 好友相关
|
||||
// @ID AddFriendResponse
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.AddFriendResponseReq true "fromUserID同意/拒绝的用户ID<br>toUserID为申请用户D<br>handleMsg为处理信息<br>flag为具体操作, 1为同意, 2为拒绝"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.AddFriendResponseResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/add_friend_response [post]
|
||||
func AddFriendResponse(c *gin.Context) {
|
||||
params := api.AddFriendResponseReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -199,28 +130,17 @@ func AddFriendResponse(c *gin.Context) {
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.HandleMsg = params.HandleMsg
|
||||
req.HandleResult = params.Flag
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddFriendResponse(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -234,18 +154,6 @@ func AddFriendResponse(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 删除好友
|
||||
// @Description 删除好友
|
||||
// @Tags 好友相关
|
||||
// @ID DeleteFriend
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteFriendReq true "fromUserID为操作用户<br>toUserID为被删除用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteFriendResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/delete_friend [post]
|
||||
func DeleteFriend(c *gin.Context) {
|
||||
params := api.DeleteFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -255,26 +163,16 @@ func DeleteFriend(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.DeleteFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -288,18 +186,6 @@ func DeleteFriend(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取黑名单列表
|
||||
// @Description 获取黑名单列表
|
||||
// @Tags 好友相关
|
||||
// @ID GetBlacklist
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetBlackListReq true "fromUserID要获取黑名单的用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetBlackListResp{data=[]open_im_sdk.PublicUserInfo}
|
||||
// @Failure 500 {object} api.Swagger400Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger500Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/get_black_list [post]
|
||||
func GetBlacklist(c *gin.Context) {
|
||||
params := api.GetBlackListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -309,26 +195,16 @@ func GetBlacklist(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -348,18 +224,6 @@ func GetBlacklist(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 设置好友备注
|
||||
// @Description 设置好友备注
|
||||
// @Tags 好友相关
|
||||
// @ID SetFriendRemark
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.SetFriendRemarkReq true "fromUserID为设置的用户<br> toUserID为被设置的用户<br> remark为好友备注"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.SetFriendRemarkResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/set_friend_remark [post]
|
||||
func SetFriendRemark(c *gin.Context) {
|
||||
params := api.SetFriendRemarkReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -370,26 +234,16 @@ func SetFriendRemark(c *gin.Context) {
|
||||
req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.Remark = params.Remark
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.SetFriendRemark(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -403,18 +257,6 @@ func SetFriendRemark(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 把用户移除黑名单
|
||||
// @Description 把用户移除黑名单
|
||||
// @Tags 好友相关
|
||||
// @ID RemoveBlack
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.RemoveBlackListReq true "fromUserID要获取黑名单的用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.RemoveBlackListResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/remove_black [post]
|
||||
func RemoveBlack(c *gin.Context) {
|
||||
params := api.RemoveBlackListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -424,26 +266,16 @@ func RemoveBlack(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -456,18 +288,6 @@ func RemoveBlack(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 检查用户之间是否为好友
|
||||
// @Description 检查用户之间是否为好友
|
||||
// @Tags 好友相关
|
||||
// @ID IsFriend
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.IsFriendReq true "fromUserID为请求用户<br> toUserID为要检查的用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.IsFriendResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/is_friend [post]
|
||||
func IsFriend(c *gin.Context) {
|
||||
params := api.IsFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -477,26 +297,16 @@ func IsFriend(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.IsFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -511,18 +321,40 @@ func IsFriend(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取用户的好友列表
|
||||
// @Description 获取用户的好友列表
|
||||
// @Tags 好友相关
|
||||
// @ID GetFriendList
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetFriendListReq true "fromUserID为要获取好友列表的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetFriendListResp{data=[]open_im_sdk.FriendInfo}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/get_friend_list [post]
|
||||
//
|
||||
//func GetFriendsInfo(c *gin.Context) {
|
||||
// params := api.GetFriendsInfoReq{}
|
||||
// if err := c.BindJSON(¶ms); err != nil {
|
||||
// log.NewError("0", "BindJSON failed ", err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
// return
|
||||
// }
|
||||
// req := &rpc.GetFriendsInfoReq{}
|
||||
// utils.CopyStructFields(req.CommID, params)
|
||||
// var ok bool
|
||||
// ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
// if !ok {
|
||||
// log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
// return
|
||||
// }
|
||||
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
|
||||
//
|
||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
// client := rpc.NewFriendClient(etcdConn)
|
||||
// RpcResp, err := client.GetFriendsInfo(context.Background(), req)
|
||||
// if err != nil {
|
||||
// log.NewError(req.CommID.OperationID, "GetFriendsInfo failed ", err.Error(), req.String())
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// resp := api.GetFriendsInfoResp{CommResp:api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
// utils.CopyStructFields(&resp, RpcResp)
|
||||
// c.JSON(http.StatusOK, resp)
|
||||
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo api return ", resp)
|
||||
//}
|
||||
|
||||
func GetFriendList(c *gin.Context) {
|
||||
params := api.GetFriendListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -532,26 +364,16 @@ func GetFriendList(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetFriendList(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -567,18 +389,6 @@ func GetFriendList(c *gin.Context) {
|
||||
//c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取好友申请列表
|
||||
// @Description 删除好友
|
||||
// @Tags 好友相关
|
||||
// @ID GetFriendApplyList
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetFriendApplyListReq true "fromUserID为要获取申请列表的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetFriendApplyListResp{data=[]open_im_sdk.FriendRequest}
|
||||
// @Failure 500 {object} api.Swagger400Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/get_friend_apply_list [post]
|
||||
func GetFriendApplyList(c *gin.Context) {
|
||||
params := api.GetFriendApplyListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -588,26 +398,16 @@ func GetFriendApplyList(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
|
||||
@@ -623,18 +423,6 @@ func GetFriendApplyList(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取自己的好友申请列表
|
||||
// @Description 获取自己的好友申请列表
|
||||
// @Tags 好友相关
|
||||
// @ID GetSelfFriendApplyList
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetSelfApplyListReq true "fromUserID为自己的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetSelfApplyListResp{data=[]open_im_sdk.FriendRequest}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/get_self_friend_apply_list [post]
|
||||
func GetSelfFriendApplyList(c *gin.Context) {
|
||||
params := api.GetSelfApplyListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -644,26 +432,16 @@ func GetSelfFriendApplyList(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
|
||||
if err != nil {
|
||||
|
||||
+96
-636
File diff suppressed because it is too large
Load Diff
@@ -1,89 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
jsonData "Open_IM/internal/utils"
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetJoinedSuperGroupList(c *gin.Context) {
|
||||
req := api.GetJoinedSuperGroupListReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
reqPb := rpc.GetJoinedSuperGroupListReq{OperationID: req.OperationID, OpUserID: opUserID, UserID: req.FromUserID}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
rpcResp, err := client.GetJoinedSuperGroupList(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), reqPb.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
GroupListResp := api.GetJoinedSuperGroupListResp{GetJoinedGroupListResp: api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupList}}
|
||||
GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
||||
log.NewInfo(req.OperationID, "GetJoinedSuperGroupList api return ", GroupListResp)
|
||||
c.JSON(http.StatusOK, GroupListResp)
|
||||
}
|
||||
|
||||
func GetSuperGroupsInfo(c *gin.Context) {
|
||||
req := api.GetSuperGroupsInfoReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
reqPb := rpc.GetSuperGroupsInfoReq{OperationID: req.OperationID, OpUserID: opUserID, GroupIDList: req.GroupIDList}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
rpcResp, err := client.GetSuperGroupsInfo(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), reqPb.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetSuperGroupsInfoResp{GetGroupInfoResp: api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupInfoList}}
|
||||
resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
|
||||
var validate *validator.Validate
|
||||
|
||||
func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
var newContent string
|
||||
var err error
|
||||
switch params.ContentType {
|
||||
@@ -40,16 +40,16 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
fallthrough
|
||||
case constant.Voice:
|
||||
fallthrough
|
||||
case constant.Video:
|
||||
fallthrough
|
||||
case constant.File:
|
||||
newContent = utils.StructToJsonString(params.Content)
|
||||
case constant.Revoke:
|
||||
newContent = params.Content["revokeMsgClientID"].(string)
|
||||
|
||||
default:
|
||||
}
|
||||
options := make(map[string]bool, 5)
|
||||
var options map[string]bool
|
||||
if params.IsOnlineOnly {
|
||||
options = make(map[string]bool, 5)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||
@@ -59,6 +59,7 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
OperationID: params.OperationID,
|
||||
MsgData: &open_im_sdk.MsgData{
|
||||
SendID: params.SendID,
|
||||
RecvID: params.RecvID,
|
||||
GroupID: params.GroupID,
|
||||
ClientMsgID: utils.GetMsgID(params.SendID),
|
||||
SenderPlatformID: params.SenderPlatformID,
|
||||
@@ -68,7 +69,6 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: params.ContentType,
|
||||
Content: []byte(newContent),
|
||||
RecvID: params.RecvID,
|
||||
// ForceList: params.ForceList,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
@@ -89,26 +89,12 @@ func init() {
|
||||
validate = validator.New()
|
||||
}
|
||||
|
||||
// @Summary 管理员发送/撤回消息
|
||||
// @Description 管理员发送/撤回消息 消息格式详细见<a href="https://doc.rentsoft.cn/#/server_doc/admin?id=%e6%b6%88%e6%81%af%e7%b1%bb%e5%9e%8b%e6%a0%bc%e5%bc%8f%e6%8f%8f%e8%bf%b0">消息格式</href>
|
||||
// @Tags 消息相关
|
||||
// @ID ManagementSendMsg
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param 管理员发送文字消息 body api.ManagementSendMsgReq{content=TextElem{}} true "该请求和消息结构体一样"
|
||||
// @Param 管理员发送OA通知消息 body api.ManagementSendMsgReq{content=OANotificationElem{}} true "该请求和消息结构体一样"
|
||||
// @Param 管理员撤回单聊消息 body api.ManagementSendMsgReq{content=RevokeElem{}} true "该请求和消息结构体一样"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ManagementSendMsgResp "serverMsgID为服务器消息ID <br> clientMsgID为客户端消息ID <br> sendTime为发送消息时间"
|
||||
// @Failure 500 {object} api.ManagementSendMsgResp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.ManagementSendMsgResp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/manage_send_msg [post]
|
||||
func ManagementSendMsg(c *gin.Context) {
|
||||
var data interface{}
|
||||
params := api.ManagementSendMsgReq{}
|
||||
params := ManagementSendMsgReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
|
||||
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
switch params.ContentType {
|
||||
@@ -140,19 +126,19 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
//case constant.Quote:
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||
log.Error(c.PostForm("operationID"), "contentType err", c.PostForm("content"))
|
||||
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
|
||||
log.ErrorByKv("content to Data struct err", "", "err", err.Error())
|
||||
return
|
||||
} else if err := validate.Struct(data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
|
||||
log.ErrorByKv("data args validate err", "", "err", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, data, params)
|
||||
log.NewInfo("", data, params)
|
||||
token := c.Request.Header.Get("token")
|
||||
claims, err := token_verify.ParseToken(token, params.OperationID)
|
||||
if err != nil {
|
||||
@@ -180,21 +166,15 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
}
|
||||
|
||||
}
|
||||
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
||||
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
pbData := newUserSendMsgReq(¶ms)
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
||||
log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call, api call rpc...")
|
||||
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
|
||||
|
||||
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||
if err != nil {
|
||||
@@ -202,126 +182,38 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||
log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: server_api_params.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
// @Summary 管理员批量发送群聊单聊消息
|
||||
// @Description 管理员批量发送群聊单聊消息 消息格式详细见<a href="https://doc.rentsoft.cn/#/server_doc/admin?id=%e6%b6%88%e6%81%af%e7%b1%bb%e5%9e%8b%e6%a0%bc%e5%bc%8f%e6%8f%8f%e8%bf%b0">消息格式</href>
|
||||
// @Tags 消息相关
|
||||
// @ID ManagementBatchSendMsg
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param 管理员批量发送单聊消息 body api.ManagementBatchSendMsgReq{content=TextElem{}} true "该请求和消息结构体一样 <br> recvIDList为接受消息的用户ID列表"
|
||||
// @Param 管理员批量发送OA通知 body api.ManagementSendMsgReq{content=OANotificationElem{}} true "该请求和消息结构体一样 <br> recvIDList为接受消息的用户ID列表"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ManagementBatchSendMsgReq "serverMsgID为服务器消息ID <br> clientMsgID为客户端消息ID <br> sendTime为发送消息时间"
|
||||
// @Failure 500 {object} api.ManagementBatchSendMsgReq "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.ManagementBatchSendMsgReq "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/batch_send_msg [post]
|
||||
func ManagementBatchSendMsg(c *gin.Context) {
|
||||
var data interface{}
|
||||
params := api.ManagementBatchSendMsgReq{}
|
||||
resp := api.ManagementBatchSendMsgResp{}
|
||||
resp.Data.FailedIDList = make([]string, 0)
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
switch params.ContentType {
|
||||
case constant.Text:
|
||||
data = TextElem{}
|
||||
case constant.Picture:
|
||||
data = PictureElem{}
|
||||
case constant.Voice:
|
||||
data = SoundElem{}
|
||||
case constant.Video:
|
||||
data = VideoElem{}
|
||||
case constant.File:
|
||||
data = FileElem{}
|
||||
//case constant.AtText:
|
||||
// data = AtElem{}
|
||||
//case constant.Merger:
|
||||
// data =
|
||||
//case constant.Card:
|
||||
//case constant.Location:
|
||||
case constant.Custom:
|
||||
data = CustomElem{}
|
||||
case constant.Revoke:
|
||||
data = RevokeElem{}
|
||||
case constant.OANotification:
|
||||
data = OANotificationElem{}
|
||||
params.SessionType = constant.NotificationChatType
|
||||
//case constant.HasReadReceipt:
|
||||
//case constant.Typing:
|
||||
//case constant.Quote:
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||
log.Error(c.PostForm("operationID"), "contentType err", c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
|
||||
return
|
||||
} else if err := validate.Struct(data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, data, params)
|
||||
token := c.Request.Header.Get("token")
|
||||
claims, err := token_verify.ParseToken(token, params.OperationID)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "parse token failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
|
||||
}
|
||||
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
||||
for _, recvID := range params.RecvIDList {
|
||||
req := &api.ManagementSendMsgReq{
|
||||
ManagementSendMsg: params.ManagementSendMsg,
|
||||
RecvID: recvID,
|
||||
}
|
||||
pbData := newUserSendMsgReq(req)
|
||||
pbData.MsgData.RecvID = recvID
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
resp.Data.FailedIDList = append(resp.Data.FailedIDList, recvID)
|
||||
continue
|
||||
}
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
rpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||
resp.Data.FailedIDList = append(resp.Data.FailedIDList, recvID)
|
||||
continue
|
||||
}
|
||||
if rpcResp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), "rpc failed", pbData, rpcResp)
|
||||
resp.Data.FailedIDList = append(resp.Data.FailedIDList, recvID)
|
||||
continue
|
||||
}
|
||||
resp.Data.ResultList = append(resp.Data.ResultList, server_api_params.UserSendMsgResp{
|
||||
ServerMsgID: rpcResp.ServerMsgID,
|
||||
ClientMsgID: rpcResp.ClientMsgID,
|
||||
SendTime: rpcResp.SendTime,
|
||||
})
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
//
|
||||
//type MergeElem struct {
|
||||
// Title string `json:"title"`
|
||||
// AbstractList []string `json:"abstractList"`
|
||||
// MultiMessage []*MsgStruct `json:"multiMessage"`
|
||||
//}
|
||||
//
|
||||
//type QuoteElem struct {
|
||||
// Text string `json:"text"`
|
||||
// QuoteMessage *MsgStruct `json:"quoteMessage"`
|
||||
//}
|
||||
type ManagementSendMsgReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
RecvID string `json:"recvID" `
|
||||
GroupID string `json:"groupID" `
|
||||
SenderNickname string `json:"senderNickname" `
|
||||
SenderFaceURL string `json:"senderFaceURL" `
|
||||
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||
ForceList []string `json:"forceList" `
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
OfflinePushInfo *open_im_sdk.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
|
||||
type PictureBaseInfo struct {
|
||||
@@ -390,15 +282,15 @@ type RevokeElem struct {
|
||||
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||
}
|
||||
type OANotificationElem struct {
|
||||
NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"`
|
||||
NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL" validate:"required"`
|
||||
NotificationType int32 `mapstructure:"notificationType" json:"notificationType" validate:"required"`
|
||||
Text string `mapstructure:"text" json:"text" validate:"required"`
|
||||
Url string `mapstructure:"url" json:"url"`
|
||||
MixType int32 `mapstructure:"mixType" json:"mixType"`
|
||||
PictureElem PictureElem `mapstructure:"pictureElem" json:"pictureElem"`
|
||||
SoundElem SoundElem `mapstructure:"soundElem" json:"soundElem"`
|
||||
VideoElem VideoElem `mapstructure:"videoElem" json:"videoElem"`
|
||||
FileElem FileElem `mapstructure:"fileElem" json:"fileElem"`
|
||||
Ex string `mapstructure:"ex" json:"ex"`
|
||||
NotificationName string `mapstructure:"notificationName" validate:"required"`
|
||||
NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"`
|
||||
NotificationType int32 `mapstructure:"notificationType" validate:"required"`
|
||||
Text string `mapstructure:"text" validate:"required"`
|
||||
Url string `mapstructure:"url"`
|
||||
MixType int32 `mapstructure:"mixType"`
|
||||
PictureElem PictureElem `mapstructure:"pictureElem"`
|
||||
SoundElem SoundElem `mapstructure:"soundElem"`
|
||||
VideoElem VideoElem `mapstructure:"videoElem"`
|
||||
FileElem FileElem `mapstructure:"fileElem"`
|
||||
Ex string `mapstructure:"ex"`
|
||||
}
|
||||
|
||||
@@ -30,25 +30,15 @@ func DeleteUser(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.DeleteUsersReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, "DeleteUser args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
||||
@@ -64,19 +54,6 @@ func DeleteUser(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, "DeleteUser api return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取所有用户uid列表
|
||||
// @Description 获取所有用户uid列表
|
||||
// @Tags 用户相关
|
||||
// @ID GetAllUsersUid
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetAllUsersUidReq true "请求体"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetAllUsersUidResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/get_all_users_uid [post]
|
||||
func GetAllUsersUid(c *gin.Context) {
|
||||
params := api.GetAllUsersUidReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -85,25 +62,15 @@ func GetAllUsersUid(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetAllUserIDReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.GetAllUserID(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -119,19 +86,6 @@ func GetAllUsersUid(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
// @Summary 检查列表账户注册状态,并且返回结果
|
||||
// @Description 传入UserIDList检查列表账户注册状态,并且返回结果
|
||||
// @Tags 用户相关
|
||||
// @ID AccountCheck
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.AccountCheckReq true "请求体"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.AccountCheckResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/account_check [post]
|
||||
func AccountCheck(c *gin.Context) {
|
||||
params := api.AccountCheckReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -140,25 +94,15 @@ func AccountCheck(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.AccountCheckReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, "AccountCheck args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.AccountCheck(context.Background(), req)
|
||||
@@ -183,14 +127,11 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
}
|
||||
req := &pbRelay.GetUsersOnlineStatusReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+46
-216
@@ -1,7 +1,7 @@
|
||||
package office
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
apistruct "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
@@ -11,27 +11,14 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"google.golang.org/grpc"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 获取用户标签信息
|
||||
// @Description 用户获取自己的所有的标签
|
||||
// @Tags 标签
|
||||
// @ID GetUserTags
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserTagsReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserTagsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_user_tags [post]
|
||||
func GetUserTags(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUserTagsReq
|
||||
resp api.GetUserTagsResp
|
||||
req apistruct.GetUserTagsReq
|
||||
resp apistruct.GetUserTagsResp
|
||||
reqPb pbOffice.GetUserTagsReq
|
||||
respPb *pbOffice.GetUserTagsResp
|
||||
)
|
||||
@@ -40,27 +27,15 @@ func GetUserTags(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetUserTags(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -79,22 +54,10 @@ func GetUserTags(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 创建标签
|
||||
// @Description 创建标签
|
||||
// @Tags 标签
|
||||
// @ID CreateTag
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateTagReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateTagResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/create_tag [post]
|
||||
func CreateTag(c *gin.Context) {
|
||||
var (
|
||||
req api.CreateTagReq
|
||||
resp api.CreateTagResp
|
||||
req apistruct.CreateTagReq
|
||||
resp apistruct.CreateTagResp
|
||||
reqPb pbOffice.CreateTagReq
|
||||
respPb *pbOffice.CreateTagResp
|
||||
)
|
||||
@@ -106,26 +69,14 @@ func CreateTag(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.CreateTag(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -139,22 +90,10 @@ func CreateTag(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 删除标签
|
||||
// @Description 根据标签ID创建标签
|
||||
// @Tags 标签
|
||||
// @ID DeleteTag
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteTagReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteTagResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/delete_tag [post]
|
||||
func DeleteTag(c *gin.Context) {
|
||||
var (
|
||||
req api.DeleteTagReq
|
||||
resp api.DeleteTagResp
|
||||
req apistruct.DeleteTagReq
|
||||
resp apistruct.DeleteTagResp
|
||||
reqPb pbOffice.DeleteTagReq
|
||||
respPb *pbOffice.DeleteTagResp
|
||||
)
|
||||
@@ -166,26 +105,14 @@ func DeleteTag(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.DeleteTag(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -199,22 +126,10 @@ func DeleteTag(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 修改标签
|
||||
// @Description 根据标签ID修改标签用户列表, 名称
|
||||
// @Tags 标签
|
||||
// @ID SetTag
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.SetTagReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.SetTagResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/set_tag [post]
|
||||
func SetTag(c *gin.Context) {
|
||||
var (
|
||||
req api.SetTagReq
|
||||
resp api.SetTagResp
|
||||
req apistruct.SetTagReq
|
||||
resp apistruct.SetTagResp
|
||||
reqPb pbOffice.SetTagReq
|
||||
respPb *pbOffice.SetTagResp
|
||||
)
|
||||
@@ -226,26 +141,14 @@ func SetTag(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.SetTag(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -259,22 +162,10 @@ func SetTag(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 发送标签消息
|
||||
// @Description 对标签用户发送消息
|
||||
// @Tags 标签
|
||||
// @ID SendMsg2Tag
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.SendMsg2TagReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.SendMsg2TagResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/send_msg_to_tag [post]
|
||||
func SendMsg2Tag(c *gin.Context) {
|
||||
var (
|
||||
req api.SendMsg2TagReq
|
||||
resp api.SendMsg2TagResp
|
||||
req apistruct.SendMsg2TagReq
|
||||
resp apistruct.SendMsg2TagResp
|
||||
reqPb pbOffice.SendMsg2TagReq
|
||||
respPb *pbOffice.SendMsg2TagResp
|
||||
)
|
||||
@@ -286,26 +177,14 @@ func SendMsg2Tag(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.SendID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.SendMsg2Tag(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -319,22 +198,10 @@ func SendMsg2Tag(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取发送历史记录
|
||||
// @Description 分页获取发送历史记录
|
||||
// @Tags 标签
|
||||
// @ID GetTagSendLogs
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetTagSendLogsReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetTagSendLogsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_send_tag_log [post]
|
||||
func GetTagSendLogs(c *gin.Context) {
|
||||
var (
|
||||
req api.GetTagSendLogsReq
|
||||
resp api.GetTagSendLogsResp
|
||||
req apistruct.GetTagSendLogsReq
|
||||
resp apistruct.GetTagSendLogsResp
|
||||
reqPb pbOffice.GetTagSendLogsReq
|
||||
respPb *pbOffice.GetTagSendLogsResp
|
||||
)
|
||||
@@ -343,37 +210,24 @@ func GetTagSendLogs(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||
PageNumber: req.PageNumber,
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
maxSizeOption := grpc.MaxCallRecvMsgSize(1024 * 1024 * 20)
|
||||
respPb, err := client.GetTagSendLogs(context.Background(), &reqPb, maxSizeOption)
|
||||
respPb, err := client.GetTagSendLogs(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTagSendLogs failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetTagSendLogs rpc server failed" + err.Error()})
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||
@@ -389,22 +243,10 @@ func GetTagSendLogs(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取该用户的标签信息
|
||||
// @Description 通过标签id获取该用户的标签信息
|
||||
// @Tags 标签
|
||||
// @ID GetUserTagByID
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserTagByIDReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserTagByIDResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_user_tag_by_id [post]
|
||||
func GetUserTagByID(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUserTagByIDReq
|
||||
resp api.GetUserTagByIDResp
|
||||
req apistruct.GetUserTagByIDReq
|
||||
resp apistruct.GetUserTagByIDResp
|
||||
reqPb pbOffice.GetUserTagByIDReq
|
||||
respPb *pbOffice.GetUserTagByIDResp
|
||||
)
|
||||
@@ -413,28 +255,16 @@ func GetUserTagByID(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.TagID = req.TagID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetUserTagByID(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package office
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
apiStruct "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
@@ -15,22 +15,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 创建一条工作圈
|
||||
// @Description 用户创建一条工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID CreateOneWorkMoment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateOneWorkMomentReq true "请求 atUserList likeUserList permissionGroupList permissionUserList 字段中userName可以不填"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateOneWorkMomentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/create_one_work_moment [post]
|
||||
func CreateOneWorkMoment(c *gin.Context) {
|
||||
var (
|
||||
req api.CreateOneWorkMomentReq
|
||||
resp api.CreateOneWorkMomentResp
|
||||
req apiStruct.CreateOneWorkMomentReq
|
||||
resp apiStruct.CreateOneWorkMomentResp
|
||||
reqPb pbOffice.CreateOneWorkMomentReq
|
||||
respPb *pbOffice.CreateOneWorkMomentResp
|
||||
)
|
||||
@@ -40,30 +28,17 @@ func CreateOneWorkMoment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.WorkMoment.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.CreateOneWorkMoment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -71,7 +46,7 @@ func CreateOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateOneWorkMoment rpc server failed" + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.CommResp = api.CommResp{
|
||||
resp.CommResp = apiStruct.CommResp{
|
||||
ErrCode: respPb.CommonResp.ErrCode,
|
||||
ErrMsg: respPb.CommonResp.ErrMsg,
|
||||
}
|
||||
@@ -79,22 +54,10 @@ func CreateOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 删除一条工作圈
|
||||
// @Description 根据用户工作圈ID删除一条工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID DeleteOneWorkMoment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteOneWorkMomentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteOneWorkMomentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/delete_one_work_moment [post]
|
||||
func DeleteOneWorkMoment(c *gin.Context) {
|
||||
var (
|
||||
req api.DeleteOneWorkMomentReq
|
||||
resp api.DeleteOneWorkMomentResp
|
||||
req apiStruct.DeleteOneWorkMomentReq
|
||||
resp apiStruct.DeleteOneWorkMomentResp
|
||||
reqPb pbOffice.DeleteOneWorkMomentReq
|
||||
respPb *pbOffice.DeleteOneWorkMomentResp
|
||||
)
|
||||
@@ -104,30 +67,17 @@ func DeleteOneWorkMoment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.DeleteOneWorkMoment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -142,22 +92,10 @@ func DeleteOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 点赞一条工作圈
|
||||
// @Description 工作圈ID点赞一条工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID LikeOneWorkMoment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.LikeOneWorkMomentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.LikeOneWorkMomentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/like_one_work_moment [post]
|
||||
func LikeOneWorkMoment(c *gin.Context) {
|
||||
var (
|
||||
req api.LikeOneWorkMomentReq
|
||||
resp api.LikeOneWorkMomentResp
|
||||
req apiStruct.LikeOneWorkMomentReq
|
||||
resp apiStruct.LikeOneWorkMomentResp
|
||||
reqPb pbOffice.LikeOneWorkMomentReq
|
||||
respPb *pbOffice.LikeOneWorkMomentResp
|
||||
)
|
||||
@@ -167,29 +105,17 @@ func LikeOneWorkMoment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.LikeOneWorkMoment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -204,22 +130,10 @@ func LikeOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 评论一条工作圈
|
||||
// @Description 评论一条工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID CommentOneWorkMoment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CommentOneWorkMomentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CommentOneWorkMomentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/comment_one_work_moment [post]
|
||||
func CommentOneWorkMoment(c *gin.Context) {
|
||||
var (
|
||||
req api.CommentOneWorkMomentReq
|
||||
resp api.CommentOneWorkMomentResp
|
||||
req apiStruct.CommentOneWorkMomentReq
|
||||
resp apiStruct.CommentOneWorkMomentResp
|
||||
reqPb pbOffice.CommentOneWorkMomentReq
|
||||
respPb *pbOffice.CommentOneWorkMomentResp
|
||||
)
|
||||
@@ -229,29 +143,17 @@ func CommentOneWorkMoment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.CommentOneWorkMoment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -266,82 +168,10 @@ func CommentOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 删除一条评论
|
||||
// @Description 删除一条评论
|
||||
// @Tags 工作圈
|
||||
// @ID DeleteComment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteCommentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteCommentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/delete_comment [post]
|
||||
func DeleteComment(c *gin.Context) {
|
||||
var (
|
||||
req api.DeleteCommentReq
|
||||
resp api.DeleteCommentResp
|
||||
reqPb pbOffice.DeleteCommentReq
|
||||
respPb *pbOffice.DeleteCommentResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.DeleteComment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteComment rpc failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "DeleteComment rpc server failed" + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 通过ID获取工作圈
|
||||
// @Description 通过ID获取工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID GetWorkMomentByID
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetWorkMomentByIDReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetWorkMomentByIDResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_work_moment_by_id [post]
|
||||
func GetWorkMomentByID(c *gin.Context) {
|
||||
var (
|
||||
req api.GetWorkMomentByIDReq
|
||||
resp api.GetWorkMomentByIDResp
|
||||
req apiStruct.GetWorkMomentByIDReq
|
||||
resp apiStruct.GetWorkMomentByIDResp
|
||||
reqPb pbOffice.GetWorkMomentByIDReq
|
||||
respPb *pbOffice.GetWorkMomentByIDResp
|
||||
)
|
||||
@@ -351,28 +181,16 @@ func GetWorkMomentByID(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.OpUserID = userID
|
||||
reqPb.WorkMomentID = req.WorkMomentID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetWorkMomentByID(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -383,8 +201,8 @@ func GetWorkMomentByID(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
resp.Data.WorkMoment = &api.WorkMoment{LikeUserList: []*api.WorkMomentUser{}, Comments: []*api.Comment{},
|
||||
AtUserList: []*api.WorkMomentUser{}, PermissionUserList: []*api.WorkMomentUser{}}
|
||||
//resp.Data.WorkMoment = respPb.WorkMoment
|
||||
resp.Data.WorkMoment = &apiStruct.WorkMoment{}
|
||||
if err := utils.CopyStructFields(&resp.Data.WorkMoment, respPb.WorkMoment); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
@@ -392,22 +210,10 @@ func GetWorkMomentByID(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 查询用户工作圈
|
||||
// @Description 查询用户工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID GetUserWorkMoments
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserWorkMomentsReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserWorkMomentsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_user_work_moments [post]
|
||||
func GetUserWorkMoments(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUserWorkMomentsReq
|
||||
resp api.GetUserWorkMomentsResp
|
||||
req apiStruct.GetUserWorkMomentsReq
|
||||
resp apiStruct.GetUserWorkMomentsResp
|
||||
reqPb pbOffice.GetUserWorkMomentsReq
|
||||
respPb *pbOffice.GetUserWorkMomentsResp
|
||||
)
|
||||
@@ -417,32 +223,19 @@ func GetUserWorkMoments(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var opUserID string
|
||||
ok, opUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||
PageNumber: req.PageNumber,
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
reqPb.OpUserID = opUserID
|
||||
reqPb.UserID = req.UserID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetUserWorkMoments(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -450,54 +243,11 @@ func GetUserWorkMoments(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserWorkMoments rpc server failed" + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.Data.WorkMoments = []*api.WorkMoment{}
|
||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
for _, v := range respPb.WorkMoments {
|
||||
workMoment := api.WorkMoment{
|
||||
WorkMomentID: v.WorkMomentID,
|
||||
UserID: v.UserID,
|
||||
Content: v.Content,
|
||||
FaceURL: v.FaceURL,
|
||||
UserName: v.UserName,
|
||||
CreateTime: v.CreateTime,
|
||||
Comments: make([]*api.Comment, len(v.Comments)),
|
||||
LikeUserList: make([]*api.WorkMomentUser, len(v.LikeUserList)),
|
||||
AtUserList: make([]*api.WorkMomentUser, len(v.AtUserList)),
|
||||
PermissionUserList: make([]*api.WorkMomentUser, len(v.PermissionUserList)),
|
||||
Permission: v.Permission,
|
||||
}
|
||||
for i, comment := range v.Comments {
|
||||
workMoment.Comments[i] = &api.Comment{
|
||||
UserID: comment.UserID,
|
||||
UserName: comment.UserName,
|
||||
ReplyUserID: comment.ReplyUserID,
|
||||
ReplyUserName: comment.ReplyUserName,
|
||||
ContentID: comment.ContentID,
|
||||
Content: comment.Content,
|
||||
CreateTime: comment.CreateTime,
|
||||
}
|
||||
}
|
||||
for i, likeUser := range v.LikeUserList {
|
||||
workMoment.LikeUserList[i] = &api.WorkMomentUser{
|
||||
UserID: likeUser.UserID,
|
||||
UserName: likeUser.UserName,
|
||||
}
|
||||
}
|
||||
for i, atUser := range v.AtUserList {
|
||||
workMoment.AtUserList[i] = &api.WorkMomentUser{
|
||||
UserID: atUser.UserID,
|
||||
UserName: atUser.UserName,
|
||||
}
|
||||
}
|
||||
for i, permissionUser := range v.PermissionUserList {
|
||||
workMoment.PermissionUserList[i] = &api.WorkMomentUser{
|
||||
UserID: permissionUser.UserID,
|
||||
UserName: permissionUser.UserName,
|
||||
}
|
||||
}
|
||||
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
|
||||
if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||
@@ -505,22 +255,10 @@ func GetUserWorkMoments(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 查询自己大工作圈页面
|
||||
// @Description 查询用户工作圈页面
|
||||
// @Tags 工作圈
|
||||
// @ID GetUserFriendWorkMoments
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserFriendWorkMomentsReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserFriendWorkMomentsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_user_friend_work_moments [post]
|
||||
func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUserFriendWorkMomentsReq
|
||||
resp api.GetUserFriendWorkMomentsResp
|
||||
req apiStruct.GetUserFriendWorkMomentsReq
|
||||
resp apiStruct.GetUserFriendWorkMomentsResp
|
||||
reqPb pbOffice.GetUserFriendWorkMomentsReq
|
||||
respPb *pbOffice.GetUserFriendWorkMomentsResp
|
||||
)
|
||||
@@ -530,31 +268,19 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||
PageNumber: req.PageNumber,
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetUserFriendWorkMoments(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -565,54 +291,8 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
||||
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
//}
|
||||
resp.Data.WorkMoments = []*api.WorkMoment{}
|
||||
for _, v := range respPb.WorkMoments {
|
||||
workMoment := api.WorkMoment{
|
||||
WorkMomentID: v.WorkMomentID,
|
||||
UserID: v.UserID,
|
||||
Content: v.Content,
|
||||
FaceURL: v.FaceURL,
|
||||
UserName: v.UserName,
|
||||
CreateTime: v.CreateTime,
|
||||
Comments: make([]*api.Comment, len(v.Comments)),
|
||||
LikeUserList: make([]*api.WorkMomentUser, len(v.LikeUserList)),
|
||||
AtUserList: make([]*api.WorkMomentUser, len(v.AtUserList)),
|
||||
PermissionUserList: make([]*api.WorkMomentUser, len(v.PermissionUserList)),
|
||||
Permission: v.Permission,
|
||||
}
|
||||
for i, comment := range v.Comments {
|
||||
workMoment.Comments[i] = &api.Comment{
|
||||
UserID: comment.UserID,
|
||||
UserName: comment.UserName,
|
||||
ReplyUserID: comment.ReplyUserID,
|
||||
ReplyUserName: comment.ReplyUserName,
|
||||
ContentID: comment.ContentID,
|
||||
Content: comment.Content,
|
||||
CreateTime: comment.CreateTime,
|
||||
}
|
||||
}
|
||||
for i, likeUser := range v.LikeUserList {
|
||||
workMoment.LikeUserList[i] = &api.WorkMomentUser{
|
||||
UserID: likeUser.UserID,
|
||||
UserName: likeUser.UserName,
|
||||
}
|
||||
}
|
||||
for i, atUser := range v.AtUserList {
|
||||
workMoment.AtUserList[i] = &api.WorkMomentUser{
|
||||
UserID: atUser.UserID,
|
||||
UserName: atUser.UserName,
|
||||
}
|
||||
}
|
||||
for i, permissionUser := range v.PermissionUserList {
|
||||
workMoment.PermissionUserList[i] = &api.WorkMomentUser{
|
||||
UserID: permissionUser.UserID,
|
||||
UserName: permissionUser.UserName,
|
||||
}
|
||||
}
|
||||
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
|
||||
if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||
@@ -622,8 +302,8 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
|
||||
func SetUserWorkMomentsLevel(c *gin.Context) {
|
||||
var (
|
||||
req api.SetUserWorkMomentsLevelReq
|
||||
resp api.SetUserWorkMomentsLevelResp
|
||||
req apiStruct.SetUserWorkMomentsLevelReq
|
||||
resp apiStruct.SetUserWorkMomentsLevelResp
|
||||
reqPb pbOffice.SetUserWorkMomentsLevelReq
|
||||
respPb *pbOffice.SetUserWorkMomentsLevelResp
|
||||
)
|
||||
@@ -633,29 +313,17 @@ func SetUserWorkMomentsLevel(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.SetUserWorkMomentsLevel(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
|
||||
@@ -16,18 +16,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 创建部门
|
||||
// @Description 创建部门
|
||||
// @Tags 组织架构相关
|
||||
// @ID CreateDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateDepartmentResp{data=open_im_sdk.Department}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/create_department [post]
|
||||
func CreateDepartment(c *gin.Context) {
|
||||
params := api.CreateDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -48,14 +36,7 @@ func CreateDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.CreateDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -71,18 +52,6 @@ func CreateDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 更新部门信息
|
||||
// @Description 更新部门信息
|
||||
// @Tags 组织架构相关
|
||||
// @ID UpdateDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UpdateDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UpdateDepartmentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/update_department [post]
|
||||
func UpdateDepartment(c *gin.Context) {
|
||||
params := api.UpdateDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -103,14 +72,7 @@ func UpdateDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.UpdateDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -125,18 +87,6 @@ func UpdateDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 获取子部门列表
|
||||
// @Description 获取子部门列表
|
||||
// @Tags 组织架构相关
|
||||
// @ID GetSubDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetSubDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetSubDepartmentResp{data=[]open_im_sdk.Department}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/get_sub_department [post]
|
||||
func GetSubDepartment(c *gin.Context) {
|
||||
params := api.GetSubDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -156,13 +106,7 @@ func GetSubDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.GetSubDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -182,18 +126,6 @@ func GetAllDepartment(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
// @Summary 删除部门
|
||||
// @Description 删除部门
|
||||
// @Tags 组织架构相关
|
||||
// @ID DeleteDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteDepartmentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/delete_department [post]
|
||||
func DeleteDepartment(c *gin.Context) {
|
||||
params := api.DeleteDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -212,13 +144,7 @@ func DeleteDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.DeleteDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -233,18 +159,6 @@ func DeleteDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 组织架构导入用户
|
||||
// @Description 组织架构导入用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID CreateOrganizationUser
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateOrganizationUserReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateOrganizationUserResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/create_organization_user [post]
|
||||
func CreateOrganizationUser(c *gin.Context) {
|
||||
params := api.CreateOrganizationUserReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -266,13 +180,7 @@ func CreateOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.CreateOrganizationUser(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -287,18 +195,6 @@ func CreateOrganizationUser(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 更新组织架构中的用户
|
||||
// @Description 更新组织架构中的用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID UpdateOrganizationUser
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UpdateOrganizationUserReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UpdateOrganizationUserResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/update_organization_user [post]
|
||||
func UpdateOrganizationUser(c *gin.Context) {
|
||||
params := api.UpdateOrganizationUserReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -319,13 +215,7 @@ func UpdateOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.UpdateOrganizationUser(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -334,23 +224,12 @@ func UpdateOrganizationUser(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
apiResp := api.UpdateOrganizationUserResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 创建部门用户
|
||||
// @Description 创建部门用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID CreateDepartmentMember
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateDepartmentMemberReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateDepartmentMemberResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/create_department_member [post]
|
||||
func CreateDepartmentMember(c *gin.Context) {
|
||||
params := api.CreateDepartmentMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -372,13 +251,7 @@ func CreateDepartmentMember(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.CreateDepartmentMember(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -393,18 +266,6 @@ func CreateDepartmentMember(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 获取部门中的所有用户
|
||||
// @Description 获取部门中的所有用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID GetUserInDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserInDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserInDepartmentResp{data=open_im_sdk.UserInDepartment}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/get_user_in_department [post]
|
||||
func GetUserInDepartment(c *gin.Context) {
|
||||
params := api.GetUserInDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -425,13 +286,7 @@ func GetUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.GetUserInDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -447,18 +302,6 @@ func GetUserInDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 更新部门中某个用户
|
||||
// @Description 更新部门中某个用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID UpdateUserInDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UpdateUserInDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UpdateUserInDepartmentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/update_user_in_department [post]
|
||||
func UpdateUserInDepartment(c *gin.Context) {
|
||||
params := api.UpdateUserInDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -479,13 +322,7 @@ func UpdateUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.UpdateUserInDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -500,18 +337,6 @@ func UpdateUserInDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 删除组织架构中某个用户
|
||||
// @Description 删除组织架构中某个用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID DeleteOrganizationUser
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteOrganizationUserReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteOrganizationUserResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/delete_organization_user [post]
|
||||
func DeleteOrganizationUser(c *gin.Context) {
|
||||
params := api.DeleteOrganizationUserReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -532,13 +357,7 @@ func DeleteOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.DeleteOrganizationUser(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -553,18 +372,6 @@ func DeleteOrganizationUser(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 获取部门中所有成员
|
||||
// @Description 获取部门中所有成员
|
||||
// @Tags 组织架构相关
|
||||
// @ID GetDepartmentMember
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetDepartmentMemberReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetDepartmentMemberResp{data=[]open_im_sdk.UserDepartmentMember}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/get_department_member [post]
|
||||
func GetDepartmentMember(c *gin.Context) {
|
||||
params := api.GetDepartmentMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -572,6 +379,7 @@ func GetDepartmentMember(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req := &rpc.GetDepartmentMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
@@ -584,13 +392,7 @@ func GetDepartmentMember(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.GetDepartmentMember(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -606,18 +408,6 @@ func GetDepartmentMember(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 删除部门中某个用户
|
||||
// @Description 删除部门中某个用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID DeleteUserInDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteUserInDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteUserInDepartmentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/delete_user_in_department [post]
|
||||
func DeleteUserInDepartment(c *gin.Context) {
|
||||
params := api.DeleteUserInDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -637,13 +427,7 @@ func DeleteUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.DeleteUserInDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
|
||||
@@ -54,18 +54,12 @@ func AliOSSCredential(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var userID string
|
||||
var errInfo string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "AliOSSCredential args ", userID)
|
||||
|
||||
stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{
|
||||
|
||||
@@ -5,14 +5,13 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
url2 "net/url"
|
||||
)
|
||||
|
||||
var (
|
||||
MinioClient *minio.Client
|
||||
minioClient *minio.Client
|
||||
)
|
||||
|
||||
func MinioInit() {
|
||||
@@ -30,16 +29,11 @@ func MinioInit() {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
||||
return
|
||||
}
|
||||
opts := &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||
}
|
||||
if minioUrl.Scheme == "http" {
|
||||
opts.Secure = false
|
||||
} else if minioUrl.Scheme == "https" {
|
||||
opts.Secure = true
|
||||
}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
|
||||
MinioClient, err = minio.New(minioUrl.Host, opts)
|
||||
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||
Secure: false,
|
||||
})
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
|
||||
@@ -49,47 +43,25 @@ func MinioInit() {
|
||||
Region: config.Config.Credential.Minio.Location,
|
||||
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 {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
||||
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
||||
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||
if err == nil && exists {
|
||||
log.NewInfo(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 {
|
||||
if err != nil {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
log.NewInfo(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.NewInfo(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
||||
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||
if err == nil && exists {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
||||
} else {
|
||||
if err != nil {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
|
||||
return
|
||||
}
|
||||
}
|
||||
// 自动化桶public的代码
|
||||
policyJsonString := fmt.Sprintf(`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],
|
||||
"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`, config.Config.Credential.Minio.Bucket)
|
||||
err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policyJsonString)
|
||||
if err != nil {
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
||||
}
|
||||
policyJsonString = fmt.Sprintf(`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],
|
||||
"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`, config.Config.Credential.Minio.AppBucket)
|
||||
err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.AppBucket, policyJsonString)
|
||||
if err != nil {
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
||||
}
|
||||
//err = minioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
|
||||
//if err != nil {
|
||||
// log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
||||
// return
|
||||
//}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
apiStruct "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
_ "Open_IM/pkg/common/token_verify"
|
||||
@@ -17,24 +16,10 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// @Summary minio上传文件(web api)
|
||||
// @Description minio上传文件(web api), 请注意本api请求为form并非json
|
||||
// @Tags 第三方服务相关
|
||||
// @ID MinioUploadFile
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param file formData file true "要上传的文件文件"
|
||||
// @Param fileType formData int true "文件类型"
|
||||
// @Param operationID formData string true "操作唯一ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.MinioUploadFileResp ""
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /third/minio_upload [post]
|
||||
func MinioUploadFile(c *gin.Context) {
|
||||
var (
|
||||
req api.MinioUploadFileReq
|
||||
resp api.MinioUploadFile
|
||||
req apiStruct.MinioUploadFileReq
|
||||
resp apiStruct.MinioUploadFileResp
|
||||
)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -48,17 +33,12 @@ func MinioUploadFile(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
switch req.FileType {
|
||||
// videoType upload snapShot
|
||||
@@ -76,7 +56,7 @@ func MinioUploadFile(c *gin.Context) {
|
||||
}
|
||||
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
|
||||
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 {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
@@ -87,7 +67,6 @@ func MinioUploadFile(c *gin.Context) {
|
||||
}
|
||||
file, err := c.FormFile("file")
|
||||
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()})
|
||||
return
|
||||
}
|
||||
@@ -98,11 +77,11 @@ func MinioUploadFile(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
|
||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, newType, MinioClient.EndpointURL())
|
||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: 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})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "upload file error", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "upload file error" + err.Error()})
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.NewName = newName
|
||||
@@ -114,25 +93,20 @@ func MinioUploadFile(c *gin.Context) {
|
||||
|
||||
func MinioStorageCredential(c *gin.Context) {
|
||||
var (
|
||||
req api.MinioStorageCredentialReq
|
||||
resp api.MiniostorageCredentialResp
|
||||
req apiStruct.MinioStorageCredentialReq
|
||||
resp apiStruct.MiniostorageCredentialResp
|
||||
)
|
||||
if err := c.BindJSON(&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)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
var stsOpts cr.STSAssumeRoleOptions
|
||||
stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID
|
||||
stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey
|
||||
@@ -162,98 +136,3 @@ func MinioStorageCredential(c *gin.Context) {
|
||||
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
|
||||
func UploadUpdateApp(c *gin.Context) {
|
||||
var (
|
||||
req api.UploadUpdateAppReq
|
||||
resp api.UploadUpdateAppResp
|
||||
)
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError(req.OperationID, 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)
|
||||
var yamlName string
|
||||
if req.Yaml == nil {
|
||||
yamlName = ""
|
||||
} else {
|
||||
yamlName = req.Yaml.Filename
|
||||
}
|
||||
fileObj, err := req.File.Open()
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open file error" + err.Error()})
|
||||
return
|
||||
}
|
||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, req.File.Filename, fileObj, req.File.Size, minio.PutObjectOptions{})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject file error")
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject file error" + err.Error()})
|
||||
return
|
||||
}
|
||||
if yamlName != "" {
|
||||
yamlObj, err := req.Yaml.Open()
|
||||
if err == nil {
|
||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, yamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject yaml error")
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject yaml error" + err.Error()})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
}
|
||||
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate, req.File.Filename, yamlName, req.UpdateLog); 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 api.GetDownloadURLReq
|
||||
resp api.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)
|
||||
app, err := imdb.GetNewestVersion(req.Type)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
|
||||
}
|
||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "app: ", app)
|
||||
if app != nil {
|
||||
if app.Version != req.Version && app.Version != "" {
|
||||
resp.Data.HasNewVersion = true
|
||||
if app.ForceUpdate == true {
|
||||
resp.Data.ForceUpdate = true
|
||||
}
|
||||
if app.YamlName != "" {
|
||||
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
|
||||
}
|
||||
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
|
||||
resp.Data.Version = app.Version
|
||||
resp.Data.UpdateLog = app.UpdateLog
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
} else {
|
||||
resp.Data.HasNewVersion = false
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 0, "errMsg": "not found app version"})
|
||||
}
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetRTCInvitationInfo(c *gin.Context) {
|
||||
var (
|
||||
req api.GetRTCInvitationInfoReq
|
||||
resp api.GetRTCInvitationInfoResp
|
||||
)
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError(req.OperationID, 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)
|
||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
var err error
|
||||
invitationInfo, err := db.DB.GetSignalInfoFromCacheByClientMsgID(req.ClientMsgID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSignalInfoFromCache", err.Error(), req)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if err := db.DB.DelUserSignalList(userID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelUserSignalList result:", err.Error())
|
||||
}
|
||||
|
||||
resp.Data.OpUserID = invitationInfo.OpUserID
|
||||
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
|
||||
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType
|
||||
resp.Data.Invitation.GroupID = invitationInfo.Invitation.GroupID
|
||||
resp.Data.Invitation.InviterUserID = invitationInfo.Invitation.InviterUserID
|
||||
resp.Data.Invitation.InviteeUserIDList = invitationInfo.Invitation.InviteeUserIDList
|
||||
resp.Data.Invitation.MediaType = invitationInfo.Invitation.MediaType
|
||||
resp.Data.Invitation.Timeout = invitationInfo.Invitation.Timeout
|
||||
resp.Data.Invitation.InitiateTime = invitationInfo.Invitation.InitiateTime
|
||||
resp.Data.Invitation.PlatformID = invitationInfo.Invitation.PlatformID
|
||||
resp.Data.Invitation.CustomData = invitationInfo.Invitation.CustomData
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetRTCInvitationInfoStartApp(c *gin.Context) {
|
||||
var (
|
||||
req api.GetRTCInvitationInfoStartAppReq
|
||||
resp api.GetRTCInvitationInfoStartAppResp
|
||||
)
|
||||
if err := c.Bind(&req); err != nil {
|
||||
log.NewError(req.OperationID, 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)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
invitationInfo, err := db.DB.GetAvailableSignalInvitationInfo(userID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSignalInfoFromCache", err.Error(), req)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": err.Error(), "data": struct{}{}})
|
||||
return
|
||||
}
|
||||
resp.Data.OpUserID = invitationInfo.OpUserID
|
||||
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
|
||||
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType
|
||||
resp.Data.Invitation.GroupID = invitationInfo.Invitation.GroupID
|
||||
resp.Data.Invitation.InviterUserID = invitationInfo.Invitation.InviterUserID
|
||||
resp.Data.Invitation.InviteeUserIDList = invitationInfo.Invitation.InviteeUserIDList
|
||||
resp.Data.Invitation.MediaType = invitationInfo.Invitation.MediaType
|
||||
resp.Data.Invitation.Timeout = invitationInfo.Invitation.Timeout
|
||||
resp.Data.Invitation.InitiateTime = invitationInfo.Invitation.InitiateTime
|
||||
resp.Data.Invitation.PlatformID = invitationInfo.Invitation.PlatformID
|
||||
resp.Data.Invitation.CustomData = invitationInfo.Invitation.CustomData
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
@@ -22,18 +22,12 @@ func TencentCloudStorageCredential(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var userID string
|
||||
var errInfo string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID)
|
||||
|
||||
cli := sts.NewClient(
|
||||
|
||||
+17
-275
@@ -8,7 +8,6 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
cacheRpc "Open_IM/pkg/proto/cache"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
@@ -19,146 +18,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
log.NewInfo(params.OperationID, "GetUsersInfoFromCache req: ", params)
|
||||
req := &rpc.GetUserInfoReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetUserInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
var publicUserInfoList []*open_im_sdk.PublicUserInfo
|
||||
for _, v := range RpcResp.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(req.OperationID, "GetUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetFriendIDListFromCache(c *gin.Context) {
|
||||
var (
|
||||
req api.GetFriendIDListFromCacheReq
|
||||
resp api.GetFriendIDListFromCacheResp
|
||||
reqPb cacheRpc.GetFriendIDListFromCacheReq
|
||||
respPb *cacheRpc.GetFriendIDListFromCacheResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||
reqPb.OperationID = req.OperationID
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := cacheRpc.NewCacheClient(etcdConn)
|
||||
respPb, err := client.GetFriendIDListFromCache(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.UserIDList = respPb.UserIDList
|
||||
resp.CommResp = api.CommResp{ErrMsg: respPb.CommonResp.ErrMsg, ErrCode: respPb.CommonResp.ErrCode}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetBlackIDListFromCache(c *gin.Context) {
|
||||
var (
|
||||
req api.GetBlackIDListFromCacheReq
|
||||
resp api.GetBlackIDListFromCacheResp
|
||||
reqPb cacheRpc.GetBlackIDListFromCacheReq
|
||||
respPb *cacheRpc.GetBlackIDListFromCacheResp
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.OperationID = req.OperationID
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := cacheRpc.NewCacheClient(etcdConn)
|
||||
respPb, err := client.GetBlackIDListFromCache(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.UserIDList = respPb.UserIDList
|
||||
resp.CommResp = api.CommResp{ErrMsg: respPb.CommonResp.ErrMsg, ErrCode: respPb.CommonResp.ErrCode}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取用户信息
|
||||
// @Description 根据用户列表批量获取用户信息
|
||||
// @Tags 用户相关
|
||||
// @ID GetUsersInfo
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUsersInfoReq true "请求体"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUsersInfoResp{Data=[]open_im_sdk.PublicUserInfo}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/get_users_info [post]
|
||||
func GetUsersInfo(c *gin.Context) {
|
||||
params := api.GetUsersInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -168,26 +27,16 @@ func GetUsersInfo(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetUserInfoReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.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 ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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(), req)
|
||||
if err != nil {
|
||||
@@ -207,18 +56,6 @@ func GetUsersInfo(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 修改用户信息
|
||||
// @Description 修改用户信息 userID faceURL等
|
||||
// @Tags 用户相关
|
||||
// @ID UpdateUserInfo
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UpdateSelfUserInfoReq true "请求体"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UpdateUserInfoResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/update_user_info [post]
|
||||
func UpdateUserInfo(c *gin.Context) {
|
||||
params := api.UpdateSelfUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -228,24 +65,18 @@ func UpdateUserInfo(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.UpdateUserInfoReq{UserInfo: &open_im_sdk.UserInfo{}}
|
||||
utils.CopyStructFields(req.UserInfo, ¶ms)
|
||||
|
||||
req.OperationID = params.OperationID
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.UpdateUserInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -258,69 +89,6 @@ func UpdateUserInfo(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 设置全局免打扰
|
||||
// @Description 设置全局免打扰
|
||||
// @Tags 用户相关
|
||||
// @ID SetGlobalRecvMessageOpt
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.SetGlobalRecvMessageOptReq true "globalRecvMsgOpt为全局免打扰设置0为关闭 1为开启"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.SetGlobalRecvMessageOptResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/set_global_msg_recv_opt [post]
|
||||
func SetGlobalRecvMessageOpt(c *gin.Context) {
|
||||
params := api.SetGlobalRecvMessageOptReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.SetGlobalRecvMessageOptReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
req.OperationID = params.OperationID
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "SetGlobalRecvMessageOpt args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.SetGlobalRecvMessageOpt(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "SetGlobalRecvMessageOpt failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.UpdateUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "SetGlobalRecvMessageOpt api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取自己的信息
|
||||
// @Description 传入ID获取自己的信息
|
||||
// @Tags 用户相关
|
||||
// @ID GetSelfUserInfo
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetSelfUserInfoReq true "请求体"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetSelfUserInfoResp{data=open_im_sdk.UserInfo}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/get_self_user_info [post]
|
||||
func GetSelfUserInfo(c *gin.Context) {
|
||||
params := api.GetSelfUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -331,27 +99,17 @@ func GetSelfUserInfo(c *gin.Context) {
|
||||
req := &rpc.GetUserInfoReq{}
|
||||
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
req.UserIDList = append(req.UserIDList, req.OpUserID)
|
||||
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, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
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(), req)
|
||||
if err != nil {
|
||||
@@ -372,18 +130,6 @@ func GetSelfUserInfo(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
// @Summary 获取用户在线状态
|
||||
// @Description 获取用户在线状态
|
||||
// @Tags 用户相关
|
||||
// @ID GetUsersOnlineStatus
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUsersOnlineStatusReq true "请求体"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUsersOnlineStatusResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/get_users_online_status [post]
|
||||
func GetUsersOnlineStatus(c *gin.Context) {
|
||||
params := api.GetUsersOnlineStatusReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -392,17 +138,13 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
}
|
||||
req := &pbRelay.GetUsersOnlineStatusReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if len(config.Config.Manager.AppManagerUid) == 0 {
|
||||
log.NewError(req.OperationID, "Manager == 0")
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "Manager == 0"})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
apiStruct "Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
@@ -10,56 +10,16 @@ import (
|
||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
url2 "net/url"
|
||||
)
|
||||
|
||||
var (
|
||||
minioClient *minio.Client
|
||||
)
|
||||
|
||||
func init() {
|
||||
operationID := utils.OperationIDGenerator()
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
|
||||
var initUrl string
|
||||
if config.Config.Credential.Minio.EndpointInnerEnable {
|
||||
initUrl = config.Config.Credential.Minio.EndpointInner
|
||||
} else {
|
||||
initUrl = config.Config.Credential.Minio.Endpoint
|
||||
}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "use initUrl: ", initUrl)
|
||||
minioUrl, err := url2.Parse(initUrl)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
||||
return
|
||||
}
|
||||
opts := &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||
}
|
||||
if minioUrl.Scheme == "http" {
|
||||
opts.Secure = false
|
||||
} else if minioUrl.Scheme == "https" {
|
||||
opts.Secure = true
|
||||
}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
|
||||
minioClient, err = minio.New(minioUrl.Host, opts)
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// register
|
||||
func AdminLogin(c *gin.Context) {
|
||||
var (
|
||||
req apiStruct.AdminLoginRequest
|
||||
resp apiStruct.AdminLoginResponse
|
||||
req cms_api_struct.AdminLoginRequest
|
||||
resp cms_api_struct.AdminLoginResponse
|
||||
reqPb pbAdmin.AdminLoginReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
@@ -69,14 +29,7 @@ func AdminLogin(c *gin.Context) {
|
||||
}
|
||||
reqPb.Secret = req.Secret
|
||||
reqPb.AdminID = req.AdminName
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName)
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
|
||||
+17
-146
@@ -10,7 +10,6 @@ import (
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
@@ -29,16 +28,8 @@ func GetGroupById(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroupById(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -53,7 +44,6 @@ func GetGroupById(c *gin.Context) {
|
||||
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
||||
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
||||
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
@@ -68,17 +58,9 @@ func GetGroups(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroups(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -101,7 +83,6 @@ func GetGroups(c *gin.Context) {
|
||||
resp.GroupNums = int(respPb.GroupNum)
|
||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
@@ -116,18 +97,10 @@ func GetGroupByName(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupName = req.GroupName
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -150,7 +123,6 @@ func GetGroupByName(c *gin.Context) {
|
||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.GroupNums = int(respPb.GroupNums)
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
@@ -165,8 +137,6 @@ func CreateGroup(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
||||
reqPb.GroupInfo.GroupName = req.GroupName
|
||||
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
||||
@@ -178,13 +148,7 @@ func CreateGroup(c *gin.Context) {
|
||||
RoleLevel: 1,
|
||||
})
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.CreateGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -205,18 +169,9 @@ func BanGroupChat(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupBanChat
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -238,17 +193,9 @@ func BanPrivateChat(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupBanPrivateChat
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -269,17 +216,9 @@ func OpenGroupChat(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupOk
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -300,18 +239,9 @@ func OpenPrivateChat(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupOk
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -333,21 +263,13 @@ func GetGroupMembers(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.Pagination = &commonPb.RequestPagination{
|
||||
PageNumber: int32(req.PageNumber),
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.UserName = req.UserName
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -368,7 +290,6 @@ func GetGroupMembers(c *gin.Context) {
|
||||
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
|
||||
})
|
||||
}
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
@@ -383,17 +304,9 @@ func AddGroupMembers(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationId = utils.OperationIDGenerator()
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.UserIds = req.Members
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationId)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationId + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationId, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -403,7 +316,6 @@ func AddGroupMembers(c *gin.Context) {
|
||||
}
|
||||
resp.Success = respPb.Success
|
||||
resp.Failed = respPb.Failed
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
@@ -418,17 +330,9 @@ func RemoveGroupMembers(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.UserIds = req.Members
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.RemoveGroupMembersCMS(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -438,7 +342,6 @@ func RemoveGroupMembers(c *gin.Context) {
|
||||
}
|
||||
resp.Success = respPb.Success
|
||||
resp.Failed = respPb.Failed
|
||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
@@ -453,16 +356,8 @@ func DeleteGroup(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.DeleteGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -484,18 +379,10 @@ func SetGroupMaster(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.UserId = req.UserId
|
||||
reqPb.RoleLevel = constant.GroupOwner
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -517,18 +404,10 @@ func SetGroupOrdinaryUsers(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.UserId = req.UserId
|
||||
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -545,29 +424,21 @@ func AlterGroupInfo(c *gin.Context) {
|
||||
_ cms_api_struct.SetGroupMasterResponse
|
||||
reqPb pbGroup.SetGroupInfoReq
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.OpUserID = c.MustGet("userID").(string)
|
||||
reqPb.GroupInfoForSet = &commonPb.GroupInfoForSet{
|
||||
reqPb.GroupInfo = &commonPb.GroupInfo{
|
||||
GroupID: req.GroupID,
|
||||
GroupName: req.GroupName,
|
||||
Introduction: req.Introduction,
|
||||
Notification: req.Notification,
|
||||
FaceURL: req.ProfilePhoto,
|
||||
// GroupType: int32(req.GroupType),
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
GroupType: int32(req.GroupType),
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.SetGroupInfo(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"Open_IM/pkg/common/constant"
|
||||
@@ -22,14 +21,7 @@ func BroadcastMessage(c *gin.Context) {
|
||||
var (
|
||||
reqPb pbMessage.BoradcastMessageReq
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
_, err := client.BoradcastMessage(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -44,14 +36,7 @@ func MassSendMassage(c *gin.Context) {
|
||||
var (
|
||||
reqPb pbMessage.MassSendMessageReq
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
_, err := client.MassSendMessage(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -66,14 +51,7 @@ func WithdrawMessage(c *gin.Context) {
|
||||
var (
|
||||
reqPb pbMessage.WithdrawMessageReq
|
||||
)
|
||||
reqPb.OperationID = utils.OperationIDGenerator()
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
_, err := client.WithdrawMessage(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -100,14 +78,7 @@ func GetChatLogs(c *gin.Context) {
|
||||
ShowNumber: int32(req.ShowNumber),
|
||||
}
|
||||
utils.CopyStructFields(&reqPb, &req)
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(reqPb.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -134,6 +105,5 @@ func GetChatLogs(c *gin.Context) {
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp", resp)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user