refactor: reorganize modules and add Linux build tooling
This commit is contained in:
52
module/social/relation/internal/logic/friend/apply_fetch.go
Normal file
52
module/social/relation/internal/logic/friend/apply_fetch.go
Normal file
@@ -0,0 +1,52 @@
|
||||
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"
|
||||
"bsm/full/module/social/relation/internal/logic/common"
|
||||
pb "bsm/full/module/social/relation/pb"
|
||||
)
|
||||
|
||||
// 好友申请列表
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user