feat: 引入循环交易管理、邮件通知和用户设置功能

This commit is contained in:
2026-02-02 11:04:03 +08:00
parent 8b2cf37b18
commit 2e869e0c85
8 changed files with 145 additions and 12 deletions

View File

@@ -9,10 +9,11 @@ import (
// Service layer errors for user settings
var (
ErrInvalidIconLayout = errors.New("invalid icon layout, must be one of: four, five, six")
ErrInvalidImageCompression = errors.New("invalid image compression, must be one of: low, medium, high")
ErrDefaultAccountNotFound = errors.New("default account not found")
ErrInvalidDefaultAccount = errors.New("invalid default account")
ErrInvalidIconLayout = errors.New("invalid icon layout, must be one of: four, five, six")
ErrInvalidImageCompression = errors.New("invalid image compression, must be one of: low, medium, high")
ErrDefaultAccountNotFound = errors.New("default account not found")
ErrInvalidDefaultAccount = errors.New("invalid default account")
ErrInvalidNotificationChannel = errors.New("invalid notification channel")
)
// UserSettingsRepositoryInterface defines the interface for user settings repository operations
@@ -37,6 +38,8 @@ type UserSettingsInput struct {
ShowRefundBtn *bool `json:"show_refund_btn"`
CurrentLedgerID *uint `json:"current_ledger_id"`
Phone *string `json:"phone"`
Email *string `json:"email"`
NotificationChannel *string `json:"notification_channel"`
}
// DefaultAccountsInput represents the input data for updating default accounts
@@ -153,6 +156,21 @@ func (s *UserSettingsService) UpdateSettings(userID uint, input UserSettingsInpu
settings.Phone = *input.Phone
}
if input.Email != nil {
settings.Email = *input.Email
}
if input.NotificationChannel != nil {
channel := *input.NotificationChannel
if channel != models.NotificationChannelSMS &&
channel != models.NotificationChannelEmail &&
channel != models.NotificationChannelBoth &&
channel != models.NotificationChannelNone {
return nil, ErrInvalidNotificationChannel
}
settings.NotificationChannel = channel
}
// Save to database
if err := s.repo.Update(settings); err != nil {
return nil, fmt.Errorf("failed to update settings: %w", err)