createchatsessionlogic.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package logic
  2. import (
  3. quitl "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. util "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
  6. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
  7. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
  8. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/service"
  9. "context"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type CreateChatSessionLogic struct {
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. logx.Logger
  16. }
  17. func NewCreateChatSessionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateChatSessionLogic {
  18. return &CreateChatSessionLogic{
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. Logger: logx.WithContext(ctx),
  22. }
  23. }
  24. // 会话创建
  25. func (l *CreateChatSessionLogic) CreateChatSession(in *messagecenter.ChatSessionReq) (*messagecenter.ChatSessionResp, error) {
  26. // todo: add your logic here and delete this line
  27. m := service.MessaggeService{}
  28. fool, sessionId := m.CreateChatSession(in)
  29. error_message := ""
  30. error_code := util.SUCCESS_CODE
  31. if fool {
  32. error_code = util.SUCCESS_CODE
  33. error_message = ""
  34. } else {
  35. error_code = util.ERROR_CODE
  36. error_message = "修改失败"
  37. }
  38. return &messagecenter.ChatSessionResp{
  39. ErrorCode: error_code,
  40. ErrorMsg: error_message,
  41. SessionId: encrypt.SE.Encode2Hex(quitl.InterfaceToStr(sessionId)),
  42. }, nil
  43. }