43 lines
1.6 KiB
Go
43 lines
1.6 KiB
Go
package outbound
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"lincodex/backend/internal/domain"
|
|
)
|
|
|
|
var (
|
|
// ErrCandidateProfileVersionConflict reports a stale expected version.
|
|
ErrCandidateProfileVersionConflict = errors.New("candidate profile changed concurrently")
|
|
|
|
// ErrCandidateProfileHistoryTooLarge reports a snapshot that exceeds the
|
|
// private history table's fixed storage bound.
|
|
ErrCandidateProfileHistoryTooLarge = errors.New("candidate profile history snapshot exceeds its bound")
|
|
)
|
|
|
|
// CandidateProfileRepositories exposes the candidate profile repository.
|
|
// UnitOfWork binds it to the transaction that also records profile history
|
|
// and advances onboarding.
|
|
type CandidateProfileRepositories interface {
|
|
CandidateProfiles() CandidateProfileRepository
|
|
}
|
|
|
|
// CandidateProfileRepository reads and replaces only the profile identified
|
|
// by userID. A missing profile row is the version-0 empty profile.
|
|
type CandidateProfileRepository interface {
|
|
Get(ctx context.Context, userID uuid.UUID) (domain.CandidateProfile, error)
|
|
|
|
// Save writes a changed profile only when its stored version equals
|
|
// expectedVersion. It replaces claims and period acknowledgements and
|
|
// appends the bounded immutable snapshot in the same transaction.
|
|
Save(ctx context.Context, expectedVersion int64, profile domain.CandidateProfile) (domain.CandidateProfile, error)
|
|
|
|
// AdvanceOnboarding advances a verified candidate only from
|
|
// candidate_profile to candidate_questionnaire. A later step is left alone.
|
|
AdvanceOnboarding(ctx context.Context, userID uuid.UUID, at time.Time) error
|
|
}
|