57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package friend
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
)
|
|
|
|
func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelBlackReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
|
chk = make(map[string]interface{})
|
|
self := &pb.DBFriend{UId: session.GetUserId()}
|
|
err := this.module.modelFriend.Get(session.GetUserId(), self)
|
|
if self == nil || err != nil {
|
|
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
return
|
|
}
|
|
chk["self"] = self
|
|
return
|
|
}
|
|
|
|
//删除黑名单
|
|
func (this *apiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendDelBlackReq) (code pb.ErrorCode) {
|
|
var (
|
|
self *pb.DBFriend
|
|
rsp *pb.FriendDelBlackRsp
|
|
)
|
|
defer func() {
|
|
if code == pb.ErrorCode_Success {
|
|
rsp = &pb.FriendDelBlackRsp{
|
|
FriendId: req.FriendId,
|
|
UserId: session.GetUserId(),
|
|
}
|
|
}
|
|
err := session.SendMsg(string(this.module.GetType()), FriendSubTypeDelBlack, rsp)
|
|
if err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
return
|
|
}
|
|
}()
|
|
|
|
if v, ok := chk["self"]; ok {
|
|
self = v.(*pb.DBFriend)
|
|
//从黑名单列表中删除目标
|
|
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
|
//更新黑名单
|
|
err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
|
"blackIds": self.BlackIds,
|
|
})
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|