createchatsessionlogic.go 1.3 KB

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