Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhaominxu
Open-IM-Server
提交
e94dbe49
O
Open-IM-Server
项目概览
zhaominxu
/
Open-IM-Server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Open-IM-Server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e94dbe49
编写于
2月 07, 2022
作者:
W
wangchuxiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cms dev
上级
a7f9faf8
变更
13
展开全部
显示空白变更内容
内联
并排
Showing
13 changed file
with
1387 addition
and
430 deletion
+1387
-430
internal/api/group/group.go
internal/api/group/group.go
+0
-2
internal/cms_api/group/group.go
internal/cms_api/group/group.go
+126
-46
internal/cms_api/router.go
internal/cms_api/router.go
+5
-8
internal/rpc/group/group.go
internal/rpc/group/group.go
+113
-21
internal/rpc/user/user.go
internal/rpc/user/user.go
+1
-1
pkg/cms_api_struct/group.go
pkg/cms_api_struct/group.go
+29
-3
pkg/common/constant/constant.go
pkg/common/constant/constant.go
+2
-4
pkg/common/db/mysql_model/im_mysql_model/group_member_model.go
...ommon/db/mysql_model/im_mysql_model/group_member_model.go
+13
-0
pkg/common/db/mysql_model/im_mysql_model/group_model.go
pkg/common/db/mysql_model/im_mysql_model/group_model.go
+21
-3
pkg/common/db/mysql_model/im_mysql_model/user_model.go
pkg/common/db/mysql_model/im_mysql_model/user_model.go
+1
-1
pkg/proto/group/group.pb.go
pkg/proto/group/group.pb.go
+1029
-336
pkg/proto/group/group.proto
pkg/proto/group/group.proto
+45
-3
pkg/proto/proto_dir.cfg
pkg/proto/proto_dir.cfg
+2
-2
未找到文件。
internal/api/group/group.go
浏览文件 @
e94dbe49
...
@@ -331,7 +331,6 @@ func GetGroupsInfo(c *gin.Context) {
...
@@ -331,7 +331,6 @@ func GetGroupsInfo(c *gin.Context) {
return
return
}
}
log
.
NewInfo
(
req
.
OperationID
,
"GetGroupsInfo args "
,
req
.
String
())
log
.
NewInfo
(
req
.
OperationID
,
"GetGroupsInfo args "
,
req
.
String
())
etcdConn
:=
getcdv3
.
GetConn
(
config
.
Config
.
Etcd
.
EtcdSchema
,
strings
.
Join
(
config
.
Config
.
Etcd
.
EtcdAddr
,
","
),
config
.
Config
.
RpcRegisterName
.
OpenImGroupName
)
etcdConn
:=
getcdv3
.
GetConn
(
config
.
Config
.
Etcd
.
EtcdSchema
,
strings
.
Join
(
config
.
Config
.
Etcd
.
EtcdAddr
,
","
),
config
.
Config
.
RpcRegisterName
.
OpenImGroupName
)
client
:=
rpc
.
NewGroupClient
(
etcdConn
)
client
:=
rpc
.
NewGroupClient
(
etcdConn
)
RpcResp
,
err
:=
client
.
GetGroupsInfo
(
context
.
Background
(),
req
)
RpcResp
,
err
:=
client
.
GetGroupsInfo
(
context
.
Background
(),
req
)
...
@@ -504,5 +503,4 @@ func TransferGroupOwner(c *gin.Context) {
...
@@ -504,5 +503,4 @@ func TransferGroupOwner(c *gin.Context) {
resp
:=
api
.
TransferGroupOwnerResp
{
CommResp
:
api
.
CommResp
{
ErrCode
:
reply
.
CommonResp
.
ErrCode
,
ErrMsg
:
reply
.
CommonResp
.
ErrMsg
}}
resp
:=
api
.
TransferGroupOwnerResp
{
CommResp
:
api
.
CommResp
{
ErrCode
:
reply
.
CommonResp
.
ErrCode
,
ErrMsg
:
reply
.
CommonResp
.
ErrMsg
}}
log
.
NewInfo
(
req
.
OperationID
,
"TransferGroupOwner api return "
,
resp
)
log
.
NewInfo
(
req
.
OperationID
,
"TransferGroupOwner api return "
,
resp
)
c
.
JSON
(
http
.
StatusOK
,
resp
)
c
.
JSON
(
http
.
StatusOK
,
resp
)
}
}
internal/cms_api/group/group.go
浏览文件 @
e94dbe49
...
@@ -25,24 +25,25 @@ func GetGroupById(c *gin.Context) {
...
@@ -25,24 +25,25 @@ func GetGroupById(c *gin.Context) {
reqPb
pbGroup
.
GetGroupByIdReq
reqPb
pbGroup
.
GetGroupByIdReq
)
)
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
log
.
NewError
(
"0"
,
"ShouldBindQuery failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
"ShouldBindQuery failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
return
return
}
}
reqPb
.
GroupId
=
req
.
GroupId
etcdConn
:=
getcdv3
.
GetConn
(
config
.
Config
.
Etcd
.
EtcdSchema
,
strings
.
Join
(
config
.
Config
.
Etcd
.
EtcdAddr
,
","
),
config
.
Config
.
RpcRegisterName
.
OpenImGroupName
)
etcdConn
:=
getcdv3
.
GetConn
(
config
.
Config
.
Etcd
.
EtcdSchema
,
strings
.
Join
(
config
.
Config
.
Etcd
.
EtcdAddr
,
","
),
config
.
Config
.
RpcRegisterName
.
OpenImGroupName
)
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
respPb
,
err
:=
client
.
GetGroupById
(
context
.
Background
(),
&
reqPb
)
respPb
,
err
:=
client
.
GetGroupById
(
context
.
Background
(),
&
reqPb
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
NewError
(
utils
.
GetSelfFuncName
(),
"GetGroupById failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"GetGroupById failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
return
}
}
resp
.
Group
MasterId
=
respPb
.
GroupInfo
.
OwnerUserID
resp
.
Group
Name
=
respPb
.
CMSGroup
.
GroupInfo
.
GroupName
resp
.
Group
Name
=
respPb
.
GroupInfo
.
GroupName
resp
.
Group
ID
=
respPb
.
CMSGroup
.
GroupInfo
.
GroupID
resp
.
GroupID
=
respPb
.
GroupInfo
.
GroupID
resp
.
CreateTime
=
(
utils
.
UnixSecondToTime
(
int64
(
respPb
.
CMSGroup
.
GroupInfo
.
CreateTime
)))
.
String
()
resp
.
CreateTime
=
(
utils
.
UnixSecondToTime
(
int64
(
respPb
.
GroupInfo
.
CreateTime
)))
.
String
()
resp
.
ProfilePhoto
=
respPb
.
CMSGroup
.
GroupInfo
.
FaceURL
resp
.
ProfilePhoto
=
respPb
.
GroupInfo
.
FaceURL
resp
.
GroupMasterName
=
respPb
.
CMSGroup
.
GroupMasterName
resp
.
GroupMaster
Name
=
respPb
.
GroupInfo
.
OwnerUserID
resp
.
GroupMaster
Id
=
respPb
.
CMSGroup
.
GroupMasterId
openIMHttp
.
RespHttp200
(
c
,
constant
.
OK
,
resp
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
OK
,
resp
)
}
}
...
@@ -53,7 +54,7 @@ func GetGroups(c *gin.Context) {
...
@@ -53,7 +54,7 @@ func GetGroups(c *gin.Context) {
reqPb
pbGroup
.
GetGroupsReq
reqPb
pbGroup
.
GetGroupsReq
)
)
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
log
.
NewError
(
"0"
,
"ShouldBindQuery failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
()
,
"ShouldBindQuery failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
return
return
}
}
...
@@ -63,20 +64,20 @@ func GetGroups(c *gin.Context) {
...
@@ -63,20 +64,20 @@ func GetGroups(c *gin.Context) {
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
respPb
,
err
:=
client
.
GetGroups
(
context
.
Background
(),
&
reqPb
)
respPb
,
err
:=
client
.
GetGroups
(
context
.
Background
(),
&
reqPb
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
NewError
(
"s"
,
"GetUserInfo failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
"GetUserInfo failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
return
}
}
for
_
,
v
:=
range
respPb
.
GroupInfo
{
for
_
,
v
:=
range
respPb
.
CMSGroups
{
resp
.
Groups
=
append
(
resp
.
Groups
,
cms_api_struct
.
GroupResponse
{
resp
.
Groups
=
append
(
resp
.
Groups
,
cms_api_struct
.
GroupResponse
{
GroupName
:
v
.
GroupName
,
GroupName
:
v
.
Group
Info
.
Group
Name
,
GroupID
:
v
.
GroupID
,
GroupID
:
v
.
GroupI
nfo
.
GroupI
D
,
GroupMasterName
:
v
.
OwnerUserID
,
GroupMasterName
:
v
.
GroupMasterName
,
GroupMasterId
:
v
.
OwnerUserID
,
GroupMasterId
:
v
.
GroupMasterId
,
CreateTime
:
(
utils
.
UnixSecondToTime
(
int64
(
v
.
CreateTime
)))
.
String
(),
CreateTime
:
(
utils
.
UnixSecondToTime
(
int64
(
v
.
GroupInfo
.
CreateTime
)))
.
String
(),
IsBanChat
:
false
,
IsBanChat
:
false
,
IsBanPrivateChat
:
false
,
IsBanPrivateChat
:
false
,
ProfilePhoto
:
v
.
FaceURL
,
ProfilePhoto
:
v
.
GroupInfo
.
FaceURL
,
})
})
}
}
resp
.
GroupNums
=
int
(
respPb
.
GroupNum
)
resp
.
GroupNums
=
int
(
respPb
.
GroupNum
)
...
@@ -108,16 +109,16 @@ func GetGroupByName(c *gin.Context) {
...
@@ -108,16 +109,16 @@ func GetGroupByName(c *gin.Context) {
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
return
}
}
for
_
,
v
:=
range
respPb
.
GroupInfo
{
for
_
,
v
:=
range
respPb
.
CMSGroups
{
resp
.
Groups
=
append
(
resp
.
Groups
,
cms_api_struct
.
GroupResponse
{
resp
.
Groups
=
append
(
resp
.
Groups
,
cms_api_struct
.
GroupResponse
{
GroupName
:
v
.
GroupName
,
GroupName
:
v
.
Group
Info
.
Group
Name
,
GroupID
:
v
.
GroupID
,
GroupID
:
v
.
GroupI
nfo
.
GroupI
D
,
GroupMasterName
:
v
.
OwnerUserID
,
GroupMasterName
:
v
.
GroupMasterName
,
GroupMasterId
:
v
.
OwnerUserID
,
GroupMasterId
:
v
.
GroupMasterId
,
CreateTime
:
(
utils
.
UnixSecondToTime
(
int64
(
v
.
CreateTime
)))
.
String
(),
CreateTime
:
(
utils
.
UnixSecondToTime
(
int64
(
v
.
GroupInfo
.
CreateTime
)))
.
String
(),
IsBanChat
:
false
,
IsBanChat
:
false
,
IsBanPrivateChat
:
false
,
IsBanPrivateChat
:
false
,
ProfilePhoto
:
v
.
FaceURL
,
ProfilePhoto
:
v
.
GroupInfo
.
FaceURL
,
})
})
}
}
resp
.
CurrentPage
=
int
(
respPb
.
Pagination
.
PageNumber
)
resp
.
CurrentPage
=
int
(
respPb
.
Pagination
.
PageNumber
)
...
@@ -132,7 +133,7 @@ func CreateGroup(c *gin.Context) {
...
@@ -132,7 +133,7 @@ func CreateGroup(c *gin.Context) {
reqPb
pbGroup
.
CreateGroupReq
reqPb
pbGroup
.
CreateGroupReq
)
)
if
err
:=
c
.
BindJSON
(
&
req
);
err
!=
nil
{
if
err
:=
c
.
BindJSON
(
&
req
);
err
!=
nil
{
log
.
NewError
(
"0"
,
"ShouldBindQuery
failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"BindJSON
failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
return
return
}
}
...
@@ -149,7 +150,7 @@ func CreateGroup(c *gin.Context) {
...
@@ -149,7 +150,7 @@ func CreateGroup(c *gin.Context) {
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
_
,
err
:=
client
.
CreateGroup
(
context
.
Background
(),
&
reqPb
)
_
,
err
:=
client
.
CreateGroup
(
context
.
Background
(),
&
reqPb
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
NewError
(
"s"
,
"GetUserInfo failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
"GetUserInfo failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
return
}
}
...
@@ -162,7 +163,7 @@ func BanGroupChat(c *gin.Context) {
...
@@ -162,7 +163,7 @@ func BanGroupChat(c *gin.Context) {
reqPb
pbGroup
.
OperateGroupStatusReq
reqPb
pbGroup
.
OperateGroupStatusReq
)
)
if
err
:=
c
.
BindJSON
(
&
req
);
err
!=
nil
{
if
err
:=
c
.
BindJSON
(
&
req
);
err
!=
nil
{
log
.
NewError
(
"0"
,
"ShouldBindQuery failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
"ShouldBindQuery failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
return
return
}
}
...
@@ -172,7 +173,7 @@ func BanGroupChat(c *gin.Context) {
...
@@ -172,7 +173,7 @@ func BanGroupChat(c *gin.Context) {
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
_
,
err
:=
client
.
OperateGroupStatus
(
context
.
Background
(),
&
reqPb
)
_
,
err
:=
client
.
OperateGroupStatus
(
context
.
Background
(),
&
reqPb
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
NewError
(
"s"
,
"GetUserInfo failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
"GetUserInfo failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
return
}
}
...
@@ -242,41 +243,120 @@ func OpenPrivateChat(c *gin.Context) {
...
@@ -242,41 +243,120 @@ func OpenPrivateChat(c *gin.Context) {
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
client
:=
pbGroup
.
NewGroupClient
(
etcdConn
)
_
,
err
:=
client
.
OperateGroupStatus
(
context
.
Background
(),
&
reqPb
)
_
,
err
:=
client
.
OperateGroupStatus
(
context
.
Background
(),
&
reqPb
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
NewError
(
"s"
,
"GetUserInfo failed "
,
err
.
Error
())
log
.
NewError
(
reqPb
.
OperationID
,
"GetUserInfo failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
return
}
}
openIMHttp
.
RespHttp200
(
c
,
constant
.
OK
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
OK
,
nil
)
}
}
func
GetGroup
sMember
(
c
*
gin
.
Context
)
{
func
GetGroup
Members
(
c
*
gin
.
Context
)
{
var
(
var
(
req
cms_api_struct
.
GetGroupMembersRequest
req
cms_api_struct
.
GetGroupMembersRequest
_
cms_api_struct
.
GetGroupMembersResponse
reqPb
pbGroup
.
GetGroupMembersCMSReq
resp
cms_api_struct
.
GetGroupMembersResponse
)
)
if
err
:=
c
.
BindJSON
(
&
req
);
err
!=
nil
{
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
log
.
NewError
(
"0"
,
"BindJSON failed "
,
err
.
Error
())
log
.
NewError
(
"0"
,
"BindJSON failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
return
return
}
}
reqPb
.
Pagination
=
&
commonPb
.
RequestPagination
{
PageNumber
:
int32
(
req
.
PageNumber
),
ShowNumber
:
int32
(
req
.
ShowNumber
),
}
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
{
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"rpc:"
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
}
resp
.
ResponsePagination
.
ShowNumber
=
int
(
respPb
.
Pagination
.
ShowNumber
)
resp
.
ResponsePagination
.
CurrentPage
=
int
(
respPb
.
Pagination
.
PageNumber
)
for
_
,
groupMembers
:=
range
respPb
.
Members
{
resp
.
GroupMembers
=
append
(
resp
.
GroupMembers
,
cms_api_struct
.
GroupMemberResponse
{
MemberPosition
:
int
(
groupMembers
.
RoleLevel
),
MemberNickName
:
groupMembers
.
Nickname
,
MemberId
:
groupMembers
.
UserID
,
JoinTime
:
utils
.
UnixSecondToTime
(
groupMembers
.
JoinTime
)
.
String
(),
})
}
openIMHttp
.
RespHttp200
(
c
,
constant
.
OK
,
resp
)
}
}
func
InquireGroup
(
c
*
gin
.
Context
)
{
}
func
AddMembers
(
c
*
gin
.
Context
)
{
}
func
RemoveUser
(
c
*
gin
.
Context
)
{
func
AddGroupMembers
(
c
*
gin
.
Context
)
{
var
(
req
cms_api_struct
.
RemoveGroupMembersRequest
resp
cms_api_struct
.
RemoveGroupMembersResponse
reqPb
pbGroup
.
AddGroupMembersCMSReq
)
if
err
:=
c
.
BindJSON
(
&
req
);
err
!=
nil
{
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"BindJSON failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
return
}
reqPb
.
UserIds
=
req
.
Members
reqPb
.
GroupId
=
req
.
GroupId
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
{
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"rpc:"
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
}
resp
.
Success
=
respPb
.
Success
resp
.
Failed
=
respPb
.
Failed
openIMHttp
.
RespHttp200
(
c
,
constant
.
OK
,
resp
)
}
}
func
Withdraw
(
c
*
gin
.
Context
)
{
func
RemoveGroupMembers
(
c
*
gin
.
Context
)
{
var
(
req
cms_api_struct
.
RemoveGroupMembersRequest
resp
cms_api_struct
.
RemoveGroupMembersResponse
reqPb
pbGroup
.
RemoveGroupMembersCMSReq
)
if
err
:=
c
.
BindJSON
(
&
req
);
err
!=
nil
{
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"BindJSON failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
return
}
reqPb
.
UserIds
=
req
.
Members
reqPb
.
GroupId
=
req
.
GroupId
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
{
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"rpc:"
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
}
resp
.
Success
=
respPb
.
Success
resp
.
Failed
=
respPb
.
Failed
openIMHttp
.
RespHttp200
(
c
,
constant
.
OK
,
respPb
)
}
}
func
SearchMessage
(
g
*
gin
.
Context
)
{
func
DeleteGroup
(
c
*
gin
.
Context
)
{
var
(
req
cms_api_struct
.
DeleteGroupRequest
_
cms_api_struct
.
DeleteGroupResponse
reqPb
pbGroup
.
DeleteGroupReq
)
if
err
:=
c
.
BindJSON
(
&
req
);
err
!=
nil
{
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"BindJSON failed "
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrArgs
,
nil
)
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
{
log
.
NewError
(
reqPb
.
OperationID
,
utils
.
GetSelfFuncName
(),
"rpc:"
,
err
.
Error
())
openIMHttp
.
RespHttp200
(
c
,
constant
.
ErrServer
,
nil
)
return
}
openIMHttp
.
RespHttp200
(
c
,
constant
.
OK
,
nil
)
}
}
\ No newline at end of file
internal/cms_api/router.go
浏览文件 @
e94dbe49
...
@@ -57,29 +57,26 @@ func NewGinRouter() *gin.Engine {
...
@@ -57,29 +57,26 @@ func NewGinRouter() *gin.Engine {
groupRouterGroup
.
GET
(
"/get_group_by_id"
,
group
.
GetGroupById
)
groupRouterGroup
.
GET
(
"/get_group_by_id"
,
group
.
GetGroupById
)
groupRouterGroup
.
GET
(
"/get_groups"
,
group
.
GetGroups
)
groupRouterGroup
.
GET
(
"/get_groups"
,
group
.
GetGroups
)
groupRouterGroup
.
GET
(
"/get_group_by_name"
,
group
.
GetGroupByName
)
groupRouterGroup
.
GET
(
"/get_group_by_name"
,
group
.
GetGroupByName
)
groupRouterGroup
.
GET
(
"/get_group_members"
,
group
.
GetGroup
sMember
)
groupRouterGroup
.
GET
(
"/get_group_members"
,
group
.
GetGroup
Members
)
groupRouterGroup
.
POST
(
"/create_group"
,
group
.
CreateGroup
)
groupRouterGroup
.
POST
(
"/create_group"
,
group
.
CreateGroup
)
groupRouterGroup
.
GET
(
"/inquire_group"
,
group
.
InquireGroup
)
groupRouterGroup
.
POST
(
"/add_members"
,
group
.
AddGroupMembers
)
groupRouterGroup
.
POST
(
"/add_members"
,
group
.
AddMembers
)
groupRouterGroup
.
POST
(
"/remove_member"
,
group
.
RemoveGroupMembers
)
groupRouterGroup
.
POST
(
"/remove_member"
,
group
.
RemoveUser
)
groupRouterGroup
.
POST
(
"/ban_group_private_chat"
,
group
.
BanPrivateChat
)
groupRouterGroup
.
POST
(
"/ban_group_private_chat"
,
group
.
BanPrivateChat
)
groupRouterGroup
.
POST
(
"/open_group_private_chat"
,
group
.
OpenPrivateChat
)
groupRouterGroup
.
POST
(
"/open_group_private_chat"
,
group
.
OpenPrivateChat
)
groupRouterGroup
.
POST
(
"/withdraw_message"
,
group
.
Withdraw
)
groupRouterGroup
.
POST
(
"/search_group_message"
,
group
.
SearchMessage
)
groupRouterGroup
.
POST
(
"/ban_group_chat"
,
group
.
BanGroupChat
)
groupRouterGroup
.
POST
(
"/ban_group_chat"
,
group
.
BanGroupChat
)
groupRouterGroup
.
POST
(
"/open_group_chat"
,
group
.
OpenGroupChat
)
groupRouterGroup
.
POST
(
"/open_group_chat"
,
group
.
OpenGroupChat
)
}
}
userRouterGroup
:=
router
.
Group
(
"/user"
)
userRouterGroup
:=
router
.
Group
(
"/user"
)
{
{
userRouterGroup
.
POST
(
"/resign"
,
user
.
ResignUser
)
userRouterGroup
.
POST
(
"/resign"
,
user
.
ResignUser
)
userRouterGroup
.
GET
(
"/get_user
_by_id
"
,
user
.
GetUserById
)
userRouterGroup
.
GET
(
"/get_user"
,
user
.
GetUserById
)
userRouterGroup
.
POST
(
"/alter_user"
,
user
.
AlterUser
)
userRouterGroup
.
POST
(
"/alter_user"
,
user
.
AlterUser
)
userRouterGroup
.
GET
(
"/get_users"
,
user
.
GetUsers
)
userRouterGroup
.
GET
(
"/get_users"
,
user
.
GetUsers
)
userRouterGroup
.
POST
(
"/add_user"
,
user
.
AddUser
)
userRouterGroup
.
POST
(
"/add_user"
,
user
.
AddUser
)
userRouterGroup
.
POST
(
"/unblock_user"
,
user
.
UnblockUser
)
userRouterGroup
.
POST
(
"/unblock_user"
,
user
.
UnblockUser
)
userRouterGroup
.
POST
(
"/block_user"
,
user
.
BlockUser
)
userRouterGroup
.
POST
(
"/block_user"
,
user
.
BlockUser
)
userRouterGroup
.
GET
(
"/get_block_users"
,
user
.
GetBlockUsers
)
userRouterGroup
.
GET
(
"/get_block_users"
,
user
.
GetBlockUsers
)
userRouterGroup
.
GET
(
"/get_block_user
_by_id
"
,
user
.
GetBlockUserById
)
userRouterGroup
.
GET
(
"/get_block_user"
,
user
.
GetBlockUserById
)
userRouterGroup
.
POST
(
"/delete_user"
,
user
.
DeleteUser
)
userRouterGroup
.
POST
(
"/delete_user"
,
user
.
DeleteUser
)
}
}
return
baseRouter
return
baseRouter
...
...
internal/rpc/group/group.go
浏览文件 @
e94dbe49
...
@@ -641,13 +641,16 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
...
@@ -641,13 +641,16 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
}
}
func
(
s
*
groupServer
)
GetGroupById
(
_
context
.
Context
,
req
*
pbGroup
.
GetGroupByIdReq
)
(
*
pbGroup
.
GetGroupByIdResp
,
error
)
{
func
(
s
*
groupServer
)
GetGroupById
(
_
context
.
Context
,
req
*
pbGroup
.
GetGroupByIdReq
)
(
*
pbGroup
.
GetGroupByIdResp
,
error
)
{
log
.
NewInfo
(
req
.
OperationID
,
"GetGroup "
,
req
.
String
())
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
"GetGroup "
,
req
.
String
())
resp
:=
&
pbGroup
.
GetGroupByIdResp
{}
resp
:=
&
pbGroup
.
GetGroupByIdResp
{
CMSGroup
:
&
pbGroup
.
CMSGroup
{
GroupInfo
:
&
open_im_sdk
.
GroupInfo
{},
}}
group
,
err
:=
imdb
.
GetGroupsById
(
req
.
GroupId
)
group
,
err
:=
imdb
.
GetGroupsById
(
req
.
GroupId
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
err
.
Error
())
return
resp
,
err
return
resp
,
err
}
}
resp
.
GroupInfo
=
&
open_im_sdk
.
GroupInfo
{
resp
.
CMSGroup
.
GroupInfo
=
&
open_im_sdk
.
GroupInfo
{
GroupID
:
group
.
GroupID
,
GroupID
:
group
.
GroupID
,
GroupName
:
group
.
GroupName
,
GroupName
:
group
.
GroupName
,
FaceURL
:
group
.
FaceUrl
,
FaceURL
:
group
.
FaceUrl
,
...
@@ -657,31 +660,47 @@ func (s *groupServer) GetGroupById(_ context.Context, req *pbGroup.GetGroupByIdR
...
@@ -657,31 +660,47 @@ func (s *groupServer) GetGroupById(_ context.Context, req *pbGroup.GetGroupByIdR
CreatorUserID
:
group
.
CreatorUserID
,
CreatorUserID
:
group
.
CreatorUserID
,
GroupType
:
group
.
GroupType
,
GroupType
:
group
.
GroupType
,
}
}
resp
.
GroupInfo
.
CreatorUserID
=
group
.
CreatorUserID
groupMember
,
err
:=
imdb
.
GetGroupMaster
(
group
.
GroupID
)
if
err
!=
nil
{
return
resp
,
err
}
resp
.
CMSGroup
.
GroupMasterName
=
groupMember
.
Nickname
resp
.
CMSGroup
.
GroupMasterId
=
groupMember
.
UserID
resp
.
CMSGroup
.
GroupInfo
.
CreatorUserID
=
group
.
CreatorUserID
return
resp
,
nil
return
resp
,
nil
}
}
func
(
s
*
groupServer
)
GetGroup
(
_
context
.
Context
,
req
*
pbGroup
.
GetGroupReq
)
(
*
pbGroup
.
GetGroupResp
,
error
)
{
func
(
s
*
groupServer
)
GetGroup
(
_
context
.
Context
,
req
*
pbGroup
.
GetGroupReq
)
(
*
pbGroup
.
GetGroupResp
,
error
)
{
log
.
NewInfo
(
req
.
OperationID
,
"GetGroup "
,
req
.
String
())
log
.
NewInfo
(
req
.
OperationID
,
"GetGroup "
,
req
.
String
())
resp
:=
&
pbGroup
.
GetGroupResp
{
resp
:=
&
pbGroup
.
GetGroupResp
{
GroupInfo
:
[]
*
open_im_sdk
.
GroupInfo
{},
CMSGroups
:
[]
*
pbGroup
.
CMSGroup
{},
}
}
groups
,
err
:=
imdb
.
GetGroupsByName
(
req
.
GroupName
,
req
.
Pagination
.
PageNumber
,
req
.
Pagination
.
ShowNumber
)
groups
,
err
:=
imdb
.
GetGroupsByName
(
req
.
GroupName
,
req
.
Pagination
.
PageNumber
,
req
.
Pagination
.
ShowNumber
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
log
.
NewInfo
(
req
.
OperationID
,
groups
)
resp
.
Pagination
=
&
open_im_sdk
.
RequestPagination
{
resp
.
Pagination
=
&
open_im_sdk
.
RequestPagination
{
PageNumber
:
req
.
Pagination
.
PageNumber
,
PageNumber
:
req
.
Pagination
.
PageNumber
,
ShowNumber
:
req
.
Pagination
.
ShowNumber
,
ShowNumber
:
req
.
Pagination
.
ShowNumber
,
}
}
for
_
,
v
:=
range
groups
{
for
_
,
v
:=
range
groups
{
resp
.
GroupInfo
=
append
(
resp
.
GroupInfo
,
&
open_im_sdk
.
GroupInfo
{
groupMember
,
err
:=
imdb
.
GetGroupMaster
(
v
.
GroupID
)
if
err
!=
nil
{
log
.
NewError
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
err
.
Error
())
continue
}
resp
.
CMSGroups
=
append
(
resp
.
CMSGroups
,
&
pbGroup
.
CMSGroup
{
GroupInfo
:
&
open_im_sdk
.
GroupInfo
{
GroupID
:
v
.
GroupID
,
GroupID
:
v
.
GroupID
,
GroupName
:
v
.
GroupName
,
GroupName
:
v
.
GroupName
,
FaceURL
:
v
.
FaceUrl
,
FaceURL
:
v
.
FaceUrl
,
OwnerUserID
:
v
.
CreatorUserID
,
OwnerUserID
:
v
.
CreatorUserID
,
Status
:
v
.
Status
,
Status
:
v
.
Status
,
CreatorUserID
:
v
.
CreatorUserID
,
CreatorUserID
:
v
.
CreatorUserID
,
},
GroupMasterName
:
groupMember
.
Nickname
,
GroupMasterId
:
groupMember
.
UserID
,
})
})
}
}
return
resp
,
nil
return
resp
,
nil
...
@@ -690,7 +709,7 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
...
@@ -690,7 +709,7 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
func
(
s
*
groupServer
)
GetGroups
(
_
context
.
Context
,
req
*
pbGroup
.
GetGroupsReq
)
(
*
pbGroup
.
GetGroupsResp
,
error
)
{
func
(
s
*
groupServer
)
GetGroups
(
_
context
.
Context
,
req
*
pbGroup
.
GetGroupsReq
)
(
*
pbGroup
.
GetGroupsResp
,
error
)
{
log
.
NewInfo
(
req
.
OperationID
,
"GetGroups "
,
req
.
String
())
log
.
NewInfo
(
req
.
OperationID
,
"GetGroups "
,
req
.
String
())
resp
:=
&
pbGroup
.
GetGroupsResp
{
resp
:=
&
pbGroup
.
GetGroupsResp
{
GroupInfo
:
[]
*
open_im_sdk
.
GroupInfo
{},
CMSGroups
:
[]
*
pbGroup
.
CMSGroup
{},
Pagination
:
&
open_im_sdk
.
RequestPagination
{},
Pagination
:
&
open_im_sdk
.
RequestPagination
{},
}
}
groups
,
err
:=
imdb
.
GetGroups
(
int
(
req
.
Pagination
.
PageNumber
),
int
(
req
.
Pagination
.
ShowNumber
))
groups
,
err
:=
imdb
.
GetGroups
(
int
(
req
.
Pagination
.
PageNumber
),
int
(
req
.
Pagination
.
ShowNumber
))
...
@@ -706,13 +725,22 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
...
@@ -706,13 +725,22 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
resp
.
Pagination
.
PageNumber
=
req
.
Pagination
.
PageNumber
resp
.
Pagination
.
PageNumber
=
req
.
Pagination
.
PageNumber
resp
.
Pagination
.
ShowNumber
=
req
.
Pagination
.
ShowNumber
resp
.
Pagination
.
ShowNumber
=
req
.
Pagination
.
ShowNumber
for
_
,
v
:=
range
groups
{
for
_
,
v
:=
range
groups
{
resp
.
GroupInfo
=
append
(
resp
.
GroupInfo
,
&
open_im_sdk
.
GroupInfo
{
groupMember
,
err
:=
imdb
.
GetGroupMaster
(
v
.
GroupID
)
if
err
!=
nil
{
log
.
NewError
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
err
.
Error
())
continue
}
resp
.
CMSGroups
=
append
(
resp
.
CMSGroups
,
&
pbGroup
.
CMSGroup
{
GroupInfo
:
&
open_im_sdk
.
GroupInfo
{
GroupID
:
v
.
GroupID
,
GroupID
:
v
.
GroupID
,
GroupName
:
v
.
GroupName
,
GroupName
:
v
.
GroupName
,
FaceURL
:
v
.
FaceUrl
,
FaceURL
:
v
.
FaceUrl
,
OwnerUserID
:
v
.
CreatorUserID
,
OwnerUserID
:
v
.
CreatorUserID
,
Status
:
v
.
Status
,
Status
:
v
.
Status
,
CreatorUserID
:
v
.
CreatorUserID
,
CreatorUserID
:
v
.
CreatorUserID
,
},
GroupMasterId
:
groupMember
.
UserID
,
GroupMasterName
:
groupMember
.
Nickname
,
})
})
}
}
...
@@ -723,6 +751,7 @@ func (s *groupServer) OperateGroupStatus(_ context.Context, req *pbGroup.Operate
...
@@ -723,6 +751,7 @@ func (s *groupServer) OperateGroupStatus(_ context.Context, req *pbGroup.Operate
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
req
.
String
())
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
req
.
String
())
resp
:=
&
pbGroup
.
OperateGroupStatusResp
{}
resp
:=
&
pbGroup
.
OperateGroupStatusResp
{}
if
err
:=
imdb
.
OperateGroupStatus
(
req
.
GroupId
,
req
.
Status
);
err
!=
nil
{
if
err
:=
imdb
.
OperateGroupStatus
(
req
.
GroupId
,
req
.
Status
);
err
!=
nil
{
log
.
NewError
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
err
.
Error
())
return
resp
,
err
return
resp
,
err
}
}
return
resp
,
nil
return
resp
,
nil
...
@@ -732,16 +761,79 @@ func (s *groupServer) DeleteGroup(_ context.Context, req *pbGroup.DeleteGroupReq
...
@@ -732,16 +761,79 @@ func (s *groupServer) DeleteGroup(_ context.Context, req *pbGroup.DeleteGroupReq
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
req
.
String
())
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
req
.
String
())
resp
:=
&
pbGroup
.
DeleteGroupResp
{}
resp
:=
&
pbGroup
.
DeleteGroupResp
{}
if
err
:=
imdb
.
DeleteGroup
(
req
.
GroupId
);
err
!=
nil
{
if
err
:=
imdb
.
DeleteGroup
(
req
.
GroupId
);
err
!=
nil
{
log
.
NewError
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
err
.
Error
())
return
resp
,
err
return
resp
,
err
}
}
return
resp
,
nil
return
resp
,
nil
}
}
func
(
s
*
groupServer
)
OperateUserRole
(
_
context
.
Context
,
req
*
pbGroup
.
OperateUserRoleReq
)
(
*
pbGroup
.
OperateUserRoleResp
,
error
)
{
func
(
s
*
groupServer
)
OperateUserRole
(
_
context
.
Context
,
req
*
pbGroup
.
OperateUserRoleReq
)
(
*
pbGroup
.
OperateUserRoleResp
,
error
)
{
log
.
NewInfo
(
req
.
OperationID
,
"DeleteGroup
"
,
req
.
String
())
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
"args:
"
,
req
.
String
())
resp
:=
&
pbGroup
.
OperateUserRoleResp
{}
resp
:=
&
pbGroup
.
OperateUserRoleResp
{}
if
err
:=
imdb
.
OperateGroupRole
(
req
.
UserId
,
req
.
GroupId
,
req
.
RoleLevel
);
err
!=
nil
{
if
err
:=
imdb
.
OperateGroupRole
(
req
.
UserId
,
req
.
GroupId
,
req
.
RoleLevel
);
err
!=
nil
{
log
.
NewError
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
err
.
Error
())
return
resp
,
err
}
return
resp
,
nil
}
func
(
s
*
groupServer
)
GetGroupMembersCMS
(
_
context
.
Context
,
req
*
pbGroup
.
GetGroupMembersCMSReq
)
(
*
pbGroup
.
GetGroupMembersCMSResp
,
error
)
{
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
"args:"
,
req
.
String
())
resp
:=
&
pbGroup
.
GetGroupMembersCMSResp
{}
groupMembers
,
err
:=
imdb
.
GetGroupMembersByGroupIdCMS
(
req
.
GroupId
,
req
.
Pagination
.
ShowNumber
,
req
.
Pagination
.
PageNumber
)
if
err
!=
nil
{
log
.
NewError
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
err
.
Error
())
return
resp
,
err
return
resp
,
err
}
}
for
_
,
groupMember
:=
range
groupMembers
{
resp
.
Members
=
append
(
resp
.
Members
,
&
open_im_sdk
.
GroupMemberFullInfo
{
GroupID
:
req
.
GroupId
,
UserID
:
groupMember
.
UserID
,
RoleLevel
:
groupMember
.
RoleLevel
,
JoinTime
:
groupMember
.
JoinTime
.
Unix
(),
Nickname
:
groupMember
.
Nickname
,
FaceURL
:
groupMember
.
FaceUrl
,
JoinSource
:
groupMember
.
JoinSource
,
})
}
return
resp
,
nil
}
func
(
s
*
groupServer
)
RemoveGroupMembersCMS
(
_
context
.
Context
,
req
*
pbGroup
.
RemoveGroupMembersCMSReq
)
(
*
pbGroup
.
RemoveGroupMembersCMSResp
,
error
)
{
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
"args:"
,
req
.
String
())
resp
:=
&
pbGroup
.
RemoveGroupMembersCMSResp
{}
for
_
,
userId
:=
range
req
.
UserIds
{
err
:=
imdb
.
RemoveGroupMember
(
req
.
GroupId
,
userId
)
if
err
!=
nil
{
log
.
NewError
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
err
.
Error
())
resp
.
Failed
=
append
(
resp
.
Failed
,
userId
)
}
else
{
resp
.
Success
=
append
(
resp
.
Success
,
userId
)
}
}
return
resp
,
nil
}
func
(
s
*
groupServer
)
AddGroupMembersCMS
(
_
context
.
Context
,
req
*
pbGroup
.
AddGroupMembersCMSReq
)
(
*
pbGroup
.
AddGroupMembersCMSResp
,
error
)
{
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
"args:"
,
req
.
String
())
resp
:=
&
pbGroup
.
AddGroupMembersCMSResp
{}
for
_
,
userIds
:=
range
req
.
UserIds
{
groupMember
:=
db
.
GroupMember
{
GroupID
:
req
.
GroupId
,
UserID
:
userIds
,
Nickname
:
""
,
FaceUrl
:
""
,
RoleLevel
:
1
,
JoinTime
:
time
.
Time
{},
JoinSource
:
constant
.
JoinByAdmin
,
OperatorUserID
:
"CmsAdmin"
,
Ex
:
""
,
}
if
err
:=
imdb
.
InsertIntoGroupMember
(
groupMember
);
err
!=
nil
{
resp
.
Failed
=
append
(
resp
.
Failed
,
userIds
)
}
else
{
resp
.
Success
=
append
(
resp
.
Success
,
userIds
)
}
}
return
resp
,
nil
return
resp
,
nil
}
}
internal/rpc/user/user.go
浏览文件 @
e94dbe49
...
@@ -374,7 +374,7 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
...
@@ -374,7 +374,7 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
}
}
func
(
s
*
userServer
)
GetBlockUserById
(
_
context
.
Context
,
req
*
pbUser
.
GetBlockUserByIdReq
)
(
*
pbUser
.
GetBlockUserByIdResp
,
error
)
{
func
(
s
*
userServer
)
GetBlockUserById
(
_
context
.
Context
,
req
*
pbUser
.
GetBlockUserByIdReq
)
(
*
pbUser
.
GetBlockUserByIdResp
,
error
)
{
log
.
NewInfo
(
req
.
OperationID
,
"GetBlockUser
args "
,
req
.
String
())
log
.
NewInfo
(
req
.
OperationID
,
utils
.
GetSelfFuncName
(),
"GetBlockUserById
args "
,
req
.
String
())
resp
:=
&
pbUser
.
GetBlockUserByIdResp
{}
resp
:=
&
pbUser
.
GetBlockUserByIdResp
{}
user
,
err
:=
imdb
.
GetBlockUserById
(
req
.
UserId
)
user
,
err
:=
imdb
.
GetBlockUserById
(
req
.
UserId
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/cms_api_struct/group.go
浏览文件 @
e94dbe49
...
@@ -86,12 +86,38 @@ type GetGroupMembersRequest struct {
...
@@ -86,12 +86,38 @@ type GetGroupMembersRequest struct {
type
GroupMemberResponse
struct
{
type
GroupMemberResponse
struct
{
MemberPosition
int
`json:"member_position"`
MemberPosition
int
`json:"member_position"`
MemberNickName
string
`json:"member_nick_name"`
MemberNickName
string
`json:"member_nick_name"`
MemberId
int
`json:"member_id"`
MemberId
string
`json:"member_id"`
JoinTime
string
`json:"join_time"`
JoinTime
string
`json:"join_time"`
}
}
type
GetGroupMembersResponse
struct
{
type
GetGroupMembersResponse
struct
{
GroupMember
List
[]
GroupMemberResponse
`json:"group_member_list
"`
GroupMember
s
[]
GroupMemberResponse
`json:"group_members
"`
GroupMemberNums
int
`json:"group_member_nums"`
GroupMemberNums
int
`json:"group_member_nums"`
ResponsePagination
ResponsePagination
}
}
type
GroupMemberRequest
struct
{
GroupId
string
`json:"group_id"`
Members
[]
string
`json:"members"`
}
type
GroupMemberOperateResponse
struct
{
Success
[]
string
`json:"success"`
Failed
[]
string
`json:"failed"`
}
type
AddGroupMembersRequest
struct
{
GroupMemberRequest
}
type
AddGroupMembersResponse
struct
{
GroupMemberOperateResponse
}
type
RemoveGroupMembersRequest
struct
{
GroupMemberRequest
}
type
RemoveGroupMembersResponse
struct
{
GroupMemberOperateResponse
}
pkg/common/constant/constant.go
浏览文件 @
e94dbe49
...
@@ -115,10 +115,8 @@ const (
...
@@ -115,10 +115,8 @@ const (
GroupBaned
=
3
GroupBaned
=
3
GroupBanPrivateChat
=
4
GroupBanPrivateChat
=
4
//timeInterval
//UserJoinGroupSource
Day
=
1
JoinByAdmin
=
1
Week
=
7
Month
=
31
)
)
var
ContentType2PushContent
=
map
[
int64
]
string
{
var
ContentType2PushContent
=
map
[
int64
]
string
{
...
...
pkg/common/db/mysql_model/im_mysql_model/group_member_model.go
浏览文件 @
e94dbe49
...
@@ -225,6 +225,19 @@ func IsGroupOwnerAdmin(groupID, UserID string) bool {
...
@@ -225,6 +225,19 @@ func IsGroupOwnerAdmin(groupID, UserID string) bool {
return
false
return
false
}
}
func
GetGroupMembersByGroupIdCMS
(
groupId
string
,
showNumber
,
pageNumber
int32
)
([]
db
.
GroupMember
,
error
)
{
var
groupMembers
[]
db
.
GroupMember
dbConn
,
err
:=
db
.
DB
.
MysqlDB
.
DefaultGormDB
()
if
err
!=
nil
{
return
groupMembers
,
err
}
err
=
dbConn
.
Table
(
"group_members"
)
.
Where
(
"group_id=?"
,
groupId
)
.
Limit
(
showNumber
)
.
Offset
(
showNumber
*
(
pageNumber
-
1
))
.
Find
(
&
groupMembers
)
.
Error
if
err
!=
nil
{
return
nil
,
err
}
return
groupMembers
,
nil
}
//
//
//func SelectGroupList(groupID string) ([]string, error) {
//func SelectGroupList(groupID string) ([]string, error) {
// var groupUserID string
// var groupUserID string
...
...
pkg/common/db/mysql_model/im_mysql_model/group_model.go
浏览文件 @
e94dbe49
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/common/db"
"Open_IM/pkg/utils"
"Open_IM/pkg/utils"
"fmt"
"time"
"time"
)
)
...
@@ -66,7 +67,7 @@ func GetGroupsByName(groupName string, pageNumber, showNumber int32) ([]db.Group
...
@@ -66,7 +67,7 @@ func GetGroupsByName(groupName string, pageNumber, showNumber int32) ([]db.Group
return
groups
,
err
return
groups
,
err
}
}
dbConn
.
LogMode
(
true
)
dbConn
.
LogMode
(
true
)
err
=
dbConn
.
Table
(
"groups"
)
.
Where
(
"name=?"
,
groupName
)
.
Limit
(
showNumber
)
.
Offset
(
showNumber
*
(
pageNumber
-
1
))
.
Find
(
&
groups
)
.
Error
err
=
dbConn
.
Table
(
"groups"
)
.
Where
(
fmt
.
Sprintf
(
" name like '%%%s%%' "
,
groupName
)
)
.
Limit
(
showNumber
)
.
Offset
(
showNumber
*
(
pageNumber
-
1
))
.
Find
(
&
groups
)
.
Error
return
groups
,
err
return
groups
,
err
}
}
...
@@ -103,9 +104,13 @@ func DeleteGroup(groupId string) error {
...
@@ -103,9 +104,13 @@ func DeleteGroup(groupId string) error {
}
}
dbConn
.
LogMode
(
true
)
dbConn
.
LogMode
(
true
)
var
group
db
.
Group
var
group
db
.
Group
var
groupMembers
[]
db
.
GroupMember
if
err
:=
dbConn
.
Table
(
"groups"
)
.
Where
(
""
)
.
Delete
(
&
group
)
.
Error
;
err
!=
nil
{
if
err
:=
dbConn
.
Table
(
"groups"
)
.
Where
(
""
)
.
Delete
(
&
group
)
.
Error
;
err
!=
nil
{
return
err
return
err
}
}
if
err
:=
dbConn
.
Table
(
"group_Members"
)
.
Where
(
"group_id=?"
,
groupId
)
.
Delete
(
groupMembers
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
return
nil
}
}
...
@@ -136,7 +141,7 @@ func GetGroupsCountNum() (int, error) {
...
@@ -136,7 +141,7 @@ func GetGroupsCountNum() (int, error) {
}
}
dbConn
.
LogMode
(
true
)
dbConn
.
LogMode
(
true
)
var
count
int
var
count
int
if
err
:=
dbConn
.
Model
(
&
db
.
Group
{}
)
.
Count
(
&
count
)
.
Error
;
err
!=
nil
{
if
err
:=
dbConn
.
Table
(
"groups"
)
.
Count
(
&
count
)
.
Error
;
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
return
count
,
nil
return
count
,
nil
...
@@ -151,8 +156,21 @@ func GetGroupsById(groupId string) (db.Group, error) {
...
@@ -151,8 +156,21 @@ func GetGroupsById(groupId string) (db.Group, error) {
return
group
,
err
return
group
,
err
}
}
dbConn
.
LogMode
(
true
)
dbConn
.
LogMode
(
true
)
if
err
:=
dbConn
.
Find
(
&
group
)
.
First
(
&
group
)
.
Error
;
err
!=
nil
{
if
err
:=
dbConn
.
Table
(
"groups"
)
.
Find
(
&
group
)
.
Error
;
err
!=
nil
{
return
group
,
err
return
group
,
err
}
}
return
group
,
nil
return
group
,
nil
}
}
func
GetGroupMaster
(
groupId
string
)
(
db
.
GroupMember
,
error
)
{
dbConn
,
err
:=
db
.
DB
.
MysqlDB
.
DefaultGormDB
()
groupMember
:=
db
.
GroupMember
{}
if
err
!=
nil
{
return
groupMember
,
err
}
dbConn
.
LogMode
(
true
)
if
err
:=
dbConn
.
Table
(
"group_members"
)
.
Where
(
"role_level=? and group_id=?"
,
constant
.
GroupOwner
,
groupId
)
.
Find
(
&
groupMember
)
.
Error
;
err
!=
nil
{
return
groupMember
,
err
}
return
groupMember
,
nil
}
\ No newline at end of file
pkg/common/db/mysql_model/im_mysql_model/user_model.go
浏览文件 @
e94dbe49
...
@@ -222,7 +222,7 @@ func GetBlockUserById(userId string) (BlockUserInfo, error) {
...
@@ -222,7 +222,7 @@ func GetBlockUserById(userId string) (BlockUserInfo, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
blockUserInfo
,
err
return
blockUserInfo
,
err
}
}
if
err
=
dbConn
.
Find
(
&
blockUser
)
.
First
(
&
blockUser
)
.
Error
;
err
!=
nil
{
if
err
=
dbConn
.
Table
(
"black_list"
)
.
Where
(
"uid=?"
,
userId
)
.
Find
(
&
blockUser
)
.
Error
;
err
!=
nil
{
return
blockUserInfo
,
err
return
blockUserInfo
,
err
}
}
user
:=
db
.
Users
{
user
:=
db
.
Users
{
...
...
pkg/proto/group/group.pb.go
浏览文件 @
e94dbe49
此差异已折叠。
点击以展开。
pkg/proto/group/group.proto
浏览文件 @
e94dbe49
...
@@ -195,6 +195,12 @@ message GetGroupAllMemberResp {
...
@@ -195,6 +195,12 @@ message GetGroupAllMemberResp {
repeated
server_api_params.GroupMemberFullInfo
memberList
=
3
;
repeated
server_api_params.GroupMemberFullInfo
memberList
=
3
;
}
}
message
CMSGroup
{
server_api_params.GroupInfo
GroupInfo
=
1
;
string
GroupMasterName
=
2
;
string
GroupMasterId
=
3
;
}
message
GetGroupReq
{
message
GetGroupReq
{
string
GroupName
=
1
;
string
GroupName
=
1
;
server_api_params.RequestPagination
Pagination
=
2
;
server_api_params.RequestPagination
Pagination
=
2
;
...
@@ -202,7 +208,7 @@ message GetGroupReq {
...
@@ -202,7 +208,7 @@ message GetGroupReq {
}
}
message
GetGroupResp
{
message
GetGroupResp
{
repeated
server_api_params.GroupInfo
GroupInfo
=
1
;
repeated
CMSGroup
CMSGroups
=
1
;
server_api_params.RequestPagination
Pagination
=
2
;
server_api_params.RequestPagination
Pagination
=
2
;
}
}
...
@@ -212,7 +218,7 @@ message GetGroupsReq {
...
@@ -212,7 +218,7 @@ message GetGroupsReq {
}
}
message
GetGroupsResp
{
message
GetGroupsResp
{
repeated
server_api_params.GroupInfo
GroupInfo
=
1
;
repeated
CMSGroup
CMSGroups
=
1
;
server_api_params.RequestPagination
Pagination
=
2
;
server_api_params.RequestPagination
Pagination
=
2
;
int32
GroupNum
=
3
;
int32
GroupNum
=
3
;
}
}
...
@@ -258,7 +264,40 @@ message GetGroupByIdReq {
...
@@ -258,7 +264,40 @@ message GetGroupByIdReq {
}
}
message
GetGroupByIdResp
{
message
GetGroupByIdResp
{
server_api_params.GroupInfo
GroupInfo
=
1
;
CMSGroup
CMSGroup
=
1
;
}
message
GetGroupMembersCMSReq
{
string
GroupId
=
1
;
server_api_params.RequestPagination
Pagination
=
2
;
string
OperationID
=
3
;
}
message
GetGroupMembersCMSResp
{
repeated
server_api_params.GroupMemberFullInfo
members
=
3
;
server_api_params.RequestPagination
Pagination
=
2
;
}
message
RemoveGroupMembersCMSReq
{
string
GroupId
=
1
;
repeated
string
UserIds
=
2
;
string
OperationID
=
3
;
}
message
RemoveGroupMembersCMSResp
{
repeated
string
success
=
1
;
repeated
string
failed
=
2
;
}
message
AddGroupMembersCMSReq
{
string
GroupId
=
1
;
repeated
string
UserIds
=
2
;
string
OperationID
=
3
;
}
message
AddGroupMembersCMSResp
{
repeated
string
success
=
1
;
repeated
string
failed
=
2
;
}
}
service
group
{
service
group
{
...
@@ -283,6 +322,9 @@ service group{
...
@@ -283,6 +322,9 @@ service group{
rpc
OperateGroupStatus
(
OperateGroupStatusReq
)
returns
(
OperateGroupStatusResp
);
rpc
OperateGroupStatus
(
OperateGroupStatusReq
)
returns
(
OperateGroupStatusResp
);
rpc
OperateUserRole
(
OperateUserRoleReq
)
returns
(
OperateUserRoleResp
);
rpc
OperateUserRole
(
OperateUserRoleReq
)
returns
(
OperateUserRoleResp
);
rpc
DeleteGroup
(
DeleteGroupReq
)
returns
(
DeleteGroupResp
);
rpc
DeleteGroup
(
DeleteGroupReq
)
returns
(
DeleteGroupResp
);
rpc
GetGroupMembersCMS
(
GetGroupMembersCMSReq
)
returns
(
GetGroupMembersCMSResp
);
rpc
RemoveGroupMembersCMS
(
RemoveGroupMembersCMSReq
)
returns
(
RemoveGroupMembersCMSResp
);
rpc
AddGroupMembersCMS
(
AddGroupMembersCMSReq
)
returns
(
AddGroupMembersCMSResp
);
}
}
...
...
pkg/proto/proto_dir.cfg
浏览文件 @
e94dbe49
all_proto=(
all_proto=(
message/message.proto
#
message/message.proto
# statistics/statistics.proto
# statistics/statistics.proto
# auth/auth.proto
# auth/auth.proto
# friend/friend.proto
# friend/friend.proto
#
group/group.proto
group/group.proto
# user/user.proto
# user/user.proto
# chat/chat.proto
# chat/chat.proto
# push/push.proto
# push/push.proto
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录