bitrix/internal/service/pipelines.go

38 lines
1.1 KiB
Go
Raw Normal View History

2024-09-16 15:14:36 +00:00
package service
import (
"context"
"database/sql"
"go.uber.org/zap"
2024-09-27 13:47:08 +00:00
"penahub.gitlab.yandexcloud.net/backend/quiz/bitrix/internal/models"
2024-09-16 15:14:36 +00:00
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/pj_errors"
)
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
}
2024-09-27 13:47:08 +00:00
func (s *Service) GetPipelinesWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserBitrixListPipelinesResp, error) {
2024-09-16 15:14:36 +00:00
response, err := s.repository.BitrixRepo.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
}