getunreadcountlogic.go 931 B

123456789101112131415161718192021222324252627282930313233343536
  1. package logic
  2. import (
  3. service "app.yhyue.com/moapp/MessageCenter/rpc/internal/common"
  4. "app.yhyue.com/moapp/MessageCenter/rpc/messageclient"
  5. "context"
  6. "app.yhyue.com/moapp/MessageCenter/rpc/internal/svc"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type GetUnreadCountLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewGetUnreadCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUnreadCountLogic {
  15. return &GetUnreadCountLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. // 查询指定用户未读消息合计
  22. func (l *GetUnreadCountLogic) GetUnreadCount(in *messageclient.GetUnreadCountRequest) (*messageclient.GetUnreadCountResponse, error) {
  23. m := &service.MessageService{}
  24. code, msg, count := m.CountUnread(in.UserId, in.Appid)
  25. return &messageclient.GetUnreadCountResponse{
  26. Code: code,
  27. Message: msg,
  28. Count: count,
  29. }, nil
  30. }