65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package friend
|
|
|
|
import (
|
|
"errors"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 踢馆(熊猫武馆)
|
|
func (this *apiComp) QiecuoCheck(session comm.IUserSession, req *pb.FriendQiecuoReq) (errdata *pb.ErrorData) {
|
|
if req.TargetUid == "" {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.FriendQiecuoReq) (errdata *pb.ErrorData) {
|
|
if errdata = this.QiecuoCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
//目标是否在线
|
|
if !this.module.ModuleUser.IsOnline(req.TargetUid) {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_UserOffline,
|
|
Title: pb.ErrorCode_UserOffline.ToString(),
|
|
}
|
|
return
|
|
}
|
|
|
|
//切磋请求处理
|
|
if err := this.module.ModelFriendQiecuo.qiecuoReq(session.GetUserId(), req.TargetUid); err != nil {
|
|
var customErr = new(comm.CustomError)
|
|
if errors.As(err, &customErr) {
|
|
code := customErr.Code
|
|
errdata = &pb.ErrorData{
|
|
Code: code,
|
|
Title: code.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
} else {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
resp := &pb.FriendQiecuoResp{
|
|
TargetUid: req.TargetUid,
|
|
Uid: session.GetUserId(),
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), FriendSubTypeQiecuo, resp)
|
|
|
|
this.module.SendMsgToUser(string(this.module.GetType()), "qiecuonotify",
|
|
&pb.FriendQiecuonotifyPush{Uid: session.GetUserId(), NotifyType: 1}, req.TargetUid)
|
|
|
|
return
|
|
}
|