refactor: reorganize modules and add Linux build tooling
This commit is contained in:
37
module/social/relation/internal/logic/match/do_ignore.go
Normal file
37
module/social/relation/internal/logic/match/do_ignore.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"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-sdk/core/vars"
|
||||
"bsm/full/module/social/relation/internal/impl"
|
||||
"bsm/full/module/social/relation/internal/models"
|
||||
pb "bsm/full/module/social/relation/pb"
|
||||
)
|
||||
|
||||
// 执行忽略
|
||||
func DoIgnore(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
err = impl.DBService.Model(new(models.RelationFollow)).Delete("identity=?", in.Identity).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
return &pb.StatusReply{
|
||||
Data: vars.OK,
|
||||
Timeseq: time.Now().UnixMilli(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
45
module/social/relation/internal/logic/match/do_join.go
Normal file
45
module/social/relation/internal/logic/match/do_join.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"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-sdk/core/utils"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
"bsm/full/module/social/relation/internal/impl"
|
||||
"bsm/full/module/social/relation/internal/models"
|
||||
pb "bsm/full/module/social/relation/pb"
|
||||
)
|
||||
|
||||
// 执行通过,加为好友
|
||||
func DoJoin(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
data := &models.RelationFollow{
|
||||
FromIdentity: auth.Identity,
|
||||
ToIdentity: in.Identity,
|
||||
}
|
||||
data.Identity = utils.UUID()
|
||||
|
||||
err = impl.DBService.Create(data).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
return &pb.StatusReply{
|
||||
Data: vars.OK,
|
||||
Timeseq: time.Now().UnixMilli(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
52
module/social/relation/internal/logic/match/fetch.go
Normal file
52
module/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"
|
||||
"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"
|
||||
)
|
||||
|
||||
// 获取匹配列表
|
||||
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
|
||||
}
|
||||
30
module/social/relation/internal/logic/match/get.go
Normal file
30
module/social/relation/internal/logic/match/get.go
Normal file
@@ -0,0 +1,30 @@
|
||||
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"
|
||||
"bsm/full/module/social/relation/internal/logic/common"
|
||||
pb "bsm/full/module/social/relation/pb"
|
||||
)
|
||||
|
||||
// 获取匹配详情
|
||||
func Get(ctx context.Context, in *pb.IdentRequest) (reply *pb.RelationItem, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
reply, err = common.GetrelationInfoDetailCard(in.Identity)
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
Reference in New Issue
Block a user