修改api check
This commit is contained in:
parent
5b479b32de
commit
b4ec3d86fb
@ -1,14 +1,17 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
self *pb.DB_FriendData
|
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)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
self *pb.DB_FriendData
|
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 {
|
if _, ok := utils.Find(target.FriendIds, self.UserId); !ok {
|
||||||
target.FriendIds = append(target.FriendIds, self.UserId)
|
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
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
self *pb.DB_FriendData
|
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{
|
err = this.module.model_friend.SetObj(req.FriendId, &pb.DB_FriendData{
|
||||||
UserId: req.FriendId,
|
UserId: req.FriendId,
|
||||||
ApplyIds: target.ApplyIds,
|
ApplyIds: target.ApplyIds,
|
||||||
}, false)
|
}, false, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("firend Apply err:%v", err)
|
log.Errorf("firend Apply err:%v", err)
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"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
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
self *pb.DB_FriendData
|
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)
|
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
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
self *pb.DB_FriendData
|
self *pb.DB_FriendData
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package friend
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
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
|
package friend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"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 (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
rsp *pb.FriendSearchRsp
|
rsp *pb.FriendSearchRsp
|
||||||
|
@ -98,35 +98,41 @@ func (this *Model_Comp) UpdateModelLogs(table string, uID string, where interfac
|
|||||||
return err
|
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)
|
err := this.Redis.Set(fmt.Sprintf("%s:%s", this.Prefix, uid), data, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("set err:%v", err)
|
log.Errorf("set err:%v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if islog {
|
||||||
if isnew {
|
if isnew {
|
||||||
return this.InsertModelLogs(this.Prefix, uid, data)
|
return this.InsertModelLogs(this.Prefix, uid, data)
|
||||||
} else {
|
} else {
|
||||||
return this.UpdateModelLogs(this.Prefix, uid, bson.M{"_id": uid}, data)
|
return this.UpdateModelLogs(this.Prefix, uid, bson.M{"_id": uid}, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
//更新缓存字段
|
//更新缓存字段
|
||||||
//isnew true insertlog , false updatelog
|
//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)
|
err := this.Redis.HMSet(fmt.Sprintf("%s:%s", this.Prefix, uid), v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("set err:%v", err)
|
log.Errorf("set err:%v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if islog {
|
||||||
if isnew {
|
if isnew {
|
||||||
return this.InsertModelLogs(this.Prefix, uid, v)
|
return this.InsertModelLogs(this.Prefix, uid, v)
|
||||||
} else {
|
} else {
|
||||||
return this.UpdateModelLogs(this.Prefix, uid, bson.M{"_id": uid}, v)
|
return this.UpdateModelLogs(this.Prefix, uid, bson.M{"_id": uid}, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Model_Comp) GetObj(uid string, v interface{}) error {
|
func (this *Model_Comp) GetObj(uid string, v interface{}) error {
|
||||||
return this.Redis.Get(fmt.Sprintf("%s:%s", this.Prefix, uid), v)
|
return this.Redis.Get(fmt.Sprintf("%s:%s", this.Prefix, uid), v)
|
||||||
|
@ -24,7 +24,7 @@ func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interf
|
|||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"name": req.NickName,
|
"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 {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
|
@ -86,20 +86,20 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
session.Bind(user.Uid, this.service.GetId())
|
session.Bind(user.Uid, this.service.GetId())
|
||||||
cache_user.Uid = user.Uid
|
|
||||||
// data := map[string]interface{}{
|
// data := map[string]interface{}{
|
||||||
// "sessionId": cache_user.SessionId,
|
// "sessionId": cache_user.SessionId,
|
||||||
// "gatewayServiceId": cache_user.GatewayServiceId,
|
// "gatewayServiceId": cache_user.GatewayServiceId,
|
||||||
// }
|
// }
|
||||||
data := &pb.Cache_UserData{
|
data := &pb.Cache_UserData{
|
||||||
|
Uid: user.Uid,
|
||||||
SessionId: cache_user.SessionId,
|
SessionId: cache_user.SessionId,
|
||||||
GatewayServiceId: cache_user.GatewayServiceId,
|
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 {
|
} else {
|
||||||
session.Bind(db_user.Uid, this.service.GetId())
|
session.Bind(db_user.Uid, this.service.GetId())
|
||||||
cache_user.Uid = db_user.Uid
|
|
||||||
data := &pb.Cache_UserData{
|
data := &pb.Cache_UserData{
|
||||||
|
Uid: db_user.Uid,
|
||||||
SessionId: cache_user.SessionId,
|
SessionId: cache_user.SessionId,
|
||||||
GatewayServiceId: cache_user.GatewayServiceId,
|
GatewayServiceId: cache_user.GatewayServiceId,
|
||||||
}
|
}
|
||||||
@ -107,6 +107,6 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
|||||||
// "sessionId": cache_user.SessionId,
|
// "sessionId": cache_user.SessionId,
|
||||||
// "gatewayServiceId": cache_user.GatewayServiceId,
|
// "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