feat: import services and standardize Go 1.26.5
This commit is contained in:
52
apps/social/relation/internal/logic/match/fetch.go
Normal file
52
apps/social/relation/internal/logic/match/fetch.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-social/relation/internal/impl"
|
||||
"git.apinb.com/bsm-social/relation/internal/logic/common"
|
||||
"git.apinb.com/bsm-social/relation/internal/models"
|
||||
pb "git.apinb.com/bsm-social/relation/pb"
|
||||
)
|
||||
|
||||
// 获取匹配列表
|
||||
func Fetch(ctx context.Context, in *pb.FetchRequest) (reply *pb.FetchRelationItemReply, err error) {
|
||||
// parse authorization meta.
|
||||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 处理分页
|
||||
if in.PageNo <= 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.PageSize <= 1 {
|
||||
in.PageSize = 20
|
||||
}
|
||||
|
||||
var (
|
||||
total int64
|
||||
)
|
||||
|
||||
err = impl.DBService.Model(&models.RelationMatch{}).Where("relation_identity=?", auth.Identity).Count(&total).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
// 取得用户信息卡片
|
||||
data, err := common.GetrelationInfoDetailCardByMatch(auth.Identity, int(in.PageNo-1)*int(in.PageSize), int(in.PageSize))
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
reply = &pb.FetchRelationItemReply{
|
||||
Total: total,
|
||||
Data: data,
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
Reference in New Issue
Block a user