go_dreamfactory/modules/chat/api_spangetlist.go

53 lines
1.3 KiB
Go

package chat
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) SpanGetListCheck(session comm.IUserSession, req *pb.ChatSpanGetListReq) (code pb.ErrorCode) {
return
}
///获取跨服聊天消息记录
func (this *apiComp) SpanGetList(session comm.IUserSession, req *pb.ChatSpanGetListReq) (code pb.ErrorCode, data proto.Message) {
var (
err error
result *pb.DBUserExpand
list []*pb.DBChat
group int32
)
if result, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
this.module.Errorf("err:%v", err)
return
}
if req.ChannelId != result.Chatchannel {
code = pb.ErrorCode_ReqParameterError
return
}
if group, err = this.module.configure.GetServiecTagGroup(session.GetServiecTag()); err != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
switch req.Channel {
case pb.ChatChannel_CrossServer:
if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, group, req.ChannelId); err != nil {
code = pb.ErrorCode_DBError
return
}
break
case pb.ChatChannel_System:
if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0, 0); err != nil {
code = pb.ErrorCode_DBError
return
}
break
}
session.SendMsg(string(this.module.GetType()), "spangetlist", &pb.ChatSpanGetListResp{Chats: list})
return
}