Add COUNTER type with auto-increment and IsNegative field
COUNTER type: - Only accepts integer values (rejects decimals) - Auto-increment behavior: each mark adds to existing value - Supports decrement via negative values (e.g., -2) - Enforces minimum value of 0 (never negative) - Default increment is 1 if no value provided VALUE type: - Accepts decimal values - Replaces value (no auto-increment) IsNegative field: - New boolean field on Habit entity - Persisted in database (is_negative column) - Available in all DTOs and HTTP responses - Marks habits as "negative" (e.g., candy consumption) Examples: - COUNTER: 5 + (-2) = 3, 2 + (-3) = 0, 0 + (-1) = 0 - VALUE: 5000 → 12000 = 12000 (replacement)
This commit is contained in:
@@ -14,6 +14,7 @@ type HabitDTO struct {
|
||||
Frequency value_objects.Frequency
|
||||
TargetValue *float64
|
||||
CarryOver bool
|
||||
IsNegative bool
|
||||
SpecificDays []int
|
||||
}
|
||||
|
||||
@@ -46,6 +47,7 @@ func (h *GetUserHabitsHandler) Handle(ctx context.Context, query GetUserHabitsQu
|
||||
Frequency: habit.Frequency,
|
||||
TargetValue: habit.TargetValue,
|
||||
CarryOver: habit.CarryOver,
|
||||
IsNegative: habit.IsNegative,
|
||||
SpecificDays: habit.SpecificDays,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user