Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
905a40f1cb
@ -28,12 +28,18 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.FriendAcceptReq)
|
||||
if qr := this.module.ModelFriendQiecuo.getQiecuo(req.Uid); qr != nil {
|
||||
now := configure.Now().Unix()
|
||||
if now-qr.Timestamp > 10 { //大于10s 切磋超时
|
||||
code = pb.ErrorCode_FriendQiecuoTimeout
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendQiecuoTimeout,
|
||||
Title: pb.ErrorCode_FriendQiecuoTimeout.ToString(),
|
||||
}
|
||||
this.module.Debug("切磋接受超时", log.Field{Key: "uid", Value: session.GetUserId()})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
code = pb.ErrorCode_FriendQiecuoNoRequest
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendQiecuoNoRequest,
|
||||
Title: pb.ErrorCode_FriendQiecuoNoRequest.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -42,13 +48,20 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.FriendAcceptReq)
|
||||
//发起者 red
|
||||
red := this.module.ModuleUser.GetUser(req.Uid)
|
||||
if red == nil {
|
||||
code = pb.ErrorCode_UserNofound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNofound,
|
||||
Title: pb.ErrorCode_UserNofound.ToString(),
|
||||
}
|
||||
this.module.Error("未找到红方信息", log.Field{Key: "uid", Value: req.Uid})
|
||||
return
|
||||
}
|
||||
blue := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
if blue == nil {
|
||||
code = pb.ErrorCode_UserNofound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNofound,
|
||||
Title: pb.ErrorCode_UserNofound.ToString(),
|
||||
}
|
||||
|
||||
this.module.Error("未找到蓝方信息", log.Field{Key: "uid", Value: session.GetUserId()})
|
||||
return
|
||||
}
|
||||
@ -57,7 +70,7 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.FriendAcceptReq)
|
||||
&pb.PvpUserInfo{Uid: blue.Uid, Name: blue.Name, Avatar: blue.Avatar, Lv: blue.Lv},
|
||||
pb.PvpType_friends,
|
||||
)
|
||||
if c != pb.ErrorCode_Success {
|
||||
if c != nil {
|
||||
this.module.Debug("createPvp code:", log.Field{Key: "code", Value: c})
|
||||
return
|
||||
}
|
||||
@ -71,10 +84,8 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.FriendAcceptReq)
|
||||
resp := &pb.FriendAcceptResp{
|
||||
IsSucc: true,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeAccept, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeAccept, resp)
|
||||
|
||||
|
||||
this.module.SendMsgToUser(string(this.module.GetType()), "qiecuonotify",
|
||||
&pb.FriendQiecuonotifyPush{Uid: session.GetUserId(), NotifyType: 2}, req.Uid)
|
||||
|
@ -35,13 +35,19 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendAddBlackR
|
||||
uid := session.GetUserId()
|
||||
self = this.module.modelFriend.GetFriend(uid)
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
target = this.module.modelFriend.GetFriend(req.FriendId)
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_FriendTargetNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendTargetNoData,
|
||||
Title: pb.ErrorCode_FriendTargetNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -53,19 +59,28 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendAddBlackR
|
||||
|
||||
//判断目标是否已经在黑名单中
|
||||
if _, ok := utils.Findx(self.BlackIds, req.FriendId); ok {
|
||||
code = pb.ErrorCode_FriendSelfBlackYet
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfBlackYet,
|
||||
Title: pb.ErrorCode_FriendSelfBlackYet.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 判断自己是否在对方的黑名单中
|
||||
if _, ok := utils.Findx(target.BlackIds, self.Uid); ok {
|
||||
code = pb.ErrorCode_FriendTargetBlackYet
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendTargetBlackYet,
|
||||
Title: pb.ErrorCode_FriendTargetBlackYet.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是否黑名单人数已满
|
||||
if len(self.BlackIds) >= int(this.module.globalConf.FriendBlack) {
|
||||
code = pb.ErrorCode_FriendBlackMax
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendBlackMax,
|
||||
Title: pb.ErrorCode_FriendBlackMax.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -98,10 +113,7 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendAddBlackR
|
||||
FriendId: req.FriendId,
|
||||
UserId: session.GetUserId(),
|
||||
}
|
||||
if err = session.SendMsg(string(this.module.GetType()), FriendSubTypeAddBlack, Resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeAddBlack, Resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -35,7 +35,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (e
|
||||
//获取玩家自己好友数据
|
||||
self = this.module.modelFriend.GetFriend(uid)
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -89,7 +93,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (e
|
||||
//双向添加:将自己加入到申请人的好友列表中
|
||||
target = this.module.modelFriend.GetFriend(userId)
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_FriendTargetNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendTargetNoData,
|
||||
Title: pb.ErrorCode_FriendTargetNoData.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
target.ApplyIds = utils.DeleteString(target.ApplyIds, self.Uid)
|
||||
@ -155,9 +163,6 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (e
|
||||
resp := &pb.FriendAgreeResp{
|
||||
Num: optNum,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeAgree, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeAgree, resp)
|
||||
return
|
||||
}
|
||||
|
@ -35,58 +35,85 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (e
|
||||
|
||||
//判断是否是自己
|
||||
if req.FriendId == uid {
|
||||
code = pb.ErrorCode_FriendNotSelf
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendNotSelf,
|
||||
Title: pb.ErrorCode_FriendNotSelf.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//获取玩家自己好友数据
|
||||
self = this.module.modelFriend.GetFriend(uid)
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
globalConf := this.module.globalConf
|
||||
//判断是否超过最大好友数量
|
||||
if len(self.FriendIds) >= int(globalConf.FriendMaxnum) {
|
||||
code = pb.ErrorCode_FriendSelfMax
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfMax,
|
||||
Title: pb.ErrorCode_FriendSelfMax.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//判断是否是好友
|
||||
if _, ok := utils.Find(self.FriendIds, req.FriendId); ok {
|
||||
code = pb.ErrorCode_FriendYet
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendYet,
|
||||
Title: pb.ErrorCode_FriendYet.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//获取好友数据
|
||||
target = this.module.modelFriend.GetFriend(req.FriendId)
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_FriendTargetNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendTargetNoData,
|
||||
Title: pb.ErrorCode_FriendTargetNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//判断自己是否在目标用户的申请列表中
|
||||
if _, ok := utils.Find(target.ApplyIds, self.Uid); ok {
|
||||
code = pb.ErrorCode_FriendApplyYet
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendApplyYet,
|
||||
Title: pb.ErrorCode_FriendApplyYet.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//判断对方是否也超过最大好友数量
|
||||
if len(target.FriendIds) >= int(globalConf.FriendMaxnum) {
|
||||
code = pb.ErrorCode_FriendTargetMax
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendTargetMax,
|
||||
Title: pb.ErrorCode_FriendTargetMax.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//判断目标用户是否在黑名单中
|
||||
if _, ok := utils.Find(self.BlackIds, req.FriendId); ok {
|
||||
code = pb.ErrorCode_FriendSelfBlackYet
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfBlackYet,
|
||||
Title: pb.ErrorCode_FriendSelfBlackYet.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//判断是否在对方的黑名单中
|
||||
if _, ok := utils.Find(target.BlackIds, self.Uid); ok {
|
||||
code = pb.ErrorCode_FriendTargetBlackYet
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendTargetBlackYet,
|
||||
Title: pb.ErrorCode_FriendTargetBlackYet.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -99,7 +126,10 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (e
|
||||
if err = this.module.modelFriend.Change(req.FriendId, map[string]interface{}{
|
||||
"applyIds": target.ApplyIds,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_FriendApplyError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendApplyError,
|
||||
Title: pb.ErrorCode_FriendApplyError.ToString(),
|
||||
}
|
||||
this.module.Error("好友申请",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "params", Value: req.FriendId},
|
||||
@ -113,9 +143,6 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (e
|
||||
FriendId: req.FriendId,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeApply, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeApply, resp)
|
||||
return
|
||||
}
|
||||
|
@ -19,7 +19,10 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyLis
|
||||
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -34,9 +37,7 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyLis
|
||||
List: list,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeApplyList, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeApplyList, resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -42,14 +42,20 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth
|
||||
}
|
||||
|
||||
if hero == nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//获取玩家自己好友数据
|
||||
self := this.module.modelFriend.GetFriend(uid)
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -64,7 +70,10 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth
|
||||
}
|
||||
|
||||
if err := this.module.modelFriend.Change(self.Uid, update); err != nil {
|
||||
code = pb.ErrorCode_FriendApplyError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendApplyError,
|
||||
Title: pb.ErrorCode_FriendApplyError.ToString(),
|
||||
}
|
||||
this.module.Error("设置助战英雄",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "params", Value: req.HeroObjId},
|
||||
@ -75,7 +84,6 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth
|
||||
|
||||
rsp := &pb.FriendAssistheroResp{HeroObjId: req.HeroObjId, Received: received}
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeAssistHero, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,10 @@ func (this *apiComp) AssistHeroList(session comm.IUserSession, req *pb.FriendAss
|
||||
//获取玩家自己好友数据
|
||||
self := this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -30,9 +33,7 @@ func (this *apiComp) AssistHeroList(session comm.IUserSession, req *pb.FriendAss
|
||||
})
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeAssistHeroList, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeAssistHeroList, rsp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ func (this *apiComp) Assistlist(session comm.IUserSession, req *pb.FriendAssistl
|
||||
//获取玩家自己好友数据
|
||||
self := this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -64,8 +67,6 @@ func (this *apiComp) Assistlist(session comm.IUserSession, req *pb.FriendAssistl
|
||||
HeroObjId: self.AssistHeroId,
|
||||
Record: self.Record,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeAssistlist, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeAssistlist, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ func (this *apiComp) Blacklist(session comm.IUserSession, req *pb.FriendBlackLis
|
||||
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -33,10 +36,7 @@ func (this *apiComp) Blacklist(session comm.IUserSession, req *pb.FriendBlackLis
|
||||
Friends: list,
|
||||
}
|
||||
|
||||
err := session.SendMsg(string(this.module.GetType()), FriendSubTypeBlacklist, resp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeBlacklist, resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -27,7 +27,10 @@ func (this *apiComp) Del(session comm.IUserSession, req *pb.FriendDelReq) (errda
|
||||
uid := session.GetUserId()
|
||||
self := this.module.modelFriend.GetFriend(uid)
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -42,13 +45,19 @@ func (this *apiComp) Del(session comm.IUserSession, req *pb.FriendDelReq) (errda
|
||||
log.Field{Key: "params", Value: req.String()},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
code = pb.ErrorCode_FriendApplyError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendApplyError,
|
||||
Title: pb.ErrorCode_FriendApplyError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
target := this.module.modelFriend.GetFriend(req.FriendId)
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_FriendNotSelf
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendNotSelf,
|
||||
Title: pb.ErrorCode_FriendNotSelf.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -58,7 +67,10 @@ func (this *apiComp) Del(session comm.IUserSession, req *pb.FriendDelReq) (errda
|
||||
if err := this.module.modelFriend.Change(req.FriendId, map[string]interface{}{
|
||||
"friendIds": targetFriendIds,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_FriendApplyError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendApplyError,
|
||||
Title: pb.ErrorCode_FriendApplyError.ToString(),
|
||||
}
|
||||
this.module.Error("删除好友",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "params", Value: req.FriendId},
|
||||
@ -67,9 +79,7 @@ func (this *apiComp) Del(session comm.IUserSession, req *pb.FriendDelReq) (errda
|
||||
return
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeDel, &pb.FriendDelResp{FriendId: req.FriendId, UserId: self.Uid}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeDel, &pb.FriendDelResp{FriendId: req.FriendId, UserId: self.Uid})
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -30,7 +30,10 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR
|
||||
uid := session.GetUserId()
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -57,9 +60,6 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR
|
||||
UserId: session.GetUserId(),
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeDelBlack, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeDelBlack, resp)
|
||||
return
|
||||
}
|
||||
|
@ -26,13 +26,19 @@ func (this *apiComp) GetRelation(session comm.IUserSession, req *pb.FriendGetRel
|
||||
|
||||
self := this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
target := this.module.modelFriend.GetFriend(req.TargetUid)
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_FriendTargetNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendTargetNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
var status bool
|
||||
@ -51,9 +57,6 @@ func (this *apiComp) GetRelation(session comm.IUserSession, req *pb.FriendGetRel
|
||||
TargetUid: req.TargetUid,
|
||||
Status: status,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeRelation, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeRelation, resp)
|
||||
return
|
||||
}
|
||||
|
@ -16,12 +16,18 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar
|
||||
//获取玩家自己好友数据
|
||||
self := this.module.modelFriend.GetFriend(uid)
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if self.Received != 1 {
|
||||
code = pb.ErrorCode_FriendNoreceived
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendNoreceived,
|
||||
Title: pb.ErrorCode_FriendNoreceived.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -30,7 +36,10 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar
|
||||
"received": received,
|
||||
}
|
||||
if err := this.module.modelFriend.Change(self.Uid, update); err != nil {
|
||||
code = pb.ErrorCode_FriendApplyError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendApplyError,
|
||||
Title: pb.ErrorCode_FriendApplyError.ToString(),
|
||||
}
|
||||
this.module.Error("领奖",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
@ -43,16 +52,13 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar
|
||||
this.module.Error("好友领奖励",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "reward", Value: globalConf.FriendPeize},
|
||||
log.Field{Key: "code", Value: code},
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
rsp := &pb.FriendGetrewardResp{Received: int32(received)}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), "getreward", rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "getreward", rsp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -20,7 +20,10 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (err
|
||||
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -58,10 +61,7 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (err
|
||||
resp := &pb.FriendListResp{
|
||||
List: list,
|
||||
}
|
||||
err := session.SendMsg(string(this.module.GetType()), FriendSubTypeList, resp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeList, resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.FriendQiecuoReq)
|
||||
|
||||
//目标是否在线
|
||||
if !this.module.ModuleUser.IsOnline(req.TargetUid) {
|
||||
code = pb.ErrorCode_UserOffline
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserOffline,
|
||||
Title: pb.ErrorCode_UserOffline.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -32,7 +35,12 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.FriendQiecuoReq)
|
||||
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
|
||||
code := customErr.Code
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
@ -47,10 +55,8 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.FriendQiecuoReq)
|
||||
TargetUid: req.TargetUid,
|
||||
Uid: session.GetUserId(),
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeQiecuo, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
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)
|
||||
|
||||
|
@ -18,7 +18,10 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendRandlistR
|
||||
// 当前玩家好友数据
|
||||
self := this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -49,7 +52,10 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendRandlistR
|
||||
//检查目标v中的申请列表中是否有自己,
|
||||
target := this.module.modelFriend.GetFriend(v.Uid)
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if _, ok := utils.Findx(target.ApplyIds, self.Uid); ok {
|
||||
@ -106,10 +112,7 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendRandlistR
|
||||
rsp := &pb.FriendRandlistResp{
|
||||
List: userList,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeRandList, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeRandList, rsp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -35,7 +35,10 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq)
|
||||
//获取玩家自己好友数据
|
||||
self = this.module.modelFriend.GetFriend(uid)
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -75,11 +78,8 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq)
|
||||
Num: optNum,
|
||||
}
|
||||
|
||||
err := session.SendMsg(string(this.module.GetType()), FriendSubTypeRefuse, resp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeRefuse, resp)
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -10,8 +10,10 @@ import (
|
||||
// 搜索
|
||||
func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.FriendSearchReq) (errdata *pb.ErrorData) {
|
||||
if req.NickName == "" {
|
||||
code = pb.ErrorCode_FriendSearchNameEmpty
|
||||
this.module.Error("参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSearchNameEmpty,
|
||||
Title: pb.ErrorCode_FriendSearchNameEmpty.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
@ -64,9 +66,7 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.FriendSearchReq)
|
||||
resp.Friends = append(resp.Friends, base)
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeSearch, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeSearch, resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -21,10 +21,7 @@ func (this *apiComp) Stop(session comm.IUserSession, req *pb.FriendStopReq) (err
|
||||
resp := &pb.FriendStopResp{
|
||||
IsSucc: true,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), "stop", resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "stop", resp)
|
||||
this.module.SendMsgToUser(string(this.module.GetType()), "qiecuonotify",
|
||||
&pb.FriendQiecuonotifyPush{Uid: session.GetUserId(), NotifyType: 3}, req.Uid)
|
||||
return
|
||||
|
@ -36,7 +36,10 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (errda
|
||||
// 不能给自己点赞
|
||||
for _, v := range req.FriendIds {
|
||||
if v == selfId {
|
||||
code = pb.ErrorCode_FriendZanSelf
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendZanSelf,
|
||||
Title: pb.ErrorCode_FriendZanSelf.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -48,7 +51,10 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (errda
|
||||
for _, v := range req.FriendIds {
|
||||
target = this.module.modelFriend.GetFriend(v)
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -88,7 +94,11 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (errda
|
||||
|
||||
// 今日送出的友情点是否达到上限
|
||||
if ue.FriendPointOD >= this.module.globalConf.FriendMaxsendnum {
|
||||
code = pb.ErrorCode_FriendPointLimit
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendPointLimit,
|
||||
Title: pb.ErrorCode_FriendPointLimit.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -108,10 +118,7 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (errda
|
||||
Flag: true,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeZan, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeZan, rsp)
|
||||
|
||||
// 赠送X次友情点
|
||||
// this.moduleFriend.ModuleRtask.SendToRtask(session, comm.Rtype11, 1)
|
||||
|
@ -23,7 +23,10 @@ func (this *apiComp) Zanlist(session comm.IUserSession, req *pb.FriendZanlistReq
|
||||
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -37,10 +40,7 @@ func (this *apiComp) Zanlist(session comm.IUserSession, req *pb.FriendZanlistReq
|
||||
rsp := &pb.FriendZanlistResp{
|
||||
List: list,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeZanList, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeZanList, rsp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -32,7 +32,10 @@ func (this *apiComp) Zanreceive(session comm.IUserSession, req *pb.FriendZanrece
|
||||
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendSelfNoData,
|
||||
Title: pb.ErrorCode_FriendSelfNoData.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -73,7 +76,10 @@ func (this *apiComp) Zanreceive(session comm.IUserSession, req *pb.FriendZanrece
|
||||
|
||||
// 今日获赠的友情点是否达到上限
|
||||
if ue.FriendPointID >= int32(this.module.globalConf.FriendMaxgetnum) {
|
||||
code = pb.ErrorCode_FriendPointLimit
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_FriendPointLimit,
|
||||
Title: pb.ErrorCode_FriendPointLimit.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -90,11 +96,8 @@ func (this *apiComp) Zanreceive(session comm.IUserSession, req *pb.FriendZanrece
|
||||
return
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeZanreceive,
|
||||
&pb.FriendZanreceiveResp{Flag: true}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeZanreceive,
|
||||
&pb.FriendZanreceiveResp{Flag: true})
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user