sync application settings
This commit is contained in:
@@ -2,10 +2,11 @@ package models
|
||||
|
||||
// AuthResponse returns a view-object of user authorization
|
||||
type AuthResponse struct {
|
||||
Token string `json:"token"`
|
||||
Need2FA bool `json:"need2FA"`
|
||||
User *UserBasicInfo `json:"user"`
|
||||
NotificationContent string `json:"notificationContent,omitempty"`
|
||||
Token string `json:"token"`
|
||||
Need2FA bool `json:"need2FA"`
|
||||
User *UserBasicInfo `json:"user"`
|
||||
ApplicationCloudSettings *ApplicationCloudSettingSlice `json:"applicationCloudSettings,omitempty"`
|
||||
NotificationContent string `json:"notificationContent,omitempty"`
|
||||
}
|
||||
|
||||
// RegisterResponse returns a view-object of user register response
|
||||
|
||||
@@ -24,10 +24,11 @@ type TokenRevokeRequest struct {
|
||||
|
||||
// TokenRefreshResponse represents all parameters of token refreshing request
|
||||
type TokenRefreshResponse struct {
|
||||
NewToken string `json:"newToken,omitempty"`
|
||||
OldTokenId string `json:"oldTokenId,omitempty"`
|
||||
User *UserBasicInfo `json:"user"`
|
||||
NotificationContent string `json:"notificationContent,omitempty"`
|
||||
NewToken string `json:"newToken,omitempty"`
|
||||
OldTokenId string `json:"oldTokenId,omitempty"`
|
||||
User *UserBasicInfo `json:"user"`
|
||||
ApplicationCloudSettings *ApplicationCloudSettingSlice `json:"applicationCloudSettings,omitempty"`
|
||||
NotificationContent string `json:"notificationContent,omitempty"`
|
||||
}
|
||||
|
||||
// TokenInfoResponse represents a view-object of token
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type UserApplicationCloudSettingType string
|
||||
|
||||
const (
|
||||
USER_APPLICATION_CLOUD_SETTING_TYPE_STRING UserApplicationCloudSettingType = "string"
|
||||
USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER UserApplicationCloudSettingType = "number"
|
||||
USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN UserApplicationCloudSettingType = "boolean"
|
||||
USER_APPLICATION_CLOUD_SETTING_TYPE_STRING_BOOLEAN_MAP UserApplicationCloudSettingType = "string_boolean_map"
|
||||
)
|
||||
|
||||
var ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES = map[string]UserApplicationCloudSettingType{
|
||||
// Basic Settings
|
||||
"showAccountBalance": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN,
|
||||
// Overview Page
|
||||
"showAmountInHomePage": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN,
|
||||
"timezoneUsedForStatisticsInHomePage": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
// Transaction List Page
|
||||
"itemsCountInTransactionListPage": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"showTotalAmountInTransactionListPage": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN,
|
||||
"showTagInTransactionListPage": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN,
|
||||
// Transaction Edit Page
|
||||
"autoSaveTransactionDraft": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING,
|
||||
"autoGetCurrentGeoLocation": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN,
|
||||
"alwaysShowTransactionPicturesInMobileTransactionEditPage": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN,
|
||||
// Exchange Rates Data Page
|
||||
"currencySortByInExchangeRatesPage": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
// Statistics Settings
|
||||
"statistics.defaultChartDataType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultTimezoneType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultAccountFilter": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING_BOOLEAN_MAP,
|
||||
"statistics.defaultTransactionCategoryFilter": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING_BOOLEAN_MAP,
|
||||
"statistics.defaultSortingType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultCategoricalChartType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultCategoricalChartDataRangeType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultTrendChartType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
"statistics.defaultTrendChartDataRangeType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER,
|
||||
}
|
||||
|
||||
// UserApplicationCloudSetting represents user application cloud setting stored in database
|
||||
type UserApplicationCloudSetting struct {
|
||||
Uid int64 `xorm:"PK"`
|
||||
Settings ApplicationCloudSettingSlice `xorm:"BLOB"`
|
||||
UpdatedUnixTime int64
|
||||
}
|
||||
|
||||
// UserApplicationCloudSettingsUpdateRequest represents all parameters of application cloud settings update request
|
||||
type UserApplicationCloudSettingsUpdateRequest struct {
|
||||
Settings ApplicationCloudSettingSlice `json:"settings"`
|
||||
FullUpdate bool `json:"fullUpdate"`
|
||||
}
|
||||
|
||||
// ApplicationCloudSettingSlice represents the slice data structure of ApplicationCloudSetting
|
||||
type ApplicationCloudSettingSlice []ApplicationCloudSetting
|
||||
|
||||
// ApplicationCloudSetting represents one application cloud setting
|
||||
type ApplicationCloudSetting struct {
|
||||
SettingKey string `json:"settingKey"`
|
||||
SettingValue string `json:"settingValue"`
|
||||
}
|
||||
|
||||
// FromDB fills the fields from the data stored in database
|
||||
func (s *ApplicationCloudSettingSlice) FromDB(data []byte) error {
|
||||
return json.Unmarshal(data, s)
|
||||
}
|
||||
|
||||
// ToDB returns the actual stored data in database
|
||||
func (s *ApplicationCloudSettingSlice) ToDB() ([]byte, error) {
|
||||
return json.Marshal(s)
|
||||
}
|
||||
|
||||
// Len returns the count of items
|
||||
func (s ApplicationCloudSettingSlice) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
// Swap swaps two items
|
||||
func (s ApplicationCloudSettingSlice) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
// Less reports whether the first item is less than the second one
|
||||
func (s ApplicationCloudSettingSlice) Less(i, j int) bool {
|
||||
return s[i].SettingKey < s[j].SettingKey
|
||||
}
|
||||
Reference in New Issue
Block a user