chatgroupjoinlogic.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package logic
  2. import (
  3. quitl "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
  6. "context"
  7. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
  8. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type ChatGroupJoinLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewChatGroupJoinLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupJoinLogic {
  17. return &ChatGroupJoinLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *ChatGroupJoinLogic) ChatGroupJoin(req *types.ChatGroupJoinReq) (resp *types.CommonRes, err error) {
  24. // todo: add your logic here and delete this line
  25. userIdArr := []int64{}
  26. for _, v := range req.UserIdArr {
  27. userIdArr = append(userIdArr, quitl.Int64All(encrypt.SE.Decode4Hex(v)))
  28. }
  29. chatGroupId := quitl.Int64All(encrypt.SE.Decode4Hex(req.ChatGroupId))
  30. result, err := l.svcCtx.Message.ChatGroupJoin(l.ctx, &messagecenter.ChatGroupJoinReq{
  31. PositionId: req.PositionId,
  32. ChatGroupId: chatGroupId,
  33. UserIdArr: userIdArr,
  34. })
  35. if err != nil {
  36. return nil, err
  37. }
  38. return &types.CommonRes{
  39. Error_msg: result.ErrorMsg,
  40. Error_code: int(result.ErrorCode),
  41. Data: map[string]interface{}{
  42. "status": result.Status,
  43. },
  44. }, nil
  45. }