优化错误日志
This commit is contained in:
parent
1016daf1be
commit
77258d5004
@ -36,7 +36,7 @@ func (this *apiComp) Del(session comm.IUserSession, req *pb.FriendDelReq) (code
|
|||||||
if err := this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
|
if err := this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
|
||||||
"friendIds": selfFriendIds,
|
"friendIds": selfFriendIds,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Errorf("Del friend err:%v", err)
|
this.moduleFriend.Error("删除好友", log.Fields{"uid": uid, "params": req, "err": err.Error()})
|
||||||
code = pb.ErrorCode_FriendApplyError
|
code = pb.ErrorCode_FriendApplyError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,22 @@ package friend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//删除黑名单
|
||||||
func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode) {
|
func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode) {
|
||||||
if req.FriendId == "" {
|
if req.FriendId == "" {
|
||||||
code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除黑名单
|
|
||||||
func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
if code = this.DelblackCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.DelblackCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
@ -23,22 +25,8 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR
|
|||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
Resp *pb.FriendDelBlackResp
|
|
||||||
)
|
)
|
||||||
defer func() {
|
uid := session.GetUserId()
|
||||||
if code == pb.ErrorCode_Success {
|
|
||||||
Resp = &pb.FriendDelBlackResp{
|
|
||||||
FriendId: req.FriendId,
|
|
||||||
UserId: session.GetUserId(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeDelBlack, Resp)
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_SystemError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
||||||
if self == nil {
|
if self == nil {
|
||||||
code = pb.ErrorCode_FriendSelfNoData
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
@ -48,13 +36,22 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR
|
|||||||
//从黑名单列表中删除目标
|
//从黑名单列表中删除目标
|
||||||
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
||||||
//更新黑名单
|
//更新黑名单
|
||||||
err = this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
|
if err = this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
|
||||||
"blackIds": self.BlackIds,
|
"blackIds": self.BlackIds,
|
||||||
})
|
}); err != nil {
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
|
this.moduleFriend.Error("删除黑名单", log.Fields{"uid": uid, "err": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resp := &pb.FriendDelBlackResp{
|
||||||
|
FriendId: req.FriendId,
|
||||||
|
UserId: session.GetUserId(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeDelBlack, resp); err != nil {
|
||||||
|
code = pb.ErrorCode_SystemError
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,15 @@ import (
|
|||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 领取奖励
|
||||||
func (this *apiComp) GetrewardCheck(session comm.IUserSession, req *pb.FriendGetrewardReq) (code pb.ErrorCode) {
|
func (this *apiComp) GetrewardCheck(session comm.IUserSession, req *pb.FriendGetrewardReq) (code pb.ErrorCode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewardReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewardReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
uid := session.GetUserId()
|
||||||
//获取玩家自己好友数据
|
//获取玩家自己好友数据
|
||||||
self := this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
self := this.moduleFriend.modelFriend.GetFriend(uid)
|
||||||
if self == nil {
|
if self == nil {
|
||||||
code = pb.ErrorCode_FriendSelfNoData
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
return
|
return
|
||||||
@ -30,12 +32,15 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar
|
|||||||
"received": received,
|
"received": received,
|
||||||
}
|
}
|
||||||
if err := this.moduleFriend.modelFriend.Change(self.Uid, update); err != nil {
|
if err := this.moduleFriend.modelFriend.Change(self.Uid, update); err != nil {
|
||||||
log.Errorf("Assisthero err:%v", err)
|
|
||||||
code = pb.ErrorCode_FriendApplyError
|
code = pb.ErrorCode_FriendApplyError
|
||||||
|
this.moduleFriend.Error("领奖", log.Fields{"uid": uid, "err": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
code = this.moduleFriend.DispenseRes(session, this.moduleFriend.globalConf.FriendPeize, true)
|
if code = this.moduleFriend.DispenseRes(session, this.moduleFriend.globalConf.FriendPeize, true); code != pb.ErrorCode_Success {
|
||||||
|
this.moduleFriend.Error("好友领奖励", log.Fields{"uid": uid, "reward": this.moduleFriend.globalConf.FriendPeize, "code": code})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
rsp := &pb.FriendGetrewardResp{Received: int32(received)}
|
rsp := &pb.FriendGetrewardResp{Received: int32(received)}
|
||||||
|
|
||||||
|
@ -8,29 +8,18 @@ import (
|
|||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//好友列表
|
||||||
|
|
||||||
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode) {
|
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//好友列表
|
|
||||||
func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
Resp *pb.FriendListResp
|
|
||||||
list []*pb.FriendBase
|
list []*pb.FriendBase
|
||||||
)
|
)
|
||||||
|
|
||||||
defer func() {
|
|
||||||
Resp = &pb.FriendListResp{
|
|
||||||
List: list,
|
|
||||||
}
|
|
||||||
err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeList, Resp)
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_SystemError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
||||||
if self == nil {
|
if self == nil {
|
||||||
code = pb.ErrorCode_FriendSelfNoData
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
@ -68,5 +57,13 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (cod
|
|||||||
list = append(list, base)
|
list = append(list, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resp := &pb.FriendListResp{
|
||||||
|
List: list,
|
||||||
|
}
|
||||||
|
err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeList, resp)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_SystemError
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import (
|
|||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 好友推荐
|
||||||
|
|
||||||
func (this *apiComp) RandlistCheck(session comm.IUserSession, req *pb.FriendRandlistReq) (code pb.ErrorCode) {
|
func (this *apiComp) RandlistCheck(session comm.IUserSession, req *pb.FriendRandlistReq) (code pb.ErrorCode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,18 @@ package friend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 好友审核-拒绝
|
||||||
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.FriendRefuseReq) (code pb.ErrorCode) {
|
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.FriendRefuseReq) (code pb.ErrorCode) {
|
||||||
if len(req.FriendIds) == 0 {
|
if len(req.FriendIds) == 0 {
|
||||||
code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -21,26 +24,15 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq)
|
|||||||
if code = this.RefuseCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.RefuseCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
uid := session.GetUserId()
|
||||||
//将申请人从申请列表中删除
|
//将申请人从申请列表中删除
|
||||||
var (
|
var (
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
Resp *pb.FriendRefuseResp
|
|
||||||
optNum int32
|
optNum int32
|
||||||
)
|
)
|
||||||
defer func() {
|
|
||||||
Resp = &pb.FriendRefuseResp{
|
|
||||||
Num: optNum,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeRefuse, Resp)
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_SystemError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
//获取玩家自己好友数据
|
//获取玩家自己好友数据
|
||||||
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
self = this.moduleFriend.modelFriend.GetFriend(uid)
|
||||||
if self == nil {
|
if self == nil {
|
||||||
code = pb.ErrorCode_FriendSelfNoData
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
return
|
return
|
||||||
@ -56,19 +48,29 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq)
|
|||||||
|
|
||||||
//将申请人从申请列表中删除
|
//将申请人从申请列表中删除
|
||||||
for _, userId := range refuseIds {
|
for _, userId := range refuseIds {
|
||||||
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
|
self.ApplyIds = utils.Deletex(self.ApplyIds, userId)
|
||||||
optNum++
|
optNum++
|
||||||
}
|
}
|
||||||
//更新
|
//更新
|
||||||
if optNum > 0 {
|
if optNum > 0 {
|
||||||
err := this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
|
if err := this.moduleFriend.modelFriend.Change(self.Uid, map[string]interface{}{
|
||||||
"applyIds": self.ApplyIds,
|
"applyIds": self.ApplyIds,
|
||||||
})
|
}); err != nil {
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
|
this.moduleFriend.Error("好友审批拒绝", log.Fields{"uid": uid, "params": req, "err": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resp := &pb.FriendRefuseResp{
|
||||||
|
Num: optNum,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeRefuse, resp)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_SystemError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,31 +2,34 @@ package friend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//搜索
|
||||||
func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.FriendSearchReq) (code pb.ErrorCode) {
|
func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.FriendSearchReq) (code pb.ErrorCode) {
|
||||||
if req.NickName == "" {
|
if req.NickName == "" {
|
||||||
code = pb.ErrorCode_FriendSearchNameEmpty
|
code = pb.ErrorCode_FriendSearchNameEmpty
|
||||||
|
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//搜索
|
|
||||||
func (this *apiComp) Search(session comm.IUserSession, req *pb.FriendSearchReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Search(session comm.IUserSession, req *pb.FriendSearchReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
if code = this.SearchCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.SearchCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uid := session.GetUserId()
|
||||||
resp := &pb.FriendSearchResp{}
|
resp := &pb.FriendSearchResp{}
|
||||||
|
|
||||||
users, err := this.moduleFriend.ModuleUser.SearchRmoteUser(req.NickName)
|
users, err := this.moduleFriend.ModuleUser.SearchRmoteUser(req.NickName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
this.moduleFriend.Errorf("搜索玩家 err:%v", err)
|
this.moduleFriend.Error("搜索玩家", log.Fields{"uid": uid, "params": req.NickName, "err": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package friend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ import (
|
|||||||
func (this *apiComp) ZanCheck(session comm.IUserSession, req *pb.FriendZanReq) (code pb.ErrorCode) {
|
func (this *apiComp) ZanCheck(session comm.IUserSession, req *pb.FriendZanReq) (code pb.ErrorCode) {
|
||||||
if len(req.FriendIds) == 0 {
|
if len(req.FriendIds) == 0 {
|
||||||
code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -27,6 +29,7 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
|
|||||||
selfId string
|
selfId string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
uid := session.GetUserId()
|
||||||
selfId = session.GetUserId()
|
selfId = session.GetUserId()
|
||||||
|
|
||||||
// 不能给自己点赞
|
// 不能给自己点赞
|
||||||
@ -49,7 +52,6 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := utils.Find(target.ZanIds, selfId); !ok {
|
if _, ok := utils.Find(target.ZanIds, selfId); !ok {
|
||||||
|
|
||||||
pointTotal += 1
|
pointTotal += 1
|
||||||
target.ZanIds = append(target.ZanIds, selfId)
|
target.ZanIds = append(target.ZanIds, selfId)
|
||||||
//设置被点赞玩家
|
//设置被点赞玩家
|
||||||
@ -57,6 +59,7 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code
|
|||||||
"zanIds": target.ZanIds,
|
"zanIds": target.ZanIds,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
|
this.moduleFriend.Error("点赞", log.Fields{"uid": uid, "err": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
// 点赞列表
|
// 点赞列表
|
||||||
func (this *apiComp) ZanlistCheck(session comm.IUserSession, req *pb.FriendZanlistReq) (code pb.ErrorCode) {
|
func (this *apiComp) ZanlistCheck(session comm.IUserSession, req *pb.FriendZanlistReq) (code pb.ErrorCode) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package friend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ import (
|
|||||||
func (this *apiComp) ZanreceiveCheck(session comm.IUserSession, req *pb.FriendZanreceiveReq) (code pb.ErrorCode) {
|
func (this *apiComp) ZanreceiveCheck(session comm.IUserSession, req *pb.FriendZanreceiveReq) (code pb.ErrorCode) {
|
||||||
if len(req.FriendIds) == 0 {
|
if len(req.FriendIds) == 0 {
|
||||||
code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,13 @@ func (this *ModelFriend) Init(service core.IService, module core.IModule, comp c
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DBUser {
|
func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DBUser {
|
||||||
var user *pb.DBUser
|
var user *pb.DBUser
|
||||||
err := this.DB.FindOne(comm.TableUser, bson.M{
|
err := this.DB.FindOne(comm.TableUser, bson.M{
|
||||||
"name": nickName,
|
"name": nickName,
|
||||||
}).Decode(&user)
|
}).Decode(&user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("findCond err:%v", err)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return user
|
return user
|
||||||
@ -45,7 +45,7 @@ func (this *ModelFriend) GetFriend(uid string) *pb.DBFriend {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Errorf("GetFriend err:%v", err)
|
log.Error("未获得好友数据", log.Fields{"uid": uid})
|
||||||
}
|
}
|
||||||
return friend
|
return friend
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func (this *Friend) ResetFriend(uid string) {
|
|||||||
"received": 0, //奖励状态重置
|
"received": 0, //奖励状态重置
|
||||||
}
|
}
|
||||||
if err := this.modelFriend.Change(uid, zanUpdate); err != nil {
|
if err := this.modelFriend.Change(uid, zanUpdate); err != nil {
|
||||||
log.Error("resetZanFriend err", log.Fields{"err": err})
|
log.Error("重置玩家点赞数据", log.Fields{"uid": uid, "err": err})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置今日友情点
|
// 重置今日友情点
|
||||||
@ -80,7 +80,7 @@ func (this *Friend) ResetFriend(uid string) {
|
|||||||
"friendPointOD": 0,
|
"friendPointOD": 0,
|
||||||
}
|
}
|
||||||
if err := this.ModuleUser.ChangeUserExpand(uid, update); err != nil {
|
if err := this.ModuleUser.ChangeUserExpand(uid, update); err != nil {
|
||||||
log.Error("resetFriend err", log.Fields{"err": err})
|
log.Error("重置今日友情点", log.Fields{"uid": uid, "err": err})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -110,6 +110,7 @@ func (this *Friend) RpcUseAssisHero(ctx context.Context, req *pb.RPCGeneralReqA2
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 使用好友助战英雄
|
// 使用好友助战英雄
|
||||||
|
// friendId 好友Id
|
||||||
func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) {
|
func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) {
|
||||||
//指定好友
|
//指定好友
|
||||||
friend := this.modelFriend.GetFriend(friendId)
|
friend := this.modelFriend.GetFriend(friendId)
|
||||||
@ -125,7 +126,7 @@ func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) {
|
|||||||
for _, r := range friend.Record {
|
for _, r := range friend.Record {
|
||||||
if r.AssistHeroId == friend.AssistHeroId {
|
if r.AssistHeroId == friend.AssistHeroId {
|
||||||
if utils.IsToday(r.AssistTime) {
|
if utils.IsToday(r.AssistTime) {
|
||||||
log.Warnf("今日已助战 uid:%v friendId:%v heroId:%v", uid, friendId, r.AssistHeroId)
|
log.Warn("今日已助战", log.Fields{"uid": uid, "friendId": friend, "assistHeroId": r.AssistHeroId})
|
||||||
return nil, errors.New("今日已助战")
|
return nil, errors.New("今日已助战")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
|
|
||||||
4、修改玩家经验值:bingo:attr,exp,1000(1000代表新增的经验值 //
|
4、修改玩家经验值:bingo:attr,exp,1000(1000代表新增的经验值 //
|
||||||
|
|
||||||
5、跳过随机任务 bingo:rtask,1,1001
|
5、跳过随机任务 bingo:worldtask,1,1001
|
||||||
6、bingo:Iamyoudad
|
6、bingo:Iamyoudad
|
||||||
7、bingo:vip,yueka_1,1 // 月卡类型
|
7、bingo:vip,yueka_1,1 // 月卡类型
|
||||||
*/
|
*/
|
||||||
|
@ -2,6 +2,7 @@ package task
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
@ -22,18 +23,9 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
|||||||
if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
uid := session.GetUserId()
|
||||||
resp := &pb.TaskReceiveResp{}
|
|
||||||
defer func() {
|
|
||||||
err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeReceive, resp)
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_SystemError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// 获取待领取的任务
|
// 获取待领取的任务
|
||||||
userTask := this.moduleTask.modelTask.getUserTask(session.GetUserId(), req.Id)
|
userTask := this.moduleTask.modelTask.getUserTask(uid, req.Id)
|
||||||
|
|
||||||
if userTask == nil {
|
if userTask == nil {
|
||||||
code = pb.ErrorCode_TaskNotFound
|
code = pb.ErrorCode_TaskNotFound
|
||||||
@ -88,6 +80,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
|||||||
|
|
||||||
//奖励
|
//奖励
|
||||||
if code = this.moduleTask.DispenseRes(session, conf.Reword, true); code != pb.ErrorCode_Success {
|
if code = this.moduleTask.DispenseRes(session, conf.Reword, true); code != pb.ErrorCode_Success {
|
||||||
|
this.moduleTask.Error("发送奖励", log.Fields{"uid": uid, "reward": conf.Reword, "code": code})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +93,15 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.TaskId = userTask.TaskId
|
resp := &pb.TaskReceiveResp{
|
||||||
|
TaskId: userTask.TaskId,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := session.SendMsg(string(this.moduleTask.GetType()), TaskSubTypeReceive, resp)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_SystemError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 监听玩家经验
|
// 监听玩家经验
|
||||||
this.moduleTask.ModuleUser.EventUserChanged(session)
|
this.moduleTask.ModuleUser.EventUserChanged(session)
|
||||||
|
@ -2,6 +2,7 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"strings"
|
"strings"
|
||||||
@ -13,6 +14,7 @@ func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateRe
|
|||||||
name := strings.TrimSpace(req.NickName)
|
name := strings.TrimSpace(req.NickName)
|
||||||
if name == "" || len(name) > 30 {
|
if name == "" || len(name) > 30 {
|
||||||
code = pb.ErrorCode_UserNickNameEmpty
|
code = pb.ErrorCode_UserNickNameEmpty
|
||||||
|
this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -24,6 +26,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uid := session.GetUserId()
|
||||||
//获取用户
|
//获取用户
|
||||||
self := this.module.modelUser.GetUser(session.GetUserId())
|
self := this.module.modelUser.GetUser(session.GetUserId())
|
||||||
if self == nil {
|
if self == nil {
|
||||||
@ -57,9 +60,9 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
|||||||
update["avatar"] = globalConf.GirlHeadPortrait
|
update["avatar"] = globalConf.GirlHeadPortrait
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil {
|
if err := this.module.modelUser.Change(uid, update); err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
this.module.Errorf("创角失败 uid:%v name:%v err:%v", session.GetUserId(), req.NickName, err)
|
this.module.Error("创角", log.Fields{"uid": uid, "params": update, "err": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +72,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
|||||||
}
|
}
|
||||||
if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), initUpdate); err != nil {
|
if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), initUpdate); err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
this.module.Errorf("更新修改名称次数失败 uid:%v err:%v", session.GetUserId(), err)
|
this.module.Error("创建初始修改名称次数", log.Fields{"uid": uid, "param": initUpdate, "err": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
@ -2,6 +2,7 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
@ -16,9 +17,10 @@ func (this *apiComp) GetTujian(session comm.IUserSession, req *pb.UserGetTujianR
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uid := session.GetUserId()
|
||||||
rsp := &pb.UserGetTujianResp{}
|
rsp := &pb.UserGetTujianResp{}
|
||||||
if result, err := this.module.modelExpand.GetUserExpand(session.GetUserId()); err != nil {
|
if result, err := this.module.modelExpand.GetUserExpand(uid); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Error("玩家扩展数据", log.Fields{"uid": uid, "err": err.Error()})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
for k := range result.Tujian {
|
for k := range result.Tujian {
|
||||||
|
@ -21,6 +21,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.UserInfoReq) (code
|
|||||||
ue, err := this.module.GetUserExpand(session.GetUserId())
|
ue, err := this.module.GetUserExpand(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp := &pb.UserInfoResp{
|
rsp := &pb.UserInfoResp{
|
||||||
|
@ -47,7 +47,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
|||||||
user, err = this.module.modelUser.FindByAccount(req.Sid, req.Account)
|
user, err = this.module.modelUser.FindByAccount(req.Sid, req.Account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != mongo.ErrNoDocuments {
|
if err != mongo.ErrNoDocuments {
|
||||||
log.Errorf("User_FindByAccount err %v", err)
|
log.Error("User_FindByAccount", log.Fields{"sid": req.Sid, "account": req.Account, "err": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user