go_dreamfactory/modules/chat/api_chanagechannel.go
2022-10-19 17:19:06 +08:00

41 lines
1.0 KiB
Go

package chat
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) ChanageChannelCheck(session comm.IUserSession, req *pb.ChatChanageChannelReq) (code pb.ErrorCode) {
if req.ChannelId < 0 {
code = pb.ErrorCode_ReqParameterError
}
return
}
///改变跨服聊天频道
func (this *apiComp) ChanageChannel(session comm.IUserSession, req *pb.ChatChanageChannelReq) (code pb.ErrorCode, data proto.Message) {
var (
err error
ok bool
)
if err, ok = this.module.modelChat.chanageChannel(session, req.ChannelId); err != nil {
code = pb.ErrorCode_DBError
return
}
if ok {
if err = this.module.modelChat.removeCrossChannelMember(session); err != nil {
code = pb.ErrorCode_DBError
return
}
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"chatchannel": req.ChannelId,
})
}
session.SendMsg(string(this.module.GetType()), "chanagechannel", &pb.ChatChanageChannelResp{ChannelId: req.ChannelId, IsSucc: ok})
return
}