amocrm/internal/service/pipelines.go
2025-02-27 16:30:52 +03:00

38 lines
1007 B
Go

package service
import (
"context"
"database/sql"
"gitea.pena/SQuiz/amocrm/internal/models"
"gitea.pena/SQuiz/common/model"
"gitea.pena/SQuiz/common/pj_errors"
"go.uber.org/zap"
)
func (s *Service) UpdateListPipelines(ctx context.Context, accountID string) error {
message := models.KafkaMessage{
AccountID: accountID,
Type: models.PipelinesUpdate,
}
err := s.producer.ToKafkaUpdate(ctx, message)
if err != nil {
s.logger.Error("failed to send message to kafka on service update pipelines", zap.Error(err))
return err
}
return nil
}
func (s *Service) GetPipelinesWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListPipelinesResp, error) {
response, err := s.repository.AmoRepo.GetPipelinesWithPagination(ctx, req, accountID)
if err != nil {
if err == sql.ErrNoRows {
return nil, pj_errors.ErrNotFound
}
s.logger.Error("error getting pipelines with pagination", zap.Error(err))
return nil, err
}
return response, nil
}