35 lines
1.3 KiB
Go
35 lines
1.3 KiB
Go
package outbound
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"lincodex/backend/internal/domain"
|
|
)
|
|
|
|
var ErrCandidateQuestionnaireVersionConflict = errors.New("candidate questionnaire changed concurrently")
|
|
|
|
// CandidateQuestionnaireRepositories exposes the questionnaire repository
|
|
// bound to a UnitOfWork transaction.
|
|
type CandidateQuestionnaireRepositories interface {
|
|
CandidateQuestionnaires() CandidateQuestionnaireRepository
|
|
}
|
|
|
|
// CandidateQuestionnaireRepository reads and replaces only the questionnaire
|
|
// owned by userID. A missing row is the version-0 empty questionnaire.
|
|
type CandidateQuestionnaireRepository interface {
|
|
Get(ctx context.Context, userID uuid.UUID) (domain.CandidateQuestionnaire, error)
|
|
|
|
// Save atomically advances the expected version and replaces the answer
|
|
// rows. A concurrent identical winner is returned as an idempotent success;
|
|
// a different winner returns ErrCandidateQuestionnaireVersionConflict.
|
|
Save(ctx context.Context, expectedVersion int64, questionnaire domain.CandidateQuestionnaire) (domain.CandidateQuestionnaire, error)
|
|
|
|
// AdvanceOnboarding advances only candidate_questionnaire to
|
|
// candidate_assessment; later onboarding steps are left unchanged.
|
|
AdvanceOnboarding(ctx context.Context, userID uuid.UUID, at time.Time) error
|
|
}
|