feat: #45 meta de poupança configurável + conquistas genéricas
- Nova tabela user_settings com savings_goal_pct (default 40%) - API GET /api/settings, PUT /api/settings - DashboardService inclui savings_goal_pct no payload - DashboardHandler dispara savings_checked com goal configurado - GameService.NotifyAction: checa pct >= goal (sem hardcode de 40%) - SettingsView: painel META DE POUPANÇA com input configurável - HomeView: widget mostra meta dinâmica (META: X%) e usa savingsGoal - stores/settings.ts: store com fetch e update Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"financeiro-carvalho/internal/model"
|
||||
"financeiro-carvalho/internal/repository"
|
||||
)
|
||||
|
||||
var ErrInvalidSavingsGoal = errors.New("savings_goal_pct must be between 1 and 100")
|
||||
|
||||
type SettingsService struct {
|
||||
repo repository.SettingsRepository
|
||||
}
|
||||
|
||||
func NewSettingsService(repo repository.SettingsRepository) *SettingsService {
|
||||
return &SettingsService{repo: repo}
|
||||
}
|
||||
|
||||
func (s *SettingsService) Get(ctx context.Context) (*model.UserSettings, error) {
|
||||
return s.repo.Get(ctx)
|
||||
}
|
||||
|
||||
func (s *SettingsService) Update(ctx context.Context, in model.UserSettings) (*model.UserSettings, error) {
|
||||
if in.SavingsGoalPct < 1 || in.SavingsGoalPct > 100 {
|
||||
return nil, ErrInvalidSavingsGoal
|
||||
}
|
||||
return s.repo.Upsert(ctx, in)
|
||||
}
|
||||
Reference in New Issue
Block a user