e87b7df979
Update module name and all imports from habit-tracker-api to apocapoc-api. This reflects the project's new branding as part of the apocapoc ecosystem (apocapoc-api, apocapoc-web, apocapoc-android).
49 lines
850 B
Go
49 lines
850 B
Go
package entities
|
|
|
|
import (
|
|
"time"
|
|
|
|
"apocapoc-api/internal/domain/value_objects"
|
|
)
|
|
|
|
type Habit struct {
|
|
ID string
|
|
UserID string
|
|
Name string
|
|
Description string
|
|
Type value_objects.HabitType
|
|
Frequency value_objects.Frequency
|
|
SpecificDays []int
|
|
SpecificDates []int
|
|
CarryOver bool
|
|
TargetValue *float64
|
|
CreatedAt time.Time
|
|
ArchivedAt *time.Time
|
|
}
|
|
|
|
func NewHabit(
|
|
userID string,
|
|
name string,
|
|
habitType value_objects.HabitType,
|
|
frequency value_objects.Frequency,
|
|
carryOver bool,
|
|
) *Habit {
|
|
return &Habit{
|
|
UserID: userID,
|
|
Name: name,
|
|
Type: habitType,
|
|
Frequency: frequency,
|
|
CarryOver: carryOver,
|
|
CreatedAt: time.Now(),
|
|
}
|
|
}
|
|
|
|
func (h *Habit) Archive() {
|
|
now := time.Now()
|
|
h.ArchivedAt = &now
|
|
}
|
|
|
|
func (h *Habit) IsActive() bool {
|
|
return h.ArchivedAt == nil
|
|
}
|