2026-08-09 10:43:45 +08:00
|
|
|
|
package friend
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
2026-08-09 12:41:08 +08:00
|
|
|
|
"bsm/full/module/social/relation/internal/impl"
|
|
|
|
|
|
"bsm/full/module/social/relation/internal/models"
|
|
|
|
|
|
pb "bsm/full/module/social/relation/pb"
|
2026-08-09 10:43:45 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 好友申请Do:留言
|
2026-08-09 20:14:57 +08:00
|
|
|
|
func ApplyDoMessage(ctx context.Context, in *pb.ApplyMessageRequest) (reply *pb.DataStatusReply, err error) {
|
2026-08-09 10:43:45 +08:00
|
|
|
|
auth, err := service.ParseMetaCtx(ctx, nil)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
}
|
|
|
|
|
|
if in.Body == "" || in.ApplyId == 0 {
|
|
|
|
|
|
return nil, errcode.ErrInvalidArgument
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
msg := models.FriendApplyMessage{
|
|
|
|
|
|
ApplyID: uint(in.ApplyId),
|
|
|
|
|
|
Body: in.Body,
|
|
|
|
|
|
}
|
|
|
|
|
|
msg.PassportID = auth.ID
|
|
|
|
|
|
msg.PassportIdentity = auth.Identity
|
|
|
|
|
|
|
|
|
|
|
|
err = impl.DBService.Create(&msg).Error
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
printer.Error(err.Error())
|
|
|
|
|
|
return nil, errcode.ErrDB
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//回写最后一次交流的消息ID
|
|
|
|
|
|
err = impl.DBService.Model(models.FriendApply{}).Where("id=?", msg.ApplyID).UpdateColumn("last_message_id", msg.ID).Error
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
printer.Error(err.Error())
|
|
|
|
|
|
return nil, errcode.ErrDB
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//EventMQ:向mesh MQ中心发送报文,请求推送消息以及更新Cache.
|
2026-08-09 20:14:57 +08:00
|
|
|
|
return &pb.DataStatusReply{
|
2026-08-09 10:43:45 +08:00
|
|
|
|
Data: vars.OK,
|
|
|
|
|
|
Timeseq: time.Now().UnixMilli(),
|
|
|
|
|
|
}, nil
|
|
|
|
|
|
|
|
|
|
|
|
}
|