groupnameupdatelogic.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/messagecenter"
  7. "context"
  8. "log"
  9. "unicode/utf8"
  10. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
  11. "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
  12. "github.com/zeromicro/go-zero/core/logx"
  13. )
  14. type GroupNameUpdateLogic struct {
  15. logx.Logger
  16. ctx context.Context
  17. svcCtx *svc.ServiceContext
  18. }
  19. func NewGroupNameUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNameUpdateLogic {
  20. return &GroupNameUpdateLogic{
  21. Logger: logx.WithContext(ctx),
  22. ctx: ctx,
  23. svcCtx: svcCtx,
  24. }
  25. }
  26. func (l *GroupNameUpdateLogic) GroupNameUpdate(req *types.GroupNameUpdateReq) (resp *types.CommonRes, err error) {
  27. // todo: add your logic here and delete this line
  28. chatGroupId := quitl.Int64All(encrypt.SE.Decode4Hex(req.ChatGroupId))
  29. log.Println(len(req.GroupName))
  30. if utf8.RuneCountInString(req.GroupName) > 15 {
  31. return &types.CommonRes{
  32. Error_msg: "超过15个字,请调整后保存",
  33. Error_code: int(util.ERROR_CODE),
  34. }, nil
  35. }
  36. result, err := l.svcCtx.Message.GroupNameUpdate(l.ctx, &messagecenter.GroupNameUpdateReq{
  37. PositionId: req.PositionId,
  38. AppId: req.Appid,
  39. GroupName: req.GroupName,
  40. ChatGroupId: chatGroupId,
  41. })
  42. if err != nil {
  43. return nil, err
  44. }
  45. return &types.CommonRes{
  46. Error_msg: result.ErrorMsg,
  47. Error_code: int(result.ErrorCode),
  48. Data: map[string]interface{}{
  49. "status": result.Status,
  50. },
  51. }, nil
  52. }