fix version 1
This commit is contained in:
@@ -10,11 +10,12 @@ import (
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 好友申请详情
|
||||
func ApplyGet(ctx context.Context, in *pb.IdentRequest) (reply *pb.FriendApplyGetReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -22,10 +23,14 @@ func ApplyGet(ctx context.Context, in *pb.IdentRequest) (reply *pb.FriendApplyGe
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// 只允许查看与自己相关的申请(申请方或被申请方)
|
||||
var apply models.FriendApply
|
||||
err = impl.DBService.Where("identity=?", in.Identity).First(&apply).Error
|
||||
err = impl.DBService.Where("identity=? and (from_identity=? or to_identity=?)", in.Identity, auth.Identity, auth.Identity).First(&apply).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, errcode.ErrPermissionDenied
|
||||
}
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user