You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

friend_app.go 2.1 KiB

3 天之前
2 天之前
3 天之前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package app
  2. import (
  3. "context"
  4. frienddomain "egg-im/internal/logic/domain/friend"
  5. "egg-im/pkg/pb"
  6. "time"
  7. )
  8. type friendApp struct{}
  9. var FriendApp = new(friendApp)
  10. // List 获取好友列表
  11. func (s *friendApp) List(ctx context.Context, userId int64) ([]*pb.Friend, error) {
  12. return frienddomain.FriendService.List(ctx, userId)
  13. }
  14. // AddFriend 添加好友
  15. func (*friendApp) AddFriend(ctx context.Context, userId, friendId int64, remarks, description string) error {
  16. return frienddomain.FriendService.AddFriend(ctx, userId, friendId, remarks, description)
  17. }
  18. // DeleteFriend 添加好友
  19. func (*friendApp) DeleteFriend(ctx context.Context, userId, friendId int64) error {
  20. return frienddomain.FriendService.DeleteFriend(ctx, userId, friendId)
  21. }
  22. // AgreeAddFriend 同意添加好友
  23. func (*friendApp) AgreeAddFriend(ctx context.Context, userId, friendId int64, remarks string) error {
  24. return frienddomain.FriendService.AgreeAddFriend(ctx, userId, friendId, remarks)
  25. }
  26. // SetFriend 设置好友信息
  27. func (*friendApp) SetFriend(ctx context.Context, userId int64, req *pb.SetFriendReq) error {
  28. friend, err := frienddomain.FriendRepo.Get(userId, req.FriendId)
  29. if err != nil {
  30. return err
  31. }
  32. if friend == nil {
  33. return nil
  34. }
  35. friend.Remarks = req.Remarks
  36. friend.Extra = req.Extra
  37. friend.UpdateTime = time.Now()
  38. err = frienddomain.FriendRepo.Save(friend)
  39. if err != nil {
  40. return err
  41. }
  42. return nil
  43. }
  44. // SendToFriend 消息发送至好友
  45. func (*friendApp) SendToFriend(ctx context.Context, sender *pb.Sender, req *pb.SendMessageReq) (int64, error) {
  46. return frienddomain.FriendService.SendToFriend(ctx, sender, req)
  47. }
  48. // RecallMessageSendToFriend 撤回消息发送至好友
  49. func (*friendApp) RecallMessageSendToFriend(ctx context.Context, sender *pb.Sender, req *pb.RecallMessageReq) (int64, error) {
  50. return frienddomain.FriendService.RecallMessageSendToFriend(ctx, sender, req)
  51. }
  52. // RedPackageMessageSendToFriend 红包发送至好友
  53. func (*friendApp) RedPackageMessageSendToFriend(ctx context.Context, sender *pb.Sender, req *pb.SendRedPacketReq) (int64, error) {
  54. return frienddomain.FriendService.RedPackageMessageSendToFriend(ctx, sender, req)
  55. }