Files
apocapoc-api/internal/domain/entities/user.go
T
david 64bfe80806 Implement domain layer (TDD - Green phase)
Implementation to make all tests pass:

Value Objects:
- HabitType: BOOLEAN, COUNTER, VALUE with validation
- Frequency: DAILY, WEEKLY, MONTHLY with validation

Entities:
- User: email, password hash, timezone with defaults
- Habit: tracking habits with type, frequency, carry-over
- HabitEntry: recording habit completions with soft delete

Repositories (interfaces):
- UserRepository: CRUD operations for users
- HabitRepository: CRUD operations for habits
- HabitEntryRepository: CRUD operations for entries

Shared:
- Common error definitions for domain layer

All domain tests now pass.
2025-11-25 10:13:08 +01:00

24 lines
406 B
Go

package entities
import "time"
type User struct {
ID string
Email string
PasswordHash string
Timezone string
CreatedAt time.Time
UpdatedAt time.Time
}
func NewUser(email, passwordHash, timezone string) *User {
now := time.Now()
return &User{
Email: email,
PasswordHash: passwordHash,
Timezone: timezone,
CreatedAt: now,
UpdatedAt: now,
}
}