修改errcode
This commit is contained in:
parent
ee5f7f899e
commit
10941376f1
@ -27,7 +27,7 @@ func (this *ApiComp) Addblack(session comm.IUserSession, chk map[string]interfac
|
|||||||
UserId: session.GetUserId(),
|
UserId: session.GetUserId(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = this.module.model_friend.GetObj(session.GetUserId(), self)
|
err = this.module.model_friend.GetObj(session.GetUserId(), self)
|
||||||
@ -65,5 +65,5 @@ func (this *ApiComp) Addblack(session comm.IUserSession, chk map[string]interfac
|
|||||||
|
|
||||||
//更新黑名单
|
//更新黑名单
|
||||||
this.module.model_friend.SetObj(self.UserId, self, false, true)
|
this.module.model_friend.SetObj(self.UserId, self, false, true)
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,8 @@ func (this *ApiComp) Agree_Check(session comm.IUserSession, req *pb.FriendAgreeR
|
|||||||
}
|
}
|
||||||
|
|
||||||
//单个/批量同意
|
//单个/批量同意
|
||||||
func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendAgreeReq) (err error) {
|
func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendAgreeReq) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
rsp *pb.FriendAgreeRsp
|
rsp *pb.FriendAgreeRsp
|
||||||
optNum int32
|
optNum int32
|
||||||
@ -48,7 +47,7 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}
|
|||||||
Num: optNum,
|
Num: optNum,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_Agree, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_Agree, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; !ok {
|
if v, ok := chk["self"]; !ok {
|
||||||
@ -92,8 +91,12 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新
|
//更新
|
||||||
return this.module.model_friend.SetObj(self.UserId, self, false, true)
|
err := this.module.model_friend.SetObj(self.UserId, self, false, true)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -79,9 +79,8 @@ func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.FriendApplyR
|
|||||||
}
|
}
|
||||||
|
|
||||||
//好友申请
|
//好友申请
|
||||||
func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendApplyReq) (err error) {
|
func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendApplyReq) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
|
||||||
target *pb.DB_FriendData
|
target *pb.DB_FriendData
|
||||||
rsp *pb.FriendApplyRsp
|
rsp *pb.FriendApplyRsp
|
||||||
)
|
)
|
||||||
@ -97,7 +96,7 @@ func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{}
|
|||||||
FriendId: req.FriendId,
|
FriendId: req.FriendId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_Apply, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_Apply, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["target"]; !ok {
|
if v, ok := chk["target"]; !ok {
|
||||||
@ -113,7 +112,7 @@ func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{}
|
|||||||
}
|
}
|
||||||
target.ApplyIds = append(target.ApplyIds, session.GetUserId())
|
target.ApplyIds = append(target.ApplyIds, session.GetUserId())
|
||||||
|
|
||||||
err = this.module.model_friend.SetObj(req.FriendId, target, false, true)
|
err := this.module.model_friend.SetObj(req.FriendId, target, false, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("firend Apply err:%v", err)
|
log.Errorf("firend Apply err:%v", err)
|
||||||
|
@ -10,9 +10,8 @@ func (this *ApiComp) ApplyList_Check(session comm.IUserSession, req *pb.FriendAp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//申请列表
|
//申请列表
|
||||||
func (this *ApiComp) ApplyList(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendApplyListReq) (err error) {
|
func (this *ApiComp) ApplyList(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendApplyListReq) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
rsp *pb.FriendApplyListRsp
|
rsp *pb.FriendApplyListRsp
|
||||||
list []*pb.FriendBase
|
list []*pb.FriendBase
|
||||||
@ -24,10 +23,10 @@ func (this *ApiComp) ApplyList(session comm.IUserSession, chk map[string]interfa
|
|||||||
List: list,
|
List: list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_ApplyList, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_ApplyList, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = this.module.model_friend.GetObj(session.GetUserId(), self)
|
err := this.module.model_friend.GetObj(session.GetUserId(), self)
|
||||||
if self == nil || err != nil {
|
if self == nil || err != nil {
|
||||||
code = pb.ErrorCode_FriendSelfNoData
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
return
|
return
|
||||||
@ -40,5 +39,5 @@ func (this *ApiComp) ApplyList(session comm.IUserSession, chk map[string]interfa
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,8 @@ func (this *ApiComp) Blacklist_Check(session comm.IUserSession, req *pb.FriendBl
|
|||||||
}
|
}
|
||||||
|
|
||||||
//黑名单
|
//黑名单
|
||||||
func (this *ApiComp) Blacklist(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendBlackListReq) (err error) {
|
func (this *ApiComp) Blacklist(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendBlackListReq) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
rsp *pb.FriendBlackListRsp
|
rsp *pb.FriendBlackListRsp
|
||||||
list []*pb.FriendBase
|
list []*pb.FriendBase
|
||||||
@ -24,10 +23,10 @@ func (this *ApiComp) Blacklist(session comm.IUserSession, chk map[string]interfa
|
|||||||
Friends: list,
|
Friends: list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_Blacklist, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_Blacklist, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = this.module.model_friend.GetObj(session.GetUserId(), self)
|
err := this.module.model_friend.GetObj(session.GetUserId(), self)
|
||||||
if self == nil || err != nil {
|
if self == nil || err != nil {
|
||||||
code = pb.ErrorCode_FriendSelfNoData
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
return
|
return
|
||||||
@ -40,5 +39,5 @@ func (this *ApiComp) Blacklist(session comm.IUserSession, chk map[string]interfa
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,8 @@ func (this *ApiComp) Delblack_Check(session comm.IUserSession, req *pb.FriendDel
|
|||||||
}
|
}
|
||||||
|
|
||||||
//删除黑名单
|
//删除黑名单
|
||||||
func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendDelBlackReq) (err error) {
|
func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendDelBlackReq) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
rsp *pb.FriendDelBlackRsp
|
rsp *pb.FriendDelBlackRsp
|
||||||
)
|
)
|
||||||
@ -24,9 +23,9 @@ func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interfac
|
|||||||
UserId: session.GetUserId(),
|
UserId: session.GetUserId(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, rsp)
|
||||||
}()
|
}()
|
||||||
err = this.module.model_friend.GetObj(session.GetUserId(), self)
|
err := this.module.model_friend.GetObj(session.GetUserId(), self)
|
||||||
if self == nil || err != nil {
|
if self == nil || err != nil {
|
||||||
code = pb.ErrorCode_FriendSelfNoData
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
return
|
return
|
||||||
@ -35,6 +34,10 @@ func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interfac
|
|||||||
//从黑名单列表中删除目标
|
//从黑名单列表中删除目标
|
||||||
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
||||||
//更新黑名单
|
//更新黑名单
|
||||||
return this.module.model_friend.SetObj(self.UserId, self, false, true)
|
err = this.module.model_friend.SetObj(self.UserId, self, false, true)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,8 @@ func (this *ApiComp) List_Check(session comm.IUserSession, req *pb.FriendListReq
|
|||||||
}
|
}
|
||||||
|
|
||||||
//好友列表
|
//好友列表
|
||||||
func (this *ApiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendListReq) (err error) {
|
func (this *ApiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendListReq) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
rsp *pb.FriendListRsp
|
rsp *pb.FriendListRsp
|
||||||
list []*pb.FriendBase
|
list []*pb.FriendBase
|
||||||
@ -24,10 +23,10 @@ func (this *ApiComp) List(session comm.IUserSession, chk map[string]interface{},
|
|||||||
List: list,
|
List: list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_List, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_List, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = this.module.model_friend.GetObj(session.GetUserId(), self)
|
err := this.module.model_friend.GetObj(session.GetUserId(), self)
|
||||||
if self == nil || err != nil {
|
if self == nil || err != nil {
|
||||||
code = pb.ErrorCode_FriendSelfNoData
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
return
|
return
|
||||||
@ -39,5 +38,5 @@ func (this *ApiComp) List(session comm.IUserSession, chk map[string]interface{},
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,9 @@ func (this *ApiComp) Refuse_Check(session comm.IUserSession, req *pb.FriendRefus
|
|||||||
}
|
}
|
||||||
|
|
||||||
//单个/批量拒绝
|
//单个/批量拒绝
|
||||||
func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendRefuseReq) (err error) {
|
func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendRefuseReq) (code pb.ErrorCode) {
|
||||||
//将申请人从申请列表中删除
|
//将申请人从申请列表中删除
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
rsp *pb.FriendAgreeRsp
|
rsp *pb.FriendAgreeRsp
|
||||||
optNum int32
|
optNum int32
|
||||||
@ -47,7 +46,7 @@ func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{
|
|||||||
Num: optNum,
|
Num: optNum,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_Refuse, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_Refuse, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; !ok {
|
if v, ok := chk["self"]; !ok {
|
||||||
@ -64,10 +63,14 @@ func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{
|
|||||||
}
|
}
|
||||||
//更新
|
//更新
|
||||||
if optNum > 0 {
|
if optNum > 0 {
|
||||||
return this.module.model_friend.SetObj(self.UserId, self, false, true)
|
err := this.module.model_friend.SetObj(self.UserId, self, false, true)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,8 @@ func (this *ApiComp) Search_Check(session comm.IUserSession, req *pb.FriendSearc
|
|||||||
}
|
}
|
||||||
|
|
||||||
//搜索
|
//搜索
|
||||||
func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendSearchReq) error {
|
func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendSearchReq) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
|
||||||
rsp *pb.FriendSearchRsp
|
rsp *pb.FriendSearchRsp
|
||||||
friend *pb.FriendBase
|
friend *pb.FriendBase
|
||||||
)
|
)
|
||||||
@ -22,7 +21,7 @@ func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{
|
|||||||
Friend: friend,
|
Friend: friend,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_Search, code, rsp)
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_Search, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
user := this.module.model_friend.Frined_FindCond(req.NickName)
|
user := this.module.model_friend.Frined_FindCond(req.NickName)
|
||||||
@ -32,5 +31,5 @@ func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{
|
|||||||
NickName: user.Name,
|
NickName: user.Name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -12,20 +12,20 @@ func (this *Api_Comp) Create_Check(session comm.IUserSession, req *pb.UserCreate
|
|||||||
}
|
}
|
||||||
|
|
||||||
//创角
|
//创角
|
||||||
func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interface{}, req *pb.UserCreateReq) (err error) {
|
func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interface{}, req *pb.UserCreateReq) (code pb.ErrorCode) {
|
||||||
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), User_SubType_Create, req, nil)
|
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), User_SubType_Create, req, nil)
|
||||||
var code pb.ErrorCode
|
|
||||||
self := &pb.DB_UserData{}
|
self := &pb.DB_UserData{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
session.SendMsg(string(this.module.GetType()), User_SubType_Create, code, &pb.UserCreateRsp{})
|
session.SendMsg(string(this.module.GetType()), User_SubType_Create, &pb.UserCreateRsp{})
|
||||||
}()
|
}()
|
||||||
|
|
||||||
//更新昵称
|
//更新昵称
|
||||||
// update := map[string]interface{}{
|
// update := map[string]interface{}{
|
||||||
// "name": req.NickName,
|
// "name": req.NickName,
|
||||||
// }
|
// }
|
||||||
err = this.module.modelUser.GetObj(session.GetUserId(), self)
|
err := this.module.modelUser.GetObj(session.GetUserId(), self)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
@ -38,5 +38,5 @@ func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
event.RegisterGO(comm.Event_CreateUser, session.GetUserId())
|
event.RegisterGO(comm.Event_CreateUser, session.GetUserId())
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
@ -41,15 +41,15 @@ func (this *Api_Comp) Login_Check(session comm.IUserSession, req *pb.UserLoginRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
//登录
|
//登录
|
||||||
func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (err error) {
|
func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
err error
|
||||||
db_user *pb.DB_UserData
|
db_user *pb.DB_UserData
|
||||||
)
|
)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if db_user != nil {
|
if db_user != nil {
|
||||||
session.SendMsg(string(this.module.GetType()), User_SubType_Login, code, &pb.UserLoginResp{
|
session.SendMsg(string(this.module.GetType()), User_SubType_Login, &pb.UserLoginResp{
|
||||||
Data: db_user,
|
Data: db_user,
|
||||||
})
|
})
|
||||||
event.TriggerEvent(comm.Event_UserLogin, db_user.Uid)
|
event.TriggerEvent(comm.Event_UserLogin, db_user.Uid)
|
||||||
@ -66,7 +66,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
|||||||
db_user, err = this.module.modelUser.User_FindByAccount(user)
|
db_user, err = this.module.modelUser.User_FindByAccount(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != mongo.ErrNoDocuments {
|
if err != mongo.ErrNoDocuments {
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,5 +127,5 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user