countlogic.go 866 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package logic
  2. import (
  3. "SocialPlatform.messageCenter/entity"
  4. "context"
  5. "SocialPlatform.messageCenter/rpc/internal/svc"
  6. "SocialPlatform.messageCenter/rpc/messagecenter"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type CountLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CountLogic {
  15. return &CountLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. // 查询数量
  22. func (l *CountLogic) Count(in *messageCenter.CountReq) (*messageCenter.CountResp, error) {
  23. // todo: add your logic here and delete this line
  24. m := entity.MessageMailBox{}
  25. count, err := m.Count(in.ReceiveId, in.SendId, int(in.MsgType), int(in.ReadType))
  26. if err != nil {
  27. return nil, err
  28. }
  29. return &messageCenter.CountResp{
  30. Count: int64(count),
  31. }, nil
  32. }