callback kickoff

pull/265/head
wangchuxiao 2 years ago
parent aa7ba6d659
commit c2bd1d0d83

@ -22,7 +22,7 @@ func GetGroupByID(c *gin.Context) {
var ( var (
req cms_api_struct.GetGroupByIDRequest req cms_api_struct.GetGroupByIDRequest
resp cms_api_struct.GetGroupByIDResponse resp cms_api_struct.GetGroupByIDResponse
reqPb pbGroup.GetGroupByIdReq reqPb pbGroup.GetGroupByIDReq
) )
if err := c.ShouldBindQuery(&req); err != nil { if err := c.ShouldBindQuery(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error()) log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
@ -46,7 +46,10 @@ func GetGroupByID(c *gin.Context) {
openIMHttp.RespHttp200(c, err, nil) openIMHttp.RespHttp200(c, err, nil)
return return
} }
utils.CopyStructFields(&resp, respPb) utils.CopyStructFields(&resp, respPb.CMSGroup.GroupInfo)
resp.GroupOwnerID = respPb.CMSGroup.GroupOwnerUserID
resp.GroupOwnerName = respPb.CMSGroup.GroupOwnerUserName
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp) log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp) openIMHttp.RespHttp200(c, constant.OK, resp)
} }
@ -81,16 +84,11 @@ func GetGroups(c *gin.Context) {
return return
} }
for _, v := range respPb.CMSGroups { for _, v := range respPb.CMSGroups {
resp.Groups = append(resp.Groups, cms_api_struct.GroupResponse{ groupResp := cms_api_struct.GroupResponse{}
GroupName: v.GroupInfo.GroupName, utils.CopyStructFields(&groupResp, v.GroupInfo)
GroupID: v.GroupInfo.GroupID, groupResp.GroupOwnerName = v.GroupOwnerUserName
GroupMasterName: v.GroupMasterName, groupResp.GroupOwnerID = v.GroupOwnerUserID
GroupMasterId: v.GroupMasterId, resp.Groups = append(resp.Groups, groupResp)
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
IsBanChat: constant.GroupIsBanChat(v.GroupInfo.Status),
IsBanPrivateChat: false,
ProfilePhoto: v.GroupInfo.FaceURL,
})
} }
resp.GroupNums = int(respPb.GroupNum) resp.GroupNums = int(respPb.GroupNum)
resp.CurrentPage = int(respPb.Pagination.PageNumber) resp.CurrentPage = int(respPb.Pagination.PageNumber)
@ -130,16 +128,11 @@ func GetGroupByName(c *gin.Context) {
return return
} }
for _, v := range respPb.CMSGroups { for _, v := range respPb.CMSGroups {
resp.Groups = append(resp.Groups, cms_api_struct.GroupResponse{ groupResp := cms_api_struct.GroupResponse{}
GroupName: v.GroupInfo.GroupName, utils.CopyStructFields(&groupResp, v.GroupInfo)
GroupID: v.GroupInfo.GroupID, groupResp.GroupOwnerName = v.GroupOwnerUserName
GroupMasterName: v.GroupMasterName, groupResp.GroupOwnerID = v.GroupOwnerUserID
GroupMasterId: v.GroupMasterId, resp.Groups = append(resp.Groups, groupResp)
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
IsBanChat: constant.GroupIsBanChat(v.GroupInfo.Status),
IsBanPrivateChat: false,
ProfilePhoto: v.GroupInfo.FaceURL,
})
} }
resp.CurrentPage = int(respPb.Pagination.PageNumber) resp.CurrentPage = int(respPb.Pagination.PageNumber)
resp.ShowNumber = int(respPb.Pagination.ShowNumber) resp.ShowNumber = int(respPb.Pagination.ShowNumber)
@ -189,133 +182,6 @@ func CreateGroup(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.OK, nil) openIMHttp.RespHttp200(c, constant.OK, nil)
} }
func BanGroupChat(c *gin.Context) {
var (
req cms_api_struct.BanGroupChatRequest
reqPb pbGroup.OperateGroupStatusReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.OperationID = utils.OperationIDGenerator()
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.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
}
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BanGroupChat failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func BanPrivateChat(c *gin.Context) {
var (
req cms_api_struct.BanPrivateChatRequest
reqPb pbGroup.OperateGroupStatusReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.OperationID = utils.OperationIDGenerator()
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.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
}
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func OpenGroupChat(c *gin.Context) {
var (
req cms_api_struct.BanPrivateChatRequest
reqPb pbGroup.OperateGroupStatusReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.OperationID = utils.OperationIDGenerator()
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.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
}
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func OpenPrivateChat(c *gin.Context) {
var (
req cms_api_struct.BanPrivateChatRequest
reqPb pbGroup.OperateGroupStatusReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OpenPrivateChat failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
reqPb.OperationID = utils.OperationIDGenerator()
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId
reqPb.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
}
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus failed ", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func GetGroupMembers(c *gin.Context) { func GetGroupMembers(c *gin.Context) {
var ( var (
req cms_api_struct.GetGroupMembersRequest req cms_api_struct.GetGroupMembersRequest
@ -333,7 +199,7 @@ func GetGroupMembers(c *gin.Context) {
PageNumber: int32(req.PageNumber), PageNumber: int32(req.PageNumber),
ShowNumber: int32(req.ShowNumber), ShowNumber: int32(req.ShowNumber),
} }
reqPb.GroupId = req.GroupId reqPb.GroupID = req.GroupID
reqPb.UserName = req.UserName reqPb.UserName = req.UserName
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
if etcdConn == nil { if etcdConn == nil {
@ -355,12 +221,7 @@ func GetGroupMembers(c *gin.Context) {
} }
resp.MemberNums = int(respPb.MemberNums) resp.MemberNums = int(respPb.MemberNums)
for _, groupMembers := range respPb.Members { for _, groupMembers := range respPb.Members {
resp.GroupMembers = append(resp.GroupMembers, cms_api_struct.GroupMemberResponse{ resp.GroupMembers = append(resp.GroupMembers, *groupMembers)
MemberPosition: int(groupMembers.RoleLevel),
MemberNickName: groupMembers.Nickname,
MemberId: groupMembers.UserID,
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
})
} }
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp) log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp) openIMHttp.RespHttp200(c, constant.OK, resp)
@ -373,25 +234,25 @@ func AddGroupMembers(c *gin.Context) {
reqPb pbGroup.AddGroupMembersCMSReq reqPb pbGroup.AddGroupMembersCMSReq
) )
if err := c.BindJSON(&req); err != nil { if err := c.BindJSON(&req); err != nil {
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "BindJSON failed ", err.Error()) log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil) openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return return
} }
reqPb.OperationId = utils.OperationIDGenerator() reqPb.OperationID = utils.OperationIDGenerator()
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req) log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
reqPb.UserIds = req.Members reqPb.UserIDList = req.Members
reqPb.GroupId = req.GroupId reqPb.GroupID = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationId) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
if etcdConn == nil { if etcdConn == nil {
errMsg := reqPb.OperationId + "getcdv3.GetConn == nil" errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
log.NewError(reqPb.OperationId, errMsg) log.NewError(reqPb.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return return
} }
client := pbGroup.NewGroupClient(etcdConn) client := pbGroup.NewGroupClient(etcdConn)
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb) respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
if err != nil { if err != nil {
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "AddGroupMembersCMS failed", err.Error()) log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "AddGroupMembersCMS failed", err.Error())
openIMHttp.RespHttp200(c, err, nil) openIMHttp.RespHttp200(c, err, nil)
return return
} }
@ -414,8 +275,8 @@ func RemoveGroupMembers(c *gin.Context) {
} }
reqPb.OperationID = utils.OperationIDGenerator() reqPb.OperationID = utils.OperationIDGenerator()
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req) log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.UserIds = req.Members reqPb.UserIDList = req.Members
reqPb.GroupId = req.GroupId reqPb.GroupID = req.GroupId
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
if etcdConn == nil { if etcdConn == nil {
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil" errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
@ -436,38 +297,7 @@ func RemoveGroupMembers(c *gin.Context) {
openIMHttp.RespHttp200(c, constant.OK, resp) openIMHttp.RespHttp200(c, constant.OK, resp)
} }
func DeleteGroup(c *gin.Context) { func SetGroupOwner(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
}
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
}
client := pbGroup.NewGroupClient(etcdConn)
_, err := client.DeleteGroup(context.Background(), &reqPb)
if err != nil {
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
openIMHttp.RespHttp200(c, err, nil)
return
}
openIMHttp.RespHttp200(c, constant.OK, nil)
}
func SetGroupMaster(c *gin.Context) {
var ( var (
req cms_api_struct.SetGroupMasterRequest req cms_api_struct.SetGroupMasterRequest
_ cms_api_struct.SetGroupMasterResponse _ cms_api_struct.SetGroupMasterResponse
@ -480,8 +310,8 @@ func SetGroupMaster(c *gin.Context) {
} }
reqPb.OperationID = utils.OperationIDGenerator() reqPb.OperationID = utils.OperationIDGenerator()
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req) log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId reqPb.GroupID = req.GroupId
reqPb.UserId = req.UserId reqPb.UserID = req.UserId
reqPb.RoleLevel = constant.GroupOwner reqPb.RoleLevel = constant.GroupOwner
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
if etcdConn == nil { if etcdConn == nil {
@ -513,8 +343,8 @@ func SetGroupOrdinaryUsers(c *gin.Context) {
} }
reqPb.OperationID = utils.OperationIDGenerator() reqPb.OperationID = utils.OperationIDGenerator()
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req) log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
reqPb.GroupId = req.GroupId reqPb.GroupID = req.GroupId
reqPb.UserId = req.UserId reqPb.UserID = req.UserId
reqPb.RoleLevel = constant.GroupOrdinaryUsers reqPb.RoleLevel = constant.GroupOrdinaryUsers
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
if etcdConn == nil { if etcdConn == nil {
@ -553,7 +383,6 @@ func AlterGroupInfo(c *gin.Context) {
Introduction: req.Introduction, Introduction: req.Introduction,
Notification: req.Notification, Notification: req.Notification,
FaceURL: req.ProfilePhoto, 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) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
if etcdConn == nil { if etcdConn == nil {

@ -54,13 +54,8 @@ func NewGinRouter() *gin.Engine {
groupRouterGroup.POST("/create_group", group.CreateGroup) groupRouterGroup.POST("/create_group", group.CreateGroup)
groupRouterGroup.POST("/add_members", group.AddGroupMembers) groupRouterGroup.POST("/add_members", group.AddGroupMembers)
groupRouterGroup.POST("/remove_members", group.RemoveGroupMembers) groupRouterGroup.POST("/remove_members", group.RemoveGroupMembers)
groupRouterGroup.POST("/ban_group_private_chat", group.BanPrivateChat)
groupRouterGroup.POST("/open_group_private_chat", group.OpenPrivateChat)
groupRouterGroup.POST("/ban_group_chat", group.BanGroupChat)
groupRouterGroup.POST("/open_group_chat", group.OpenGroupChat)
groupRouterGroup.POST("/delete_group", group.DeleteGroup)
groupRouterGroup.POST("/get_members_in_group", group.GetGroupMembers) groupRouterGroup.POST("/get_members_in_group", group.GetGroupMembers)
groupRouterGroup.POST("/set_group_master", group.SetGroupMaster) groupRouterGroup.POST("/set_group_master", group.SetGroupOwner)
groupRouterGroup.POST("/set_group_ordinary_user", group.SetGroupOrdinaryUsers) groupRouterGroup.POST("/set_group_ordinary_user", group.SetGroupOrdinaryUsers)
groupRouterGroup.POST("/alter_group_info", group.AlterGroupInfo) groupRouterGroup.POST("/alter_group_info", group.AlterGroupInfo)
} }

@ -1333,35 +1333,32 @@ 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, utils.GetSelfFuncName(), "req: ", req.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbGroup.GetGroupByIdResp{CMSGroup: &pbGroup.CMSGroup{ resp := &pbGroup.GetGroupByIDResp{CMSGroup: &pbGroup.CMSGroup{
GroupInfo: &open_im_sdk.GroupInfo{}, GroupInfo: &open_im_sdk.GroupInfo{},
}} }}
group, err := imdb.GetGroupById(req.GroupId) group, err := imdb.GetGroupInfoByGroupID(req.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById error", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById error", err.Error())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
resp.CMSGroup.GroupInfo = &open_im_sdk.GroupInfo{ utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
GroupID: group.GroupID,
GroupName: group.GroupName,
FaceURL: group.FaceURL,
OwnerUserID: group.CreatorUserID,
MemberCount: 0,
Status: group.Status,
CreatorUserID: group.CreatorUserID,
GroupType: group.GroupType,
CreateTime: uint32(group.CreateTime.Unix()),
}
groupMember, err := imdb.GetGroupMaster(group.GroupID) groupMember, err := imdb.GetGroupMaster(group.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster", err.Error())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
resp.CMSGroup.GroupMasterName = groupMember.Nickname groupMemberNum, err := imdb.GetGroupMemberNumByGroupID(req.GroupID)
resp.CMSGroup.GroupMasterId = groupMember.UserID if err == nil {
resp.CMSGroup.GroupInfo.MemberCount = uint32(groupMemberNum)
} else {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
}
resp.CMSGroup.GroupOwnerUserName = groupMember.Nickname
resp.CMSGroup.GroupOwnerUserID = groupMember.UserID
resp.CMSGroup.GroupInfo.CreatorUserID = group.CreatorUserID resp.CMSGroup.GroupInfo.CreatorUserID = group.CreatorUserID
utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil return resp, nil
} }
@ -1373,12 +1370,13 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
} }
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 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsByName error", req.String()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsByName error", req.String(), req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "groups", groups)
nums, err := imdb.GetGroupsCountNum(db.Group{GroupName: req.GroupName}) nums, err := imdb.GetGroupsCountNum(db.Group{GroupName: req.GroupName})
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error(), req.GroupName)
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
resp.GroupNums = nums resp.GroupNums = nums
@ -1387,24 +1385,16 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
ShowNumber: req.Pagination.ShowNumber, ShowNumber: req.Pagination.ShowNumber,
} }
for _, v := range groups { for _, v := range groups {
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(group.GroupInfo, v)
groupMember, err := imdb.GetGroupMaster(v.GroupID) groupMember, err := imdb.GetGroupMaster(v.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error())
continue continue
} }
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{ group.GroupOwnerUserID = groupMember.GroupID
GroupInfo: &open_im_sdk.GroupInfo{ group.GroupOwnerUserName = groupMember.Nickname
GroupID: v.GroupID, resp.CMSGroups = append(resp.CMSGroups, group)
GroupName: v.GroupName,
FaceURL: v.FaceURL,
OwnerUserID: v.CreatorUserID,
Status: v.Status,
CreatorUserID: v.CreatorUserID,
CreateTime: uint32(v.CreateTime.Unix()),
},
GroupMasterName: groupMember.Nickname,
GroupMasterId: groupMember.UserID,
})
} }
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil return resp, nil
@ -1427,57 +1417,29 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum", err.Error())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
resp.GroupNum = int32(groupsCountNum) resp.GroupNum = groupsCountNum
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 {
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(group.GroupInfo, v)
groupMember, err := imdb.GetGroupMaster(v.GroupID) groupMember, err := imdb.GetGroupMaster(v.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
continue continue
} }
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{ group.GroupOwnerUserID = groupMember.GroupID
GroupInfo: &open_im_sdk.GroupInfo{ group.GroupOwnerUserName = groupMember.Nickname
GroupID: v.GroupID, resp.CMSGroups = append(resp.CMSGroups, group)
GroupName: v.GroupName,
FaceURL: v.FaceURL,
OwnerUserID: v.CreatorUserID,
Status: v.Status,
CreatorUserID: v.CreatorUserID,
CreateTime: uint32(v.CreateTime.Unix()),
},
GroupMasterId: groupMember.UserID,
GroupMasterName: groupMember.Nickname,
})
} }
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String())
return resp, nil return resp, nil
} }
func (s *groupServer) OperateGroupStatus(_ context.Context, req *pbGroup.OperateGroupStatusReq) (*pbGroup.OperateGroupStatusResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
resp := &pbGroup.OperateGroupStatusResp{}
if err := imdb.OperateGroupStatus(req.GroupId, req.Status); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "OperateGroupStatus", err.Error())
return resp, http.WrapError(constant.ErrDB)
}
return resp, nil
}
func (s *groupServer) DeleteGroup(_ context.Context, req *pbGroup.DeleteGroupReq) (*pbGroup.DeleteGroupResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
resp := &pbGroup.DeleteGroupResp{}
if err := imdb.DeleteGroup(req.GroupId); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteGroup error", err.Error())
return resp, http.WrapError(constant.ErrDB)
}
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, utils.GetSelfFuncName(), "args:", req.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
resp := &pbGroup.OperateUserRoleResp{} resp := &pbGroup.OperateUserRoleResp{}
oldOwnerUserID, err := imdb.GetGroupMaster(req.GroupId) oldOwnerUserID, err := imdb.GetGroupMaster(req.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
@ -1491,8 +1453,8 @@ func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUse
client := pbGroup.NewGroupClient(etcdConn) client := pbGroup.NewGroupClient(etcdConn)
var reqPb pbGroup.TransferGroupOwnerReq var reqPb pbGroup.TransferGroupOwnerReq
reqPb.OperationID = req.OperationID reqPb.OperationID = req.OperationID
reqPb.NewOwnerUserID = req.UserId reqPb.NewOwnerUserID = req.UserID
reqPb.GroupID = req.GroupId reqPb.GroupID = req.GroupID
reqPb.OpUserID = "cms admin" reqPb.OpUserID = "cms admin"
reqPb.OldOwnerUserID = oldOwnerUserID.UserID reqPb.OldOwnerUserID = oldOwnerUserID.UserID
reply, err := client.TransferGroupOwner(context.Background(), &reqPb) reply, err := client.TransferGroupOwner(context.Background(), &reqPb)
@ -1508,12 +1470,12 @@ func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUse
func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) { func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
resp := &pbGroup.GetGroupMembersCMSResp{} resp := &pbGroup.GetGroupMembersCMSResp{}
groupMembers, err := imdb.GetGroupMembersByGroupIdCMS(req.GroupId, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber) groupMembers, err := imdb.GetGroupMembersByGroupIdCMS(req.GroupID, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersByGroupIdCMS Error", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersByGroupIdCMS Error", err.Error())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
groupMembersCount, err := imdb.GetGroupMembersCount(req.GroupId, req.UserName) groupMembersCount, err := imdb.GetGroupMembersCount(req.GroupID, req.UserName)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS Error", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS Error", err.Error())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
@ -1521,15 +1483,9 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
log.NewInfo(req.OperationID, groupMembersCount) log.NewInfo(req.OperationID, groupMembersCount)
resp.MemberNums = int32(groupMembersCount) resp.MemberNums = int32(groupMembersCount)
for _, groupMember := range groupMembers { for _, groupMember := range groupMembers {
resp.Members = append(resp.Members, &open_im_sdk.GroupMemberFullInfo{ member := open_im_sdk.GroupMemberFullInfo{}
GroupID: req.GroupId, utils.CopyStructFields(&member, groupMember)
UserID: groupMember.UserID, resp.Members = append(resp.Members, &member)
RoleLevel: groupMember.RoleLevel,
JoinTime: int32(groupMember.JoinTime.Unix()),
Nickname: groupMember.Nickname,
FaceURL: groupMember.FaceURL,
JoinSource: groupMember.JoinSource,
})
} }
resp.Pagination = &open_im_sdk.ResponsePagination{ resp.Pagination = &open_im_sdk.ResponsePagination{
CurrentPage: req.Pagination.PageNumber, CurrentPage: req.Pagination.PageNumber,
@ -1542,8 +1498,8 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.RemoveGroupMembersCMSReq) (*pbGroup.RemoveGroupMembersCMSResp, error) { func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.RemoveGroupMembersCMSReq) (*pbGroup.RemoveGroupMembersCMSResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
resp := &pbGroup.RemoveGroupMembersCMSResp{} resp := &pbGroup.RemoveGroupMembersCMSResp{}
for _, userId := range req.UserIds { for _, userId := range req.UserIDList {
err := imdb.RemoveGroupMember(req.GroupId, userId) err := imdb.RemoveGroupMember(req.GroupID, userId)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
resp.Failed = append(resp.Failed, userId) resp.Failed = append(resp.Failed, userId)
@ -1552,20 +1508,20 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
} }
} }
reqKick := &pbGroup.KickGroupMemberReq{ reqKick := &pbGroup.KickGroupMemberReq{
GroupID: req.GroupId, GroupID: req.GroupID,
KickedUserIDList: resp.Success, KickedUserIDList: resp.Success,
Reason: "admin kick", Reason: "admin kick",
OperationID: req.OperationID, OperationID: req.OperationID,
OpUserID: req.OpUserId, OpUserID: req.OpUserID,
} }
var reqPb pbUser.SetConversationReq var reqPb pbUser.SetConversationReq
var c pbUser.Conversation var c pbUser.Conversation
for _, v := range resp.Success { for _, v := range resp.Success {
reqPb.OperationID = req.OperationID reqPb.OperationID = req.OperationID
c.OwnerUserID = v c.OwnerUserID = v
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupId, constant.GroupChatType) c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
c.ConversationType = constant.GroupChatType c.ConversationType = constant.GroupChatType
c.GroupID = req.GroupId c.GroupID = req.GroupID
c.IsNotInGroup = true c.IsNotInGroup = true
reqPb.Conversation = &c reqPb.Conversation = &c
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
@ -1591,7 +1547,7 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
} }
cacheClient := pbCache.NewCacheClient(etcdConn) cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{ cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
GroupID: req.GroupId, GroupID: req.GroupID,
OperationID: req.OperationID, OperationID: req.OperationID,
}) })
if err != nil { if err != nil {
@ -1602,16 +1558,16 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String()) log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupId); err != nil { if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupId) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
} }
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupId); err != nil { if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupId) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
} }
for _, userID := range resp.Success { for _, userID := range resp.Success {
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupId, userID); err != nil { if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, userID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupId, userID) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID, userID)
} }
} }
@ -1621,22 +1577,22 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
} }
func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGroupMembersCMSReq) (*pbGroup.AddGroupMembersCMSResp, error) { func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGroupMembersCMSReq) (*pbGroup.AddGroupMembersCMSResp, error) {
log.NewInfo(req.OperationId, utils.GetSelfFuncName(), "args:", req.String()) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
resp := &pbGroup.AddGroupMembersCMSResp{} resp := &pbGroup.AddGroupMembersCMSResp{}
for _, userId := range req.UserIds { for _, userId := range req.UserIDList {
if isExist := imdb.IsExistGroupMember(req.GroupId, userId); isExist { if isExist := imdb.IsExistGroupMember(req.GroupID, userId); isExist {
log.NewError(req.OperationId, utils.GetSelfFuncName(), "user is exist in group", userId, req.GroupId) log.NewError(req.OperationID, utils.GetSelfFuncName(), "user is exist in group", userId, req.GroupID)
resp.Failed = append(resp.Failed, userId) resp.Failed = append(resp.Failed, userId)
continue continue
} }
user, err := imdb.GetUserByUserID(userId) user, err := imdb.GetUserByUserID(userId)
if err != nil { if err != nil {
log.NewError(req.OperationId, utils.GetSelfFuncName(), "GetUserByUserID", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID", err.Error())
resp.Failed = append(resp.Failed, userId) resp.Failed = append(resp.Failed, userId)
continue continue
} }
groupMember := db.GroupMember{ groupMember := db.GroupMember{
GroupID: req.GroupId, GroupID: req.GroupID,
UserID: userId, UserID: userId,
Nickname: user.Nickname, Nickname: user.Nickname,
FaceURL: "", FaceURL: "",
@ -1647,40 +1603,40 @@ func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGrou
Ex: "", Ex: "",
} }
if err := imdb.InsertIntoGroupMember(groupMember); err != nil { if err := imdb.InsertIntoGroupMember(groupMember); err != nil {
log.NewError(req.OperationId, utils.GetSelfFuncName(), "InsertIntoGroupMember failed", req.String()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "InsertIntoGroupMember failed", req.String())
resp.Failed = append(resp.Failed, userId) resp.Failed = append(resp.Failed, userId)
} else { } else {
resp.Success = append(resp.Success, userId) resp.Success = append(resp.Success, userId)
} }
} }
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationId) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
if etcdConn == nil { if etcdConn == nil {
errMsg := req.OperationId + "getcdv3.GetConn == nil" errMsg := req.OperationID + "getcdv3.GetConn == nil"
log.NewError(req.OperationId, errMsg) log.NewError(req.OperationID, errMsg)
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
cacheClient := pbCache.NewCacheClient(etcdConn) cacheClient := pbCache.NewCacheClient(etcdConn)
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{ cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
GroupID: req.GroupId, GroupID: req.GroupID,
OperationID: req.OperationId, OperationID: req.OperationID,
}) })
if err != nil { if err != nil {
log.NewError(req.OperationId, "DelGroupMemberIDListFromCache rpc call failed ", err.Error()) log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
if cacheResp.CommonResp.ErrCode != 0 { if cacheResp.CommonResp.ErrCode != 0 {
log.NewError(req.OperationId, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String()) log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
return resp, http.WrapError(constant.ErrDB) return resp, http.WrapError(constant.ErrDB)
} }
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupId); err != nil { if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
log.NewError(req.OperationId, utils.GetSelfFuncName(), err.Error(), req.GroupId) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
} }
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupId); err != nil { if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
log.NewError(req.OperationId, utils.GetSelfFuncName(), err.Error(), req.GroupId) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
} }
chat.MemberInvitedNotification(req.OperationId, req.GroupId, req.OpUserId, "admin add you to group", resp.Success) chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, "admin add you to group", resp.Success)
return resp, nil return resp, nil
} }

