allow users to set coordinate display type (#141)
This commit is contained in:
+95
-91
@@ -82,61 +82,63 @@ func (s AmountColorType) String() string {
|
||||
|
||||
// User represents user data stored in database
|
||||
type User struct {
|
||||
Uid int64 `xorm:"PK"`
|
||||
Username string `xorm:"VARCHAR(32) UNIQUE NOT NULL"`
|
||||
Email string `xorm:"VARCHAR(100) UNIQUE NOT NULL"`
|
||||
Nickname string `xorm:"VARCHAR(64) NOT NULL"`
|
||||
Password string `xorm:"VARCHAR(64) NOT NULL"`
|
||||
Salt string `xorm:"VARCHAR(10) NOT NULL"`
|
||||
CustomAvatarType string `xorm:"VARCHAR(10)"`
|
||||
DefaultAccountId int64
|
||||
TransactionEditScope TransactionEditScope `xorm:"TINYINT NOT NULL"`
|
||||
Language string `xorm:"VARCHAR(10)"`
|
||||
DefaultCurrency string `xorm:"VARCHAR(3) NOT NULL"`
|
||||
FirstDayOfWeek core.WeekDay `xorm:"TINYINT NOT NULL"`
|
||||
LongDateFormat core.LongDateFormat `xorm:"TINYINT"`
|
||||
ShortDateFormat core.ShortDateFormat `xorm:"TINYINT"`
|
||||
LongTimeFormat core.LongTimeFormat `xorm:"TINYINT"`
|
||||
ShortTimeFormat core.ShortTimeFormat `xorm:"TINYINT"`
|
||||
DecimalSeparator core.DecimalSeparator `xorm:"TINYINT"`
|
||||
DigitGroupingSymbol core.DigitGroupingSymbol `xorm:"TINYINT"`
|
||||
DigitGrouping core.DigitGroupingType `xorm:"TINYINT"`
|
||||
CurrencyDisplayType core.CurrencyDisplayType `xorm:"TINYINT"`
|
||||
ExpenseAmountColor AmountColorType `xorm:"TINYINT"`
|
||||
IncomeAmountColor AmountColorType `xorm:"TINYINT"`
|
||||
FeatureRestriction core.UserFeatureRestrictions
|
||||
Disabled bool
|
||||
Deleted bool `xorm:"NOT NULL"`
|
||||
EmailVerified bool `xorm:"NOT NULL"`
|
||||
CreatedUnixTime int64
|
||||
UpdatedUnixTime int64
|
||||
DeletedUnixTime int64
|
||||
LastLoginUnixTime int64
|
||||
Uid int64 `xorm:"PK"`
|
||||
Username string `xorm:"VARCHAR(32) UNIQUE NOT NULL"`
|
||||
Email string `xorm:"VARCHAR(100) UNIQUE NOT NULL"`
|
||||
Nickname string `xorm:"VARCHAR(64) NOT NULL"`
|
||||
Password string `xorm:"VARCHAR(64) NOT NULL"`
|
||||
Salt string `xorm:"VARCHAR(10) NOT NULL"`
|
||||
CustomAvatarType string `xorm:"VARCHAR(10)"`
|
||||
DefaultAccountId int64
|
||||
TransactionEditScope TransactionEditScope `xorm:"TINYINT NOT NULL"`
|
||||
Language string `xorm:"VARCHAR(10)"`
|
||||
DefaultCurrency string `xorm:"VARCHAR(3) NOT NULL"`
|
||||
FirstDayOfWeek core.WeekDay `xorm:"TINYINT NOT NULL"`
|
||||
LongDateFormat core.LongDateFormat `xorm:"TINYINT"`
|
||||
ShortDateFormat core.ShortDateFormat `xorm:"TINYINT"`
|
||||
LongTimeFormat core.LongTimeFormat `xorm:"TINYINT"`
|
||||
ShortTimeFormat core.ShortTimeFormat `xorm:"TINYINT"`
|
||||
DecimalSeparator core.DecimalSeparator `xorm:"TINYINT"`
|
||||
DigitGroupingSymbol core.DigitGroupingSymbol `xorm:"TINYINT"`
|
||||
DigitGrouping core.DigitGroupingType `xorm:"TINYINT"`
|
||||
CurrencyDisplayType core.CurrencyDisplayType `xorm:"TINYINT"`
|
||||
CoordinateDisplayType core.CoordinateDisplayType `xorm:"TINYINT"`
|
||||
ExpenseAmountColor AmountColorType `xorm:"TINYINT"`
|
||||
IncomeAmountColor AmountColorType `xorm:"TINYINT"`
|
||||
FeatureRestriction core.UserFeatureRestrictions
|
||||
Disabled bool
|
||||
Deleted bool `xorm:"NOT NULL"`
|
||||
EmailVerified bool `xorm:"NOT NULL"`
|
||||
CreatedUnixTime int64
|
||||
UpdatedUnixTime int64
|
||||
DeletedUnixTime int64
|
||||
LastLoginUnixTime int64
|
||||
}
|
||||
|
||||
// UserBasicInfo represents a view-object of user basic info
|
||||
type UserBasicInfo struct {
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Nickname string `json:"nickname"`
|
||||
AvatarUrl string `json:"avatar"`
|
||||
AvatarProvider string `json:"avatarProvider,omitempty"`
|
||||
DefaultAccountId int64 `json:"defaultAccountId,string"`
|
||||
TransactionEditScope TransactionEditScope `json:"transactionEditScope"`
|
||||
Language string `json:"language"`
|
||||
DefaultCurrency string `json:"defaultCurrency"`
|
||||
FirstDayOfWeek core.WeekDay `json:"firstDayOfWeek"`
|
||||
LongDateFormat core.LongDateFormat `json:"longDateFormat"`
|
||||
ShortDateFormat core.ShortDateFormat `json:"shortDateFormat"`
|
||||
LongTimeFormat core.LongTimeFormat `json:"longTimeFormat"`
|
||||
ShortTimeFormat core.ShortTimeFormat `json:"shortTimeFormat"`
|
||||
DecimalSeparator core.DecimalSeparator `json:"decimalSeparator"`
|
||||
DigitGroupingSymbol core.DigitGroupingSymbol `json:"digitGroupingSymbol"`
|
||||
DigitGrouping core.DigitGroupingType `json:"digitGrouping"`
|
||||
CurrencyDisplayType core.CurrencyDisplayType `json:"currencyDisplayType"`
|
||||
ExpenseAmountColor AmountColorType `json:"expenseAmountColor"`
|
||||
IncomeAmountColor AmountColorType `json:"incomeAmountColor"`
|
||||
EmailVerified bool `json:"emailVerified"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Nickname string `json:"nickname"`
|
||||
AvatarUrl string `json:"avatar"`
|
||||
AvatarProvider string `json:"avatarProvider,omitempty"`
|
||||
DefaultAccountId int64 `json:"defaultAccountId,string"`
|
||||
TransactionEditScope TransactionEditScope `json:"transactionEditScope"`
|
||||
Language string `json:"language"`
|
||||
DefaultCurrency string `json:"defaultCurrency"`
|
||||
FirstDayOfWeek core.WeekDay `json:"firstDayOfWeek"`
|
||||
LongDateFormat core.LongDateFormat `json:"longDateFormat"`
|
||||
ShortDateFormat core.ShortDateFormat `json:"shortDateFormat"`
|
||||
LongTimeFormat core.LongTimeFormat `json:"longTimeFormat"`
|
||||
ShortTimeFormat core.ShortTimeFormat `json:"shortTimeFormat"`
|
||||
DecimalSeparator core.DecimalSeparator `json:"decimalSeparator"`
|
||||
DigitGroupingSymbol core.DigitGroupingSymbol `json:"digitGroupingSymbol"`
|
||||
DigitGrouping core.DigitGroupingType `json:"digitGrouping"`
|
||||
CurrencyDisplayType core.CurrencyDisplayType `json:"currencyDisplayType"`
|
||||
CoordinateDisplayType core.CoordinateDisplayType `json:"coordinateDisplayType"`
|
||||
ExpenseAmountColor AmountColorType `json:"expenseAmountColor"`
|
||||
IncomeAmountColor AmountColorType `json:"incomeAmountColor"`
|
||||
EmailVerified bool `json:"emailVerified"`
|
||||
}
|
||||
|
||||
// UserLoginRequest represents all parameters of user login request
|
||||
@@ -177,25 +179,26 @@ type UserResendVerifyEmailRequest struct {
|
||||
|
||||
// UserProfileUpdateRequest represents all parameters of user updating profile request
|
||||
type UserProfileUpdateRequest struct {
|
||||
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
|
||||
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
|
||||
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
||||
OldPassword string `json:"oldPassword" binding:"omitempty,min=6,max=128"`
|
||||
DefaultAccountId int64 `json:"defaultAccountId,string" binding:"omitempty,min=1"`
|
||||
TransactionEditScope *TransactionEditScope `json:"transactionEditScope" binding:"omitempty,min=0,max=6"`
|
||||
Language string `json:"language" binding:"omitempty,min=2,max=16"`
|
||||
DefaultCurrency string `json:"defaultCurrency" binding:"omitempty,len=3,validCurrency"`
|
||||
FirstDayOfWeek *core.WeekDay `json:"firstDayOfWeek" binding:"omitempty,min=0,max=6"`
|
||||
LongDateFormat *core.LongDateFormat `json:"longDateFormat" binding:"omitempty,min=0,max=3"`
|
||||
ShortDateFormat *core.ShortDateFormat `json:"shortDateFormat" binding:"omitempty,min=0,max=3"`
|
||||
LongTimeFormat *core.LongTimeFormat `json:"longTimeFormat" binding:"omitempty,min=0,max=3"`
|
||||
ShortTimeFormat *core.ShortTimeFormat `json:"shortTimeFormat" binding:"omitempty,min=0,max=3"`
|
||||
DecimalSeparator *core.DecimalSeparator `json:"decimalSeparator" binding:"omitempty,min=0,max=3"`
|
||||
DigitGroupingSymbol *core.DigitGroupingSymbol `json:"digitGroupingSymbol" binding:"omitempty,min=0,max=4"`
|
||||
DigitGrouping *core.DigitGroupingType `json:"digitGrouping" binding:"omitempty,min=0,max=2"`
|
||||
CurrencyDisplayType *core.CurrencyDisplayType `json:"currencyDisplayType" binding:"omitempty,min=0,max=11"`
|
||||
ExpenseAmountColor *AmountColorType `json:"expenseAmountColor" binding:"omitempty,min=0,max=4"`
|
||||
IncomeAmountColor *AmountColorType `json:"incomeAmountColor" binding:"omitempty,min=0,max=4"`
|
||||
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
|
||||
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
|
||||
Password string `json:"password" binding:"omitempty,min=6,max=128"`
|
||||
OldPassword string `json:"oldPassword" binding:"omitempty,min=6,max=128"`
|
||||
DefaultAccountId int64 `json:"defaultAccountId,string" binding:"omitempty,min=1"`
|
||||
TransactionEditScope *TransactionEditScope `json:"transactionEditScope" binding:"omitempty,min=0,max=6"`
|
||||
Language string `json:"language" binding:"omitempty,min=2,max=16"`
|
||||
DefaultCurrency string `json:"defaultCurrency" binding:"omitempty,len=3,validCurrency"`
|
||||
FirstDayOfWeek *core.WeekDay `json:"firstDayOfWeek" binding:"omitempty,min=0,max=6"`
|
||||
LongDateFormat *core.LongDateFormat `json:"longDateFormat" binding:"omitempty,min=0,max=3"`
|
||||
ShortDateFormat *core.ShortDateFormat `json:"shortDateFormat" binding:"omitempty,min=0,max=3"`
|
||||
LongTimeFormat *core.LongTimeFormat `json:"longTimeFormat" binding:"omitempty,min=0,max=3"`
|
||||
ShortTimeFormat *core.ShortTimeFormat `json:"shortTimeFormat" binding:"omitempty,min=0,max=3"`
|
||||
DecimalSeparator *core.DecimalSeparator `json:"decimalSeparator" binding:"omitempty,min=0,max=3"`
|
||||
DigitGroupingSymbol *core.DigitGroupingSymbol `json:"digitGroupingSymbol" binding:"omitempty,min=0,max=4"`
|
||||
DigitGrouping *core.DigitGroupingType `json:"digitGrouping" binding:"omitempty,min=0,max=2"`
|
||||
CurrencyDisplayType *core.CurrencyDisplayType `json:"currencyDisplayType" binding:"omitempty,min=0,max=11"`
|
||||
CoordinateDisplayType *core.CoordinateDisplayType `json:"coordinateDisplayType" binding:"omitempty,min=0,max=6"`
|
||||
ExpenseAmountColor *AmountColorType `json:"expenseAmountColor" binding:"omitempty,min=0,max=4"`
|
||||
IncomeAmountColor *AmountColorType `json:"incomeAmountColor" binding:"omitempty,min=0,max=4"`
|
||||
}
|
||||
|
||||
// UserProfileUpdateResponse represents the data returns to frontend after updating profile
|
||||
@@ -255,27 +258,28 @@ func (u *User) CanEditTransactionByTransactionTime(transactionTime int64, utcOff
|
||||
// ToUserBasicInfo returns a user basic view-object according to database model
|
||||
func (u *User) ToUserBasicInfo(avatarProvider core.UserAvatarProviderType, avatarUrl string) *UserBasicInfo {
|
||||
return &UserBasicInfo{
|
||||
Username: u.Username,
|
||||
Email: u.Email,
|
||||
Nickname: u.Nickname,
|
||||
AvatarUrl: avatarUrl,
|
||||
AvatarProvider: string(avatarProvider),
|
||||
DefaultAccountId: u.DefaultAccountId,
|
||||
TransactionEditScope: u.TransactionEditScope,
|
||||
Language: u.Language,
|
||||
DefaultCurrency: u.DefaultCurrency,
|
||||
FirstDayOfWeek: u.FirstDayOfWeek,
|
||||
LongDateFormat: u.LongDateFormat,
|
||||
ShortDateFormat: u.ShortDateFormat,
|
||||
LongTimeFormat: u.LongTimeFormat,
|
||||
ShortTimeFormat: u.ShortTimeFormat,
|
||||
DecimalSeparator: u.DecimalSeparator,
|
||||
DigitGroupingSymbol: u.DigitGroupingSymbol,
|
||||
DigitGrouping: u.DigitGrouping,
|
||||
CurrencyDisplayType: u.CurrencyDisplayType,
|
||||
ExpenseAmountColor: u.ExpenseAmountColor,
|
||||
IncomeAmountColor: u.IncomeAmountColor,
|
||||
EmailVerified: u.EmailVerified,
|
||||
Username: u.Username,
|
||||
Email: u.Email,
|
||||
Nickname: u.Nickname,
|
||||
AvatarUrl: avatarUrl,
|
||||
AvatarProvider: string(avatarProvider),
|
||||
DefaultAccountId: u.DefaultAccountId,
|
||||
TransactionEditScope: u.TransactionEditScope,
|
||||
Language: u.Language,
|
||||
DefaultCurrency: u.DefaultCurrency,
|
||||
FirstDayOfWeek: u.FirstDayOfWeek,
|
||||
LongDateFormat: u.LongDateFormat,
|
||||
ShortDateFormat: u.ShortDateFormat,
|
||||
LongTimeFormat: u.LongTimeFormat,
|
||||
ShortTimeFormat: u.ShortTimeFormat,
|
||||
DecimalSeparator: u.DecimalSeparator,
|
||||
DigitGroupingSymbol: u.DigitGroupingSymbol,
|
||||
DigitGrouping: u.DigitGrouping,
|
||||
CurrencyDisplayType: u.CurrencyDisplayType,
|
||||
CoordinateDisplayType: u.CoordinateDisplayType,
|
||||
ExpenseAmountColor: u.ExpenseAmountColor,
|
||||
IncomeAmountColor: u.IncomeAmountColor,
|
||||
EmailVerified: u.EmailVerified,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user