2026-08-09 10:43:45 +08:00
|
|
|
package friend
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/errcode"
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/printer"
|
|
|
|
|
"git.apinb.com/bsm-sdk/core/service"
|
2026-08-09 12:41:08 +08:00
|
|
|
"bsm/full/module/social/relation/internal/logic/common"
|
|
|
|
|
pb "bsm/full/module/social/relation/pb"
|
2026-08-09 10:43:45 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 好友申请列表
|
|
|
|
|
func ApplyFetch(ctx context.Context, in *pb.VersionRequest) (reply *pb.ApplyFetchReply, err error) {
|
|
|
|
|
auth, err := service.ParseMetaCtx(ctx, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cacheErr error
|
|
|
|
|
if in.Version == 0 {
|
|
|
|
|
reply, err = common.CollectionFriendApply(auth.ID)
|
|
|
|
|
if err == nil {
|
|
|
|
|
cacheErr = common.SetCache(auth.Identity, "apply", reply)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cache, err := common.GetCache(auth.Identity, "apply")
|
|
|
|
|
if err != nil {
|
|
|
|
|
printer.Error(err.Error())
|
|
|
|
|
return nil, errcode.ErrRedis
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if in.Version != cache.Version {
|
|
|
|
|
reply, err = common.CollectionFriendApply(auth.ID)
|
|
|
|
|
if err == nil {
|
|
|
|
|
cacheErr = common.SetCache(auth.Identity, "apply", reply)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
printer.Error(err.Error())
|
|
|
|
|
return nil, errcode.ErrDB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if cacheErr != nil {
|
|
|
|
|
printer.Error(err.Error())
|
|
|
|
|
return nil, errcode.ErrRedis
|
|
|
|
|
}
|
|
|
|
|
return reply, nil
|
|
|
|
|
}
|