amocrm/internal/service/steps.go

38 lines
1018 B
Go
Raw Normal View History

package service
import (
"context"
2024-06-05 13:27:14 +00:00
"database/sql"
2025-02-27 13:30:52 +00:00
"gitea.pena/SQuiz/amocrm/internal/models"
"gitea.pena/SQuiz/common/model"
"gitea.pena/SQuiz/common/pj_errors"
2024-04-12 16:39:51 +00:00
"go.uber.org/zap"
)
func (s *Service) GetStepsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string, pipelineID int) (*model.UserListStepsResp, error) {
response, err := s.repository.AmoRepo.GetStepsWithPagination(ctx, req, accountID, int32(pipelineID))
if err != nil {
2024-06-05 13:27:14 +00:00
if err == sql.ErrNoRows {
return nil, pj_errors.ErrNotFound
}
2024-04-12 16:39:51 +00:00
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.PipelinesUpdate,
}
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
}