50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package friend
|
|
|
|
import (
|
|
"context"
|
|
|
|
"bsm/full/module/social/relation/internal/impl"
|
|
"bsm/full/module/social/relation/internal/logic/common"
|
|
"bsm/full/module/social/relation/internal/models"
|
|
pb "bsm/full/module/social/relation/pb"
|
|
"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) {
|
|
auth, err := service.ParseMetaCtx(ctx, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if in.Identity == "" {
|
|
return nil, errcode.ErrInvalidArgument
|
|
}
|
|
|
|
// 只允许查看与自己相关的申请(申请方或被申请方)
|
|
var apply models.FriendApply
|
|
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
|
|
}
|
|
|
|
reply.Data, err = common.GetrelationInfoDetailCard(apply.FromIdentity)
|
|
if err != nil {
|
|
printer.Error(err.Error())
|
|
return nil, errcode.ErrDB
|
|
}
|
|
|
|
err = impl.DBService.Where("apply_id=?", apply.ID).Order("id asc").Find(&reply.Message).Error
|
|
if err != nil {
|
|
printer.Error(err.Error())
|
|
return nil, errcode.ErrDB
|
|
}
|
|
return
|
|
}
|