Yimaru-BackEnd/internal/domain/profile_field_option.go
Yared Yemane a5acd00637 Add admin-managed field options API for configurable dropdowns.
Store options in field_options with public /field-options and admin CRUD; validate learner profile values on update.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 09:21:36 -07:00

78 lines
1.9 KiB
Go

package domain
import (
"errors"
"time"
)
const (
ProfileFieldOptionStatusActive = "ACTIVE"
ProfileFieldOptionStatusInactive = "INACTIVE"
)
var (
ErrInvalidFieldKey = errors.New("invalid field key")
ErrInvalidOptionCode = errors.New("invalid field option code")
ErrFieldOptionNotFound = errors.New("field option not found")
)
// Deprecated aliases for internal references during transition.
var (
ErrInvalidProfileFieldKey = ErrInvalidFieldKey
ErrInvalidProfileFieldOptionCode = ErrInvalidOptionCode
ErrProfileFieldOptionNotFound = ErrFieldOptionNotFound
)
const (
ProfileFieldEducationLevel = "education_level"
ProfileFieldOccupation = "occupation"
ProfileFieldAgeGroup = "age_group"
ProfileFieldLearningGoal = "learning_goal"
ProfileFieldLanguageChallange = "language_challange"
ProfileFieldLanguageGoal = "language_goal"
ProfileFieldFavouriteTopic = "favourite_topic"
)
// User profile columns validated against field_options on PUT /user (when non-empty).
var UserProfileFieldsWithOptions = []string{
ProfileFieldEducationLevel,
ProfileFieldOccupation,
ProfileFieldAgeGroup,
ProfileFieldLearningGoal,
ProfileFieldLanguageChallange,
ProfileFieldLanguageGoal,
ProfileFieldFavouriteTopic,
}
type ProfileFieldOption struct {
ID int64
FieldKey string
Code string
Label string
DisplayOrder int32
Status string
CreatedAt time.Time
UpdatedAt *time.Time
}
type CreateProfileFieldOptionInput struct {
FieldKey string
Code string
Label string
DisplayOrder *int32
Status *string
}
type UpdateProfileFieldOptionInput struct {
Label *string
DisplayOrder *int32
Status *string
}
type ProfileFieldOptionsGrouped map[string][]ProfileFieldOptionItem
type ProfileFieldOptionItem struct {
Code string `json:"code"`
Label string `json:"label"`
}