@ -1,11 +1,30 @@
package cms_api_struct package cms_api_struct
import server_api_params "Open_IM/pkg/proto/sdk_ws" import (
server_api_params "Open_IM/pkg/proto/sdk_ws"
)
type GroupResponse struct { type GroupResponse struct {
GroupOwnerName string `json:"GroupOwnerName"` GroupOwnerName string `json:"GroupOwnerName"`
GroupOwnerID string `json:"GroupOwnerID"` GroupOwnerID string `json:"GroupOwnerID"`
*server_api_params.GroupInfo //*server_api_params.GroupInfo
GroupID string `json:"groupID"`
GroupName string `json:"groupName"`
Notification string `json:"notification"`
Introduction string `json:"introduction"`
FaceURL string `json:"faceURL"`
OwnerUserID string `json:"ownerUserID"`
CreateTime uint32 `json:"createTime"`
MemberCount uint32 `json:"memberCount"`
Ex string `json:"ex"`
Status int32 `json:"status"`
CreatorUserID string `json:"creatorUserID"`
GroupType int32 `json:"groupType"`
NeedVerification int32 `json:"needVerification"`
LookMemberInfo int32 `json:"lookMemberInfo"`
ApplyMemberFriend int32 `json:"applyMemberFriend"`
NotificationUpdateTime uint32 `json:"notificationUpdateTime"`
NotificationUserID string `json:"notificationUserID"`
} }
type GetGroupByIDRequest struct { type GetGroupByIDRequest struct {
@ -17,13 +36,13 @@ type GetGroupByIDResponse struct {
} }
type GetGroupRequest struct { type GetGroupRequest struct {
GroupName string `form:"group_name" binding:"required"` GroupName string `form:"groupName" binding:"required"`
RequestPagination RequestPagination
} }
type GetGroupResponse struct { type GetGroupResponse struct {
Groups []GroupResponse `json:"groups"` Groups []GroupResponse `json:"groups"`
GroupNums int `json:"group_nums"` GroupNums int `json:"groupNums"`
ResponsePagination ResponsePagination
} }
@ -33,77 +52,70 @@ type GetGroupsRequest struct {
type GetGroupsResponse struct { type GetGroupsResponse struct {
Groups []GroupResponse `json:"groups"` Groups []GroupResponse `json:"groups"`
GroupNums int `json:"group_nums"` GroupNums int `json:"groupNums"`
ResponsePagination ResponsePagination
} }
type CreateGroupRequest struct { type CreateGroupRequest struct {
GroupName string `json:"group_name" binding:"required"` GroupName string `json:"groupName" binding:"required"`
GroupMasterId string `json:"group_master_id" binding:"required"` GroupMasterId string `json:"groupOwnerID" binding:"required"`
GroupMembers []string `json:"group_members" binding:"required"` GroupMembers []string `json:"groupMembers" binding:"required"`
} }
type CreateGroupResponse struct { type CreateGroupResponse struct {
} }
type SetGroupMasterRequest struct { type SetGroupMasterRequest struct {
GroupId string `json:"group_id" binding:"required"` GroupId string `json:"groupID" binding:"required"`
UserId string `json:"user_id" binding:"required"` UserId string `json:"userID" binding:"required"`
} }
type SetGroupMasterResponse struct { type SetGroupMasterResponse struct {
} }
type SetGroupMemberRequest struct { type SetGroupMemberRequest struct {
GroupId string `json:"group_id" binding:"required"` GroupId string `json:"groupID" binding:"required"`
UserId string `json:"user_id" binding:"required"` UserId string `json:"userID" binding:"required"`
} }
type SetGroupMemberRespones struct { type SetGroupMemberRespones struct {
} }
type BanGroupChatRequest struct { type BanGroupChatRequest struct {
GroupId string `json:"group_id" binding:"required"` GroupId string `json:"groupID" binding:"required"`
} }
type BanGroupChatResponse struct { type BanGroupChatResponse struct {
} }
type BanPrivateChatRequest struct { type BanPrivateChatRequest struct {
GroupId string `json:"group_id" binding:"required"` GroupId string `json:"groupID" binding:"required"`
} }
type BanPrivateChatResponse struct { type BanPrivateChatResponse struct {
} }
type DeleteGroupRequest struct { type DeleteGroupRequest struct {
GroupId string `json:"group_id" binding:"required"` GroupId string `json:"groupID" binding:"required"`
} }
type DeleteGroupResponse struct { type DeleteGroupResponse struct {
} }
type GetGroupMembersRequest struct { type GetGroupMembersRequest struct {
GroupId string `form:"group_id" binding:"required"` GroupID string `form:"groupID" binding:"required"`
UserName string `form:"user_name"` UserName string `form:"userName"`
RequestPagination RequestPagination
} }
type GroupMemberResponse struct {
MemberPosition int `json:"member_position"`
MemberNickName string `json:"member_nick_name"`
MemberId string `json:"member_id"`
JoinTime string `json:"join_time"`
}
type GetGroupMembersResponse struct { type GetGroupMembersResponse struct {
GroupMembers []GroupMemberResponse `json:"group_members"` GroupMembers []server_api_params.GroupMemberFullInfo `json:"groupMembers"`
ResponsePagination ResponsePagination
MemberNums int `json:"member_nums"` MemberNums int `json:"memberNums"`
} }
type GroupMemberRequest struct { type GroupMemberRequest struct {
GroupId string `json:"group_id" binding:"required"` GroupId string `json:"groupID" binding:"required"`
Members []string `json:"members" binding:"required"` Members []string `json:"members" binding:"required"`
} }
@ -129,12 +141,12 @@ type RemoveGroupMembersResponse struct {
} }
type AlterGroupInfoRequest struct { type AlterGroupInfoRequest struct {
GroupID string `json:"group_id"` GroupID string `json:"groupID"`
GroupName string `json:"group_name"` GroupName string `json:"groupName"`
Notification string `json:"notification"` Notification string `json:"notification"`
Introduction string `json:"introduction"` Introduction string `json:"introduction"`
ProfilePhoto string `json:"profile_photo"` ProfilePhoto string `json:"profilePhoto"`
GroupType int `json:"group_type"` GroupType int `json:"groupType"`
} }
type AlterGroupInfoResponse struct { type AlterGroupInfoResponse struct {

@ -2,7 +2,7 @@ package log
import ( import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"bufio" //"bufio"
"fmt" "fmt"
"os" "os"
"time" "time"
@ -33,13 +33,13 @@ func loggerInit(moduleName string) *Logger {
//All logs will be printed //All logs will be printed
logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel)) logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel))
//Close std console output //Close std console output
src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend) //src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
if err != nil { //if err != nil {
panic(err.Error()) // panic(err.Error())
} //}
writer := bufio.NewWriter(src) //writer := bufio.NewWriter(src)
logger.SetOutput(writer) //logger.SetOutput(writer)
//logger.SetOutput(os.Stdout) logger.SetOutput(os.Stdout)
//Log Console Print Style Setting //Log Console Print Style Setting
logger.SetFormatter(&nested.Formatter{ logger.SetFormatter(&nested.Formatter{
TimestampFormat: "2006-01-02 15:04:05.000", TimestampFormat: "2006-01-02 15:04:05.000",

File diff suppressed because it is too large Load Diff

@ -247,16 +247,6 @@ message GetGroupMemberReq {
string OperationID = 2; string OperationID = 2;
} }
message OperateGroupStatusReq {
string GroupID = 1;
int32 Status = 2;
string OperationID = 3;
}
message OperateGroupStatusResp {
}
message OperateUserRoleReq { message OperateUserRoleReq {
string GroupID = 1; string GroupID = 1;
string UserID = 2; string UserID = 2;
@ -268,15 +258,6 @@ message OperateUserRoleResp {
} }
message DeleteGroupReq {
string GroupID = 1;
string OperationID = 2;
}
message DeleteGroupResp {
}
message GetGroupByIDReq { message GetGroupByIDReq {
string GroupID = 1; string GroupID = 1;
string OperationID = 2; string OperationID = 2;
@ -463,12 +444,10 @@ service group{
rpc inviteUserToGroup(InviteUserToGroupReq) returns (InviteUserToGroupResp); rpc inviteUserToGroup(InviteUserToGroupReq) returns (InviteUserToGroupResp);
rpc getGroupAllMember(GetGroupAllMemberReq) returns(GetGroupAllMemberResp); rpc getGroupAllMember(GetGroupAllMemberReq) returns(GetGroupAllMemberResp);
rpc GetGroupById(GetGroupByIDReq) returns(GetGroupByIDResp); rpc GetGroupByID(GetGroupByIDReq) returns(GetGroupByIDResp);
rpc GetGroup(GetGroupReq) returns(GetGroupResp); rpc GetGroup(GetGroupReq) returns(GetGroupResp);
rpc GetGroups(GetGroupsReq) returns(GetGroupsResp); rpc GetGroups(GetGroupsReq) returns(GetGroupsResp);
rpc OperateGroupStatus(OperateGroupStatusReq) returns(OperateGroupStatusResp);
rpc OperateUserRole(OperateUserRoleReq) returns(OperateUserRoleResp); rpc OperateUserRole(OperateUserRoleReq) returns(OperateUserRoleResp);
rpc DeleteGroup(DeleteGroupReq) returns(DeleteGroupResp);
rpc GetGroupMembersCMS(GetGroupMembersCMSReq) returns(GetGroupMembersCMSResp); rpc GetGroupMembersCMS(GetGroupMembersCMSReq) returns(GetGroupMembersCMSResp);
rpc RemoveGroupMembersCMS(RemoveGroupMembersCMSReq) returns(RemoveGroupMembersCMSResp); rpc RemoveGroupMembersCMS(RemoveGroupMembersCMSReq) returns(RemoveGroupMembersCMSResp);
rpc AddGroupMembersCMS(AddGroupMembersCMSReq) returns(AddGroupMembersCMSResp); rpc AddGroupMembersCMS(AddGroupMembersCMSReq) returns(AddGroupMembersCMSResp);

Loading…
Cancel
Save