feat: 引入循环交易管理、邮件通知和用户设置功能
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user