cms api rpc

pull/265/head
wangchuxiao 2 years ago
parent 06236546a8
commit 69008e08be

@ -220,8 +220,10 @@ func GetGroupMembers(c *gin.Context) {
ShowNumber: int(respPb.Pagination.ShowNumber),
}
resp.MemberNums = int(respPb.MemberNums)
for _, groupMembers := range respPb.Members {
resp.GroupMembers = append(resp.GroupMembers, *groupMembers)
for _, groupMember := range respPb.Members {
memberResp := cms_api_struct.GroupMemberResponse{}
utils.CopyStructFields(&memberResp, groupMember)
resp.GroupMembers = append(resp.GroupMembers, memberResp)
}
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
openIMHttp.RespHttp200(c, constant.OK, resp)

@ -15,6 +15,7 @@ import (
const cronTaskOperationID = "cronTaskOperationID-"
func StartCronTask() {
log.NewPrivateLog("cron.log")
log.NewInfo(utils.OperationIDGenerator(), "start cron task")
c := cron.New()
fmt.Println("config", config.Config.Mongo.ChatRecordsClearTime)

@ -1,3 +1,7 @@
package main
func main() {}
import "Open_IM/pkg/common/db"
func main() {
db.DB.BatchInsertChat()
}

@ -1358,6 +1358,7 @@ func (s *groupServer) GetGroupByID(_ context.Context, req *pbGroup.GetGroupByIDR
resp.CMSGroup.GroupOwnerUserName = groupMember.Nickname
resp.CMSGroup.GroupOwnerUserID = groupMember.UserID
resp.CMSGroup.GroupInfo.CreatorUserID = group.CreatorUserID
resp.CMSGroup.GroupInfo.CreateTime = uint32(group.CreateTime.Unix())
utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, nil
@ -1392,7 +1393,8 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error())
continue
}
group.GroupOwnerUserID = groupMember.GroupID
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
group.GroupOwnerUserID = groupMember.UserID
group.GroupOwnerUserName = groupMember.Nickname
resp.CMSGroups = append(resp.CMSGroups, group)
}
@ -1411,13 +1413,7 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroups error", err.Error())
return resp, http.WrapError(constant.ErrDB)
}
groupsCountNum, err := imdb.GetGroupsCountNum(db.Group{})
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "groupsCountNum ", groupsCountNum)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum", err.Error())
return resp, http.WrapError(constant.ErrDB)
}
resp.GroupNum = groupsCountNum
resp.Pagination.PageNumber = req.Pagination.PageNumber
resp.Pagination.ShowNumber = req.Pagination.ShowNumber
for _, v := range groups {
@ -1428,7 +1424,14 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
continue
}
group.GroupOwnerUserID = groupMember.GroupID
//groupCountNum, err := imdb.GetGroupsCountNum(v)
//if err != nil {
// log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum failed", err.Error(), v)
// continue
//}
//group.GroupInfo.MemberCount = uint32(groupCountNum)
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
group.GroupOwnerUserID = groupMember.UserID
group.GroupOwnerUserName = groupMember.Nickname
resp.CMSGroups = append(resp.CMSGroups, group)
}
@ -1485,6 +1488,8 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
for _, groupMember := range groupMembers {
member := open_im_sdk.GroupMemberFullInfo{}
utils.CopyStructFields(&member, groupMember)
member.JoinTime = int32(groupMember.JoinTime.Unix())
member.MuteEndTime = uint32(groupMember.MuteEndTime.Unix())
resp.Members = append(resp.Members, &member)
}
resp.Pagination = &open_im_sdk.ResponsePagination{

@ -1,21 +1,17 @@
package cms_api_struct
import (
server_api_params "Open_IM/pkg/proto/sdk_ws"
)
type GroupResponse struct {
GroupOwnerName string `json:"GroupOwnerName"`
GroupOwnerID string `json:"GroupOwnerID"`
//*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"`
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"`
@ -108,8 +104,23 @@ type GetGroupMembersRequest struct {
RequestPagination
}
type GroupMemberResponse struct {
GroupID string `json:"groupID"`
UserID string `json:"userID"`
RoleLevel int32 `json:"roleLevel"`
JoinTime int32 `json:"joinTime"`
Nickname string `json:"nickname"`
FaceURL string `json:"faceURL"`
AppMangerLevel int32 `json:"appMangerLevel"` //if >0
JoinSource int32 `json:"joinSource"`
OperatorUserID string `json:"operatorUserID"`
Ex string `json:"ex"`
MuteEndTime uint32 `json:"muteEndTime"`
InviterUserID string `json:"inviterUserID"`
}
type GetGroupMembersResponse struct {
GroupMembers []server_api_params.GroupMemberFullInfo `json:"groupMembers"`
GroupMembers []GroupMemberResponse `json:"groupMembers"`
ResponsePagination
MemberNums int `json:"memberNums"`
}

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

Loading…
Cancel
Save