bitrix/internal/service/steps.go

38 lines
1.1 KiB
Go

package service
import (
"context"
"database/sql"
"go.uber.org/zap"
"penahub.gitlab.yandexcloud.net/backend/quiz/bitrix/internal/models"
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/pj_errors"
)
func (s *Service) GetStepsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListBitrixStepsResp, error) {
response, err := s.repository.BitrixRepo.GetStepsWithPagination(ctx, req, accountID)
if err != nil {
if err == sql.ErrNoRows {
return nil, pj_errors.ErrNotFound
}
s.logger.Error("error getting steps with pagination", zap.Error(err))
return nil, err
}
return response, nil
}
func (s *Service) UpdateListSteps(ctx context.Context, accountID string) error {
message := models.KafkaMessage{
AccountID: accountID,
Type: models.StepsUpdate,
}
err := s.producer.ToKafkaUpdate(ctx, message)
if err != nil {
s.logger.Error("failed to send message to kafka on service update steps", zap.Error(err))
return err
}
return nil
}