amocrm/internal/service/fields.go

38 lines
1.0 KiB
Go
Raw Normal View History

package service
import (
"amocrm/internal/models"
"context"
2024-06-05 13:27:14 +00:00
"database/sql"
2024-04-12 16:39:51 +00:00
"go.uber.org/zap"
2024-04-17 12:21:06 +00:00
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
2024-06-05 13:27:14 +00:00
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/pj_errors"
)
2024-04-21 15:24:13 +00:00
func (s *Service) GetFieldsWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListFieldsResp, error) {
response, err := s.repository.AmoRepo.GetFieldsWithPagination(ctx, req, accountID)
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 fields with pagination", zap.Error(err))
return nil, err
}
return response, nil
}
func (s *Service) UpdateListCustom(ctx context.Context, accountID string) error {
message := models.KafkaMessage{
AccountID: accountID,
Type: models.FieldsUpdate,
}
err := s.producer.ToKafkaUpdate(ctx, message)
if err != nil {
s.logger.Error("failed to send message to kafka on service update fields", zap.Error(err))
return err
}
return nil
}