修改api check
This commit is contained in:
parent
5b479b32de
commit
b4ec3d86fb
@ -1,14 +1,17 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
)
|
||||
|
||||
func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.FriendBlackAddReq) (result map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//加入黑名单
|
||||
func (this *ApiComp) Addblack(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackAddReq) (err error) {
|
||||
func (this *ApiComp) Addblack(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendBlackAddReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
self *pb.DB_FriendData
|
||||
@ -61,6 +64,6 @@ func (this *ApiComp) Addblack(ctx context.Context, session comm.IUserSession, re
|
||||
self.BlackIds = append(self.BlackIds, req.FriendId)
|
||||
|
||||
//更新黑名单
|
||||
this.module.model_friend.SetObj(self.UserId, self, false)
|
||||
this.module.model_friend.SetObj(self.UserId, self, false, true)
|
||||
return nil
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
)
|
||||
|
||||
func (this *ApiComp) Agree_Check(session comm.IUserSession, req *pb.FriendAgreeReq) (result map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//单个/批量同意
|
||||
func (this *ApiComp) Agree(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeReq) (err error) {
|
||||
func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendAgreeReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
self *pb.DB_FriendData
|
||||
@ -49,7 +52,7 @@ func (this *ApiComp) Agree(ctx context.Context, session comm.IUserSession, req *
|
||||
if _, ok := utils.Find(target.FriendIds, self.UserId); !ok {
|
||||
target.FriendIds = append(target.FriendIds, self.UserId)
|
||||
}
|
||||
this.module.model_friend.SetObj(target.UserId, target, false)
|
||||
this.module.model_friend.SetObj(target.UserId, target, false, true)
|
||||
}
|
||||
|
||||
//将申请人从申请列表中删除
|
||||
@ -59,5 +62,5 @@ func (this *ApiComp) Agree(ctx context.Context, session comm.IUserSession, req *
|
||||
}
|
||||
|
||||
//更新
|
||||
return this.module.model_friend.SetObj(self.UserId, self, false)
|
||||
return this.module.model_friend.SetObj(self.UserId, self, false, true)
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
)
|
||||
|
||||
func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.FriendApplyReq) (chk map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//好友申请
|
||||
func (this *ApiComp) Apply(ctx context.Context, session comm.IUserSession, req *pb.FriendApplyReq) (err error) {
|
||||
func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendApplyReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
self *pb.DB_FriendData
|
||||
@ -94,7 +97,7 @@ func (this *ApiComp) Apply(ctx context.Context, session comm.IUserSession, req *
|
||||
err = this.module.model_friend.SetObj(req.FriendId, &pb.DB_FriendData{
|
||||
UserId: req.FriendId,
|
||||
ApplyIds: target.ApplyIds,
|
||||
}, false)
|
||||
}, false, true)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("firend Apply err:%v", err)
|
||||
|
@ -1,13 +1,16 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *ApiComp) ApplyList_Check(session comm.IUserSession, req *pb.FriendApplyListReq) (chk map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//申请列表
|
||||
func (this *ApiComp) ApplyList(ctx context.Context, session comm.IUserSession, req *pb.FriendApplyListReq) (err error) {
|
||||
func (this *ApiComp) ApplyList(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendApplyListReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
self *pb.DB_FriendData
|
||||
|
@ -1,13 +1,16 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *ApiComp) Blacklist_Check(session comm.IUserSession, req *pb.FriendBlackListReq) (chk map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//黑名单
|
||||
func (this *ApiComp) Blacklist(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackListReq) (err error) {
|
||||
func (this *ApiComp) Blacklist(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendBlackListReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
self *pb.DB_FriendData
|
||||
|
@ -1,12 +1,15 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *ApiComp) Del_Check(session comm.IUserSession, req *pb.FriendDelReq) (chk map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//删除好友
|
||||
func (this *ApiComp) Del(ctx context.Context, session comm.IUserSession, req *pb.FriendDelReq) error {
|
||||
func (this *ApiComp) Del(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendDelReq) error {
|
||||
return nil
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
)
|
||||
|
||||
func (this *ApiComp) Delblack_Check(session comm.IUserSession, req *pb.FriendDelBlackReq) (chk map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//删除黑名单
|
||||
func (this *ApiComp) delblack(ctx context.Context, session comm.IUserSession, req *pb.FriendDelBlackReq) (err error) {
|
||||
func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendDelBlackReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
self *pb.DB_FriendData
|
||||
@ -32,6 +35,6 @@ func (this *ApiComp) delblack(ctx context.Context, session comm.IUserSession, re
|
||||
//从黑名单列表中删除目标
|
||||
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
||||
//更新黑名单
|
||||
return this.module.model_friend.SetObj(self.UserId, self, false)
|
||||
return this.module.model_friend.SetObj(self.UserId, self, false, true)
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *ApiComp) List_Check(session comm.IUserSession, req *pb.FriendListReq) (chk map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//好友列表
|
||||
func (this *ApiComp) List(ctx context.Context, session comm.IUserSession, req *pb.FriendListReq) (err error) {
|
||||
func (this *ApiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendListReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
self *pb.DB_FriendData
|
||||
|
@ -1,14 +1,17 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
)
|
||||
|
||||
func (this *ApiComp) Refuse_Check(session comm.IUserSession, req *pb.FriendRefuseReq) (chk map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//单个/批量拒绝
|
||||
func (this *ApiComp) Refuse(ctx context.Context, session comm.IUserSession, req *pb.FriendRefuseReq) (err error) {
|
||||
func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendRefuseReq) (err error) {
|
||||
//将申请人从申请列表中删除
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
@ -38,5 +41,5 @@ func (this *ApiComp) Refuse(ctx context.Context, session comm.IUserSession, req
|
||||
}
|
||||
|
||||
//更新
|
||||
return this.module.model_friend.SetObj(self.UserId, self, false)
|
||||
return this.module.model_friend.SetObj(self.UserId, self, false, true)
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *ApiComp) Search_Check(session comm.IUserSession, req *pb.FriendSearchReq) (chk map[string]interface{}, code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
//搜索
|
||||
func (this *ApiComp) Search(ctx context.Context, session comm.IUserSession, req *pb.FriendSearchReq) error {
|
||||
func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendSearchReq) error {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
rsp *pb.FriendSearchRsp
|
||||
@ -22,7 +25,7 @@ func (this *ApiComp) Search(ctx context.Context, session comm.IUserSession, req
|
||||
session.SendMsg(string(this.module.GetType()), Friend_SubType_Search, code, rsp)
|
||||
}()
|
||||
|
||||
user :=this.module.model_friend.Frined_FindCond(req.NickName)
|
||||
user := this.module.model_friend.Frined_FindCond(req.NickName)
|
||||
if user != nil {
|
||||
friend = &pb.FriendBase{
|
||||
UserId: user.Uid,
|
||||
|
@ -98,34 +98,40 @@ func (this *Model_Comp) UpdateModelLogs(table string, uID string, where interfac
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *Model_Comp) SetObj(uid string, data proto.Message, isnew bool) error {
|
||||
func (this *Model_Comp) SetObj(uid string, data proto.Message, isnew, islog bool) error {
|
||||
err := this.Redis.Set(fmt.Sprintf("%s:%s", this.Prefix, uid), data, 0)
|
||||
if err != nil {
|
||||
log.Errorf("set err:%v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if isnew {
|
||||
return this.InsertModelLogs(this.Prefix, uid, data)
|
||||
} else {
|
||||
return this.UpdateModelLogs(this.Prefix, uid, bson.M{"_id": uid}, data)
|
||||
if islog {
|
||||
if isnew {
|
||||
return this.InsertModelLogs(this.Prefix, uid, data)
|
||||
} else {
|
||||
return this.UpdateModelLogs(this.Prefix, uid, bson.M{"_id": uid}, data)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//更新缓存字段
|
||||
//isnew true insertlog , false updatelog
|
||||
func (this *Model_Comp) Set(uid string, v map[string]interface{}, isnew bool) error {
|
||||
func (this *Model_Comp) Set(uid string, v map[string]interface{}, isnew, islog bool) error {
|
||||
err := this.Redis.HMSet(fmt.Sprintf("%s:%s", this.Prefix, uid), v)
|
||||
if err != nil {
|
||||
log.Errorf("set err:%v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if isnew {
|
||||
return this.InsertModelLogs(this.Prefix, uid, v)
|
||||
} else {
|
||||
return this.UpdateModelLogs(this.Prefix, uid, bson.M{"_id": uid}, v)
|
||||
if islog {
|
||||
if isnew {
|
||||
return this.InsertModelLogs(this.Prefix, uid, v)
|
||||
} else {
|
||||
return this.UpdateModelLogs(this.Prefix, uid, bson.M{"_id": uid}, v)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Model_Comp) GetObj(uid string, v interface{}) error {
|
||||
|
@ -24,7 +24,7 @@ func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interf
|
||||
update := map[string]interface{}{
|
||||
"name": req.NickName,
|
||||
}
|
||||
err = this.module.modelUser.Set(session.GetUserId(), update, false)
|
||||
err = this.module.modelUser.Set(session.GetUserId(), update, false, true)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -86,20 +86,20 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
||||
return
|
||||
}
|
||||
session.Bind(user.Uid, this.service.GetId())
|
||||
cache_user.Uid = user.Uid
|
||||
// data := map[string]interface{}{
|
||||
// "sessionId": cache_user.SessionId,
|
||||
// "gatewayServiceId": cache_user.GatewayServiceId,
|
||||
// }
|
||||
data := &pb.Cache_UserData{
|
||||
Uid: user.Uid,
|
||||
SessionId: cache_user.SessionId,
|
||||
GatewayServiceId: cache_user.GatewayServiceId,
|
||||
}
|
||||
return this.module.modelUser.SetObj(cache_user.Uid, data, true)
|
||||
return this.module.modelUser.SetObj(cache_user.Uid, data, true, true)
|
||||
} else {
|
||||
session.Bind(db_user.Uid, this.service.GetId())
|
||||
cache_user.Uid = db_user.Uid
|
||||
data := &pb.Cache_UserData{
|
||||
Uid: db_user.Uid,
|
||||
SessionId: cache_user.SessionId,
|
||||
GatewayServiceId: cache_user.GatewayServiceId,
|
||||
}
|
||||
@ -107,6 +107,6 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
||||
// "sessionId": cache_user.SessionId,
|
||||
// "gatewayServiceId": cache_user.GatewayServiceId,
|
||||
// }
|
||||
return this.module.modelUser.SetObj(cache_user.Uid, data, false)
|
||||
return this.module.modelUser.SetObj(cache_user.Uid, data, false, false)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user