fix version 1
This commit is contained in:
@@ -10,11 +10,10 @@ import (
|
||||
"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"
|
||||
)
|
||||
|
||||
// 执行通过,加为好友
|
||||
// 执行通过:标记匹配记录状态为已通过
|
||||
func DoJoin(ctx context.Context, in *pb.IdentRequest) (reply *pb.DataStatusReply, err error) {
|
||||
// parse authorization meta.
|
||||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||||
@@ -26,17 +25,15 @@ func DoJoin(ctx context.Context, in *pb.IdentRequest) (reply *pb.DataStatusReply
|
||||
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())
|
||||
// 操作匹配记录表并限定归属,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(),
|
||||
|
||||
Reference in New Issue
Block a user