go_dreamfactory/modules/chat/api_getlist.go
2022-07-20 14:01:59 +08:00

45 lines
1.1 KiB
Go

package chat
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.ChatGetListReq) (code pb.ErrorCode) {
return
}
///获取本服聊天消息记录
func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq) (code pb.ErrorCode, data proto.Message) {
var (
err error
list []*pb.DBChat
)
switch req.Channel {
case pb.ChatChannel_World:
if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0, 0); err != nil {
code = pb.ErrorCode_DBError
return
}
break
case pb.ChatChannel_Union:
if list, err = this.module.modelChat.GetChatQueue(req.Channel, 0, 0, 0); err != nil {
code = pb.ErrorCode_DBError
return
}
break
case pb.ChatChannel_Private:
if list, err = this.module.modelChat.QueryUserMsg(session.GetUserId()); err != nil {
code = pb.ErrorCode_DBError
return
}
break
}
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ChatGetListResp{Chats: list})
return
}