43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package match
|
||
|
||
import (
|
||
"context"
|
||
"time"
|
||
|
||
"bsm/full/module/social/relation/internal/impl"
|
||
"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"
|
||
"git.apinb.com/bsm-sdk/core/vars"
|
||
)
|
||
|
||
// 执行通过:标记匹配记录状态为已通过
|
||
func DoJoin(ctx context.Context, in *pb.IdentRequest) (reply *pb.DataStatusReply, err error) {
|
||
// parse authorization meta.
|
||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
if in.Identity == "" {
|
||
return nil, errcode.ErrInvalidArgument
|
||
}
|
||
|
||
// 操作匹配记录表并限定归属,status=1 表示已通过
|
||
result := impl.DBService.Model(&models.RelationMatch{}).Where("relation_identity=? and recommend_identity=?", auth.Identity, in.Identity).UpdateColumn("status", 1)
|
||
if result.Error != nil {
|
||
printer.Error(result.Error.Error())
|
||
return nil, errcode.ErrDB
|
||
}
|
||
if result.RowsAffected == 0 {
|
||
return nil, errcode.ErrPermissionDenied
|
||
}
|
||
return &pb.DataStatusReply{
|
||
Data: vars.OK,
|
||
Timeseq: time.Now().UnixMilli(),
|
||
}, nil
|
||
|
||
}
